Files
ladybird/Libraries/LibWeb/HTML/RenderingThread.h
Aliaksandr Kalenik 5854bf10e6 LibWeb: Give the rendering thread its own Skia backend context
Sharing a single SkiaBackendContext between the main thread and the
rendering thread forces locking around every GPU operation. Now that
ImmutableBitmaps are context-neutral, the SkImage cache is per-painter,
and PaintingSurface accepts an explicit context, have the rendering
thread create its own GPU context on startup and use it for the
display-list player and backing store allocation.

This sets up the next commit to remove the cross-thread locking
machinery entirely.
2026-05-04 20:12:21 +02:00

57 lines
1.6 KiB
C++

/*
* Copyright (c) 2025-2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Noncopyable.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Queue.h>
#include <AK/Variant.h>
#include <LibGfx/SharedImage.h>
#include <LibThreading/ConditionVariable.h>
#include <LibThreading/Forward.h>
#include <LibThreading/Mutex.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Page/Page.h>
namespace Web::HTML {
class RenderingThread {
AK_MAKE_NONCOPYABLE(RenderingThread);
AK_MAKE_NONMOVABLE(RenderingThread);
class ThreadData;
public:
using PresentationCallback = Function<void(Gfx::IntRect const&, i32)>;
struct PresentToUI {
};
struct PublishToExternalContent {
NonnullRefPtr<Painting::ExternalContentSource> source;
};
using PresentationMode = Variant<PresentToUI, PublishToExternalContent>;
explicit RenderingThread(PresentationCallback);
~RenderingThread();
void start(DisplayListPlayerType);
void set_presentation_mode(PresentationMode);
void update_display_list(NonnullRefPtr<Painting::DisplayList>, Painting::ScrollStateSnapshot&&);
void update_backing_stores(Gfx::IntSize, i32 front_id, i32 back_id, Function<void(i32, Gfx::SharedImage, i32, Gfx::SharedImage)>&& = {});
u64 present_frame(Gfx::IntRect);
void wait_for_frame(u64 frame_id);
void request_screenshot(NonnullRefPtr<Gfx::PaintingSurface>, Function<void()>&& callback);
void ready_to_paint();
private:
NonnullRefPtr<ThreadData> m_thread_data;
RefPtr<Threading::Thread> m_thread;
};
}