LibWeb: Add save and restore commands in recording painter

This change is a preparation before introducing Skia painter in an
upcoming change. It's needed because Skia does not have an API to
implement ClearClipRect command. It only allows to return previous
clip rect by popping from its internal state stack.

A bit more context: initially we had save and restore commands, but
their frequent use led to many reallocations of vector during painting
commands recording. To resolve this, we switched to SegmentedVector to
store commands list, which allows fast appends. Now, having many save
and restore commands no longer causes noticeable performance issue.
This commit is contained in:
Aliaksandr Kalenik
2024-06-10 14:18:32 +03:00
committed by Andreas Kling
parent 0e705f431e
commit 8a7cd8055f
10 changed files with 58 additions and 49 deletions

View File

@@ -89,15 +89,21 @@ CommandResult CommandExecutorGPU::draw_scaled_immutable_bitmap(DrawScaledImmutab
return CommandResult::Continue;
}
CommandResult CommandExecutorGPU::set_clip_rect(SetClipRect const& command)
CommandResult CommandExecutorGPU::save(Save const&)
{
painter().set_clip_rect(command.rect);
painter().save();
return CommandResult::Continue;
}
CommandResult CommandExecutorGPU::clear_clip_rect(ClearClipRect const&)
CommandResult CommandExecutorGPU::restore(Restore const&)
{
painter().clear_clip_rect();
painter().restore();
return CommandResult::Continue;
}
CommandResult CommandExecutorGPU::add_clip_rect(AddClipRect const& command)
{
painter().set_clip_rect(command.rect);
return CommandResult::Continue;
}