LibWeb: Move painting surface allocation into rendering thread

Skia has a check in debug mode to verify that surface is only used
within one thread. Before this change we were violating this by
allocating surfaces on the main thread while using and destructing them
on the rendering thread.
This commit is contained in:
Aliaksandr Kalenik 2025-04-03 18:03:17 +02:00 committed by Alexander Kalenik
commit 12a2aebeb6
Notes: github-actions[bot] 2025-04-03 20:02:46 +00:00
6 changed files with 73 additions and 52 deletions

View file

@ -98,7 +98,7 @@ public:
[[nodiscard]] GC::Ptr<DOM::Node> currently_focused_area();
RefPtr<Painting::DisplayList> record_display_list(DevicePixelRect const&, PaintOptions);
void start_display_list_rendering(NonnullRefPtr<Painting::DisplayList> display_list, NonnullRefPtr<Gfx::PaintingSurface> painting_surface, Function<void()>&& callback);
void start_display_list_rendering(NonnullRefPtr<Painting::DisplayList>, NonnullRefPtr<Painting::BackingStore>, Function<void()>&& callback);
enum class CheckIfUnloadingIsCanceledResult {
CanceledByBeforeUnload,
@ -117,8 +117,6 @@ public:
bool needs_repaint() const { return m_needs_repaint; }
void set_needs_repaint() { m_needs_repaint = true; }
NonnullRefPtr<Gfx::PaintingSurface> painting_surface_for_backing_store(Painting::BackingStore&);
private:
TraversableNavigable(GC::Ref<Page>);
@ -140,6 +138,8 @@ private:
[[nodiscard]] bool can_go_forward() const;
RenderingThread m_rendering_thread;
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
int m_current_session_history_step { 0 };
@ -163,11 +163,8 @@ private:
String m_window_handle;
RefPtr<Gfx::SkiaBackendContext> m_skia_backend_context;
HashMap<Gfx::Bitmap*, NonnullRefPtr<Gfx::PaintingSurface>> m_bitmap_to_surface;
bool m_needs_repaint { true };
RenderingThread m_rendering_thread;
};
struct BrowsingContextAndDocument {