mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
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:
parent
3169747989
commit
12a2aebeb6
Notes:
github-actions[bot]
2025-04-03 20:02:46 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 12a2aebeb6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4210
Reviewed-by: https://github.com/ADKaster
6 changed files with 73 additions and 52 deletions
|
@ -11,6 +11,8 @@
|
|||
#include <LibThreading/ConditionVariable.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -23,23 +25,28 @@ public:
|
|||
RenderingThread();
|
||||
~RenderingThread();
|
||||
|
||||
void start();
|
||||
void start(DisplayListPlayerType);
|
||||
void set_skia_player(OwnPtr<Painting::DisplayListPlayerSkia>&& player) { m_skia_player = move(player); }
|
||||
void enqueue_rendering_task(NonnullRefPtr<Painting::DisplayList>, NonnullRefPtr<Gfx::PaintingSurface>, Function<void()>&& callback);
|
||||
void set_skia_backend_context(RefPtr<Gfx::SkiaBackendContext> context) { m_skia_backend_context = move(context); }
|
||||
void enqueue_rendering_task(NonnullRefPtr<Painting::DisplayList>, NonnullRefPtr<Painting::BackingStore>, Function<void()>&& callback);
|
||||
void clear_bitmap_to_surface_cache();
|
||||
|
||||
private:
|
||||
void rendering_thread_loop();
|
||||
NonnullRefPtr<Gfx::PaintingSurface> painting_surface_for_backing_store(Painting::BackingStore& backing_store);
|
||||
|
||||
Core::EventLoop& m_main_thread_event_loop;
|
||||
DisplayListPlayerType m_display_list_player_type;
|
||||
|
||||
OwnPtr<Painting::DisplayListPlayerSkia> m_skia_player;
|
||||
RefPtr<Gfx::SkiaBackendContext> m_skia_backend_context;
|
||||
|
||||
RefPtr<Threading::Thread> m_thread;
|
||||
Atomic<bool> m_exit { false };
|
||||
|
||||
struct Task {
|
||||
NonnullRefPtr<Painting::DisplayList> display_list;
|
||||
NonnullRefPtr<Gfx::PaintingSurface> painting_surface;
|
||||
NonnullRefPtr<Painting::BackingStore> backing_store;
|
||||
Function<void()> callback;
|
||||
};
|
||||
// NOTE: Queue will only contain multiple items in case tasks were scheduled by screenshot requests.
|
||||
|
@ -47,6 +54,9 @@ private:
|
|||
Queue<Task> m_rendering_tasks;
|
||||
Threading::Mutex m_rendering_task_mutex;
|
||||
Threading::ConditionVariable m_rendering_task_ready_wake_condition { m_rendering_task_mutex };
|
||||
|
||||
HashMap<Gfx::Bitmap*, NonnullRefPtr<Gfx::PaintingSurface>> m_bitmap_to_surface;
|
||||
bool m_needs_to_clear_bitmap_to_surface_cache { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue