LibWeb+WebContent: Move display list rasterization off the main thread

The display list is an immutable data structure, so once it's created,
rasterization can be moved to a separate thread. This allows more room
for performing other tasks between processing HTML rendering tasks.

This change makes PaintingSurface, ImmutableBitmap, and GlyphRun atomic
ref-counted, as they are shared between the main and rendering threads
by being included in the display list.
This commit is contained in:
Aliaksandr Kalenik 2025-02-25 04:07:53 +01:00 committed by Alexander Kalenik
parent 86b831750d
commit 24e2c402f5
Notes: github-actions[bot] 2025-03-31 14:59:11 +00:00
16 changed files with 180 additions and 42 deletions

View file

@ -57,7 +57,14 @@ ErrorOr<GC::Ref<HTML::HTMLCanvasElement>, WebDriver::Error> draw_bounding_box_fr
auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied, canvas.surface()->size()));
auto backing_store = Web::Painting::BitmapBackingStore(bitmap);
browsing_context.page().client().paint(paint_rect.to_type<Web::DevicePixels>(), backing_store);
IGNORE_USE_IN_ESCAPING_LAMBDA bool did_paint = false;
browsing_context.page().client().start_display_list_rendering(paint_rect.to_type<Web::DevicePixels>(), backing_store, {}, [&did_paint] {
did_paint = true;
});
HTML::main_thread_event_loop().spin_until(GC::create_function(HTML::main_thread_event_loop().heap(), [&] {
return did_paint;
}));
canvas.surface()->write_from_bitmap(*bitmap);
// 7. Return success with canvas.