LibWeb: Pass PaintingSurface into DisplayListPlayer::execute()

Deleteing set_surface() makes DisplayListPlayer API a bit more intuitive
because now caller doesn't have to think whether it's necessary to
restore previous surface after execution, instead DisplayListPlayer
takes care of it by maintaining a stack of surfaces.
This commit is contained in:
Aliaksandr Kalenik 2025-04-01 19:53:16 +02:00 committed by Alexander Kalenik
commit 24527b6ae3
Notes: github-actions[bot] 2025-04-01 21:40:08 +00:00
7 changed files with 18 additions and 19 deletions

View file

@ -35,13 +35,20 @@ static bool command_is_clip_or_mask(Command const& command)
});
}
void DisplayListPlayer::execute(DisplayList& display_list)
void DisplayListPlayer::execute(DisplayList& display_list, RefPtr<Gfx::PaintingSurface> surface)
{
if (surface)
m_surfaces.append(*surface);
ScopeGuard guard = [&surfaces = m_surfaces, pop_surface_from_stack = !!surface] {
if (pop_surface_from_stack)
(void)surfaces.take_last();
};
auto const& commands = display_list.commands();
auto const& scroll_state = display_list.scroll_state();
auto device_pixels_per_css_pixel = display_list.device_pixels_per_css_pixel();
VERIFY(m_surface);
VERIFY(!m_surfaces.is_empty());
for (size_t command_index = 0; command_index < commands.size(); command_index++) {
auto scroll_frame_id = commands[command_index].scroll_frame_id;