LibWeb+WebContent+WebWorker: Move backing store allocation in Navigable

Making navigables responsible for backing store allocation will allow us
to have separate backing stores for iframes and run paint updates for
them independently, which is a step toward isolating them into separate
processes.

Another nice side effect is that now Skia backend context is ready by
the time backing stores are allocated, so we will be able to get rid of
BackingStore class in the upcoming changes and allocate PaintingSurface
directly.
This commit is contained in:
Aliaksandr Kalenik 2025-06-26 22:33:58 +02:00 committed by Jelle Raaijmakers
commit 082053d781
Notes: github-actions[bot] 2025-07-04 14:14:12 +00:00
23 changed files with 265 additions and 262 deletions

View file

@ -0,0 +1,63 @@
/*
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/Painting/BackingStore.h>
namespace Web::Painting {
class BackingStoreManager : public JS::Cell {
GC_CELL(BackingStoreManager, JS::Cell);
GC_DECLARE_ALLOCATOR(BackingStoreManager);
public:
#ifdef AK_OS_MACOS
static void set_browser_mach_port(Core::MachPort&&);
#endif
enum class WindowResizingInProgress {
No,
Yes
};
void resize_backing_stores_if_needed(WindowResizingInProgress window_resize_in_progress);
void reallocate_backing_stores(Gfx::IntSize);
void restart_resize_timer();
struct BackingStore {
i32 bitmap_id { -1 };
Web::Painting::BackingStore* store { nullptr };
};
BackingStore acquire_store_for_next_frame()
{
BackingStore backing_store;
backing_store.bitmap_id = m_back_bitmap_id;
backing_store.store = m_back_store.ptr();
swap_back_and_front();
return backing_store;
}
virtual void visit_edges(Cell::Visitor& visitor) override;
BackingStoreManager(HTML::Navigable&);
private:
void swap_back_and_front();
GC::Ref<HTML::Navigable> m_navigable;
i32 m_front_bitmap_id { -1 };
i32 m_back_bitmap_id { -1 };
RefPtr<Painting::BackingStore> m_front_store;
RefPtr<Painting::BackingStore> m_back_store;
int m_next_bitmap_id { 0 };
RefPtr<Core::Timer> m_backing_store_shrink_timer;
};
}