Nested navigables were represented through compositor surface ids owned by the parent context. That forced CompositorState and ContextState to maintain bidirectional attach/detach bookkeeping, publish child snapshots into a surface map, and keep presentation mode variants just to distinguish UI presentation from parent composition. Record the child compositor context id directly in the display list and let the compositor resolve it against the painting parent at playback time. Child contexts now keep their parent context id and latest rendered surface, while parents no longer track child maps or compositor surface ids. UI presentation is represented separately from parent composition, so closing a page only stops client presentation and nested contexts keep using set_parent_context.
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2024-2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/Optional.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/Types.h>
|
|
#include <LibGfx/Forward.h>
|
|
#include <LibGfx/SharedImage.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibWeb/Compositor/Types.h>
|
|
|
|
namespace Compositor {
|
|
|
|
class BackingStoreManager {
|
|
AK_MAKE_NONCOPYABLE(BackingStoreManager);
|
|
AK_MAKE_NONMOVABLE(BackingStoreManager);
|
|
|
|
public:
|
|
struct Allocation {
|
|
Gfx::IntSize size;
|
|
i32 front_bitmap_id { -1 };
|
|
i32 back_bitmap_id { -1 };
|
|
};
|
|
struct Publication {
|
|
i32 front_bitmap_id { -1 };
|
|
Gfx::SharedImage front_shared_image;
|
|
i32 back_bitmap_id { -1 };
|
|
Gfx::SharedImage back_shared_image;
|
|
};
|
|
|
|
BackingStoreManager() = default;
|
|
|
|
Optional<Allocation> resize_backing_stores_if_needed(
|
|
Gfx::IntSize viewport_size, Web::Compositor::WindowResizingInProgress);
|
|
Optional<Publication> allocate_backing_stores(Allocation const&, RefPtr<Gfx::SkiaBackendContext> const&, bool should_publish);
|
|
|
|
bool is_valid() const;
|
|
RefPtr<Gfx::PaintingSurface> front_store_if_present() const;
|
|
Gfx::PaintingSurface& front_store();
|
|
Gfx::PaintingSurface& back_store();
|
|
i32 back_bitmap_id() const;
|
|
void swap();
|
|
|
|
private:
|
|
struct BackingStoreState {
|
|
RefPtr<Gfx::PaintingSurface> front_store;
|
|
RefPtr<Gfx::PaintingSurface> back_store;
|
|
i32 front_bitmap_id { -1 };
|
|
i32 back_bitmap_id { -1 };
|
|
|
|
bool is_valid() const { return front_store && back_store; }
|
|
};
|
|
|
|
int m_next_bitmap_id { 0 };
|
|
|
|
// Used to track if backing stores need reallocation
|
|
Gfx::IntSize m_allocated_size;
|
|
BackingStoreState m_backing_stores;
|
|
};
|
|
|
|
}
|