1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

LibWeb: Skip erroneous blit/sample corner commands in RecordingPainter

Fixes https://github.com/SerenityOS/serenity/issues/22451
This commit is contained in:
Aliaksandr Kalenik 2023-12-27 18:48:28 +01:00 committed by Andreas Kling
parent 916cb256de
commit 522302d5d6

View file

@ -433,11 +433,16 @@ void RecordingPainter::execute(PaintingCommandExecutor& executor)
executor.update_immutable_bitmap_texture_cache(immutable_bitmaps); executor.update_immutable_bitmap_texture_cache(immutable_bitmaps);
} }
HashTable<u32> skipped_sample_corner_commands;
size_t next_command_index = 0; size_t next_command_index = 0;
while (next_command_index < m_painting_commands.size()) { while (next_command_index < m_painting_commands.size()) {
auto& command = m_painting_commands[next_command_index++]; auto& command = m_painting_commands[next_command_index++];
auto bounding_rect = command_bounding_rectangle(command); auto bounding_rect = command_bounding_rectangle(command);
if (bounding_rect.has_value() && (bounding_rect->is_empty() || executor.would_be_fully_clipped_by_painter(*bounding_rect))) { if (bounding_rect.has_value() && (bounding_rect->is_empty() || executor.would_be_fully_clipped_by_painter(*bounding_rect))) {
if (command.has<SampleUnderCorners>()) {
auto const& sample_under_corners = command.get<SampleUnderCorners>();
skipped_sample_corner_commands.set(sample_under_corners.id);
}
continue; continue;
} }
@ -533,6 +538,14 @@ void RecordingPainter::execute(PaintingCommandExecutor& executor)
return executor.sample_under_corners(command.id, command.corner_radii, command.border_rect, command.corner_clip); return executor.sample_under_corners(command.id, command.corner_radii, command.border_rect, command.corner_clip);
}, },
[&](BlitCornerClipping const& command) { [&](BlitCornerClipping const& command) {
if (skipped_sample_corner_commands.contains(command.id)) {
// FIXME: If a sampling command falls outside the viewport and is not executed, the associated blit
// should also be skipped if it is within the viewport. In a properly generated list of
// painting commands, sample and blit commands should have matching rectangles, preventing
// this discrepancy.
dbgln("Skipping blit_corner_clipping command because the sample_under_corners command was skipped.");
return CommandResult::Continue;
}
return executor.blit_corner_clipping(command.id); return executor.blit_corner_clipping(command.id);
}, },
[&](PaintBorders const& command) { [&](PaintBorders const& command) {