LibWeb: Verify each sample corners command has matching blit command

This commit is contained in:
Aliaksandr Kalenik 2024-05-26 13:54:26 +01:00 committed by Andreas Kling
parent 1a6cf7fadc
commit 49f75d2c0f
Notes: sideshowbarker 2024-07-17 23:07:41 +09:00
4 changed files with 21 additions and 8 deletions

View file

@ -135,7 +135,7 @@ ScopedCornerRadiusClip::~ScopedCornerRadiusClip()
{
if (!m_has_radius)
return;
m_context.recording_painter().blit_corner_clipping(m_id, m_border_rect);
m_context.recording_painter().blit_corner_clipping(m_id);
}
}

View file

@ -499,7 +499,6 @@ void PaintableBox::clear_clip_overflow_rect(PaintContext& context, PaintPhase ph
if (m_clipping_overflow) {
m_clipping_overflow = false;
auto const& combined_transform = combined_css_transform();
auto const& border_radii_clips = this->border_radii_clips();
for (int corner_clip_index = border_radii_clips.size() - 1; corner_clip_index >= 0; --corner_clip_index) {
auto const& corner_clip = border_radii_clips[corner_clip_index];
@ -508,8 +507,7 @@ void PaintableBox::clear_clip_overflow_rect(PaintContext& context, PaintPhase ph
continue;
auto corner_clipper_id = m_corner_clipper_ids[corner_clip_index];
m_corner_clipper_ids[corner_clip_index] = corner_clipper_id;
auto rect = corner_clip.rect.translated(-combined_transform.translation().to_type<CSSPixels>());
context.recording_painter().blit_corner_clipping(corner_clipper_id, context.rounded_device_rect(rect).to_type<int>());
context.recording_painter().blit_corner_clipping(corner_clipper_id);
}
context.recording_painter().restore();
}
@ -724,7 +722,7 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const
if (should_clip_overflow) {
context.recording_painter().restore();
if (corner_clip_id.has_value()) {
context.recording_painter().blit_corner_clipping(*corner_clip_id, context.rounded_device_rect(clip_box).to_type<int>());
context.recording_painter().blit_corner_clipping(*corner_clip_id);
corner_clip_id = {};
}
context.recording_painter().restore();

View file

@ -15,6 +15,11 @@ RecordingPainter::RecordingPainter(CommandList& command_list)
m_state_stack.append(State());
}
RecordingPainter::~RecordingPainter()
{
VERIFY(m_corner_clip_state_stack.is_empty());
}
void RecordingPainter::append(Command&& command)
{
m_command_list.append(move(command), state().scroll_frame_id);
@ -22,6 +27,7 @@ void RecordingPainter::append(Command&& command)
void RecordingPainter::sample_under_corners(u32 id, CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip)
{
m_corner_clip_state_stack.append({ id, border_rect });
append(SampleUnderCorners {
id,
corner_radii,
@ -29,9 +35,11 @@ void RecordingPainter::sample_under_corners(u32 id, CornerRadii corner_radii, Gf
corner_clip });
}
void RecordingPainter::blit_corner_clipping(u32 id, Gfx::IntRect border_rect)
void RecordingPainter::blit_corner_clipping(u32 id)
{
append(BlitCornerClipping { id, border_rect = state().translation.map(border_rect) });
auto clip_state = m_corner_clip_state_stack.take_last();
VERIFY(clip_state.id == id);
append(BlitCornerClipping { id, state().translation.map(clip_state.rect) });
}
void RecordingPainter::fill_rect(Gfx::IntRect const& rect, Color color, Vector<Gfx::Path> const& clip_paths)

View file

@ -127,7 +127,7 @@ public:
void pop_stacking_context();
void sample_under_corners(u32 id, CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip);
void blit_corner_clipping(u32 id, Gfx::IntRect border_rect);
void blit_corner_clipping(u32 id);
void apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, CSS::ResolvedBackdropFilter const& backdrop_filter);
@ -144,6 +144,7 @@ public:
void paint_borders(DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data);
RecordingPainter(CommandList& commands_list);
~RecordingPainter();
CommandList& commands_list() { return m_command_list; }
@ -158,6 +159,12 @@ private:
State& state() { return m_state_stack.last(); }
State const& state() const { return m_state_stack.last(); }
struct CornerClipState {
u32 id;
Gfx::IntRect rect;
};
Vector<CornerClipState> m_corner_clip_state_stack;
Vector<State> m_state_stack;
CommandList& m_command_list;
};