mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 09:52:31 +00:00
LibWeb: Allow working on N+1 frame while N is rasterizing
This change allows us to overlap rasterization and rendering work across threads: while the rasterization thread processes frame N, the main thread can simultaneously work on producing the display list for frame N+1.
This commit is contained in:
parent
7248748157
commit
cb722ca18b
Notes:
github-actions[bot]
2025-04-01 10:18:57 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: cb722ca18b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4163
Reviewed-by: https://github.com/gmta ✅
3 changed files with 27 additions and 20 deletions
|
@ -81,12 +81,7 @@ PageClient::~PageClient() = default;
|
|||
|
||||
bool PageClient::is_ready_to_paint() const
|
||||
{
|
||||
return m_paint_state == PaintState::Ready;
|
||||
}
|
||||
|
||||
void PageClient::ready_to_paint()
|
||||
{
|
||||
m_paint_state = PaintState::Ready;
|
||||
return m_number_of_queued_rasterization_tasks <= 1;
|
||||
}
|
||||
|
||||
void PageClient::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
@ -220,18 +215,24 @@ void PageClient::process_screenshot_requests()
|
|||
}
|
||||
}
|
||||
|
||||
void PageClient::ready_to_paint()
|
||||
{
|
||||
m_number_of_queued_rasterization_tasks--;
|
||||
VERIFY(m_number_of_queued_rasterization_tasks >= 0 && m_number_of_queued_rasterization_tasks < 2);
|
||||
}
|
||||
|
||||
void PageClient::paint_next_frame()
|
||||
{
|
||||
auto back_store = m_backing_store_manager.back_store();
|
||||
auto [backing_store_id, back_store] = m_backing_store_manager.acquire_store_for_next_frame();
|
||||
if (!back_store)
|
||||
return;
|
||||
|
||||
m_paint_state = PaintState::WaitingForClient;
|
||||
VERIFY(m_number_of_queued_rasterization_tasks <= 1);
|
||||
m_number_of_queued_rasterization_tasks++;
|
||||
|
||||
auto viewport_rect = page().css_to_device_rect(page().top_level_traversable()->viewport_rect());
|
||||
start_display_list_rendering(viewport_rect, *back_store, {}, [this, viewport_rect]() {
|
||||
m_backing_store_manager.swap_back_and_front();
|
||||
client().async_did_paint(m_id, viewport_rect.to_type<int>(), m_backing_store_manager.front_id());
|
||||
start_display_list_rendering(viewport_rect, *back_store, {}, [this, viewport_rect, backing_store_id] {
|
||||
client().async_did_paint(m_id, viewport_rect.to_type<int>(), backing_store_id);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue