LibWeb/Painting: Do not clip border radius when it is out of viewport

Painting optimization to do less unnecessary work.
This commit is contained in:
Aliaksandr Kalenik 2023-10-18 16:24:20 +02:00 committed by Andreas Kling
parent b835d2bd66
commit 708574d373
Notes: sideshowbarker 2024-07-17 16:23:55 +09:00
3 changed files with 10 additions and 2 deletions

View file

@ -53,7 +53,7 @@ ErrorOr<NonnullRefPtr<BorderRadiusCornerClipper>> BorderRadiusCornerClipper::cre
.corner_bitmap_size = corners_bitmap_size
};
return try_make_ref_counted<BorderRadiusCornerClipper>(corner_data, corner_bitmap.release_nonnull(), corner_clip);
return try_make_ref_counted<BorderRadiusCornerClipper>(corner_data, corner_bitmap.release_nonnull(), corner_clip, border_rect);
}
void BorderRadiusCornerClipper::sample_under_corners(Gfx::Painter& page_painter)

View file

@ -41,10 +41,13 @@ public:
DevicePixelSize corner_bitmap_size;
} m_data;
BorderRadiusCornerClipper(CornerData corner_data, NonnullRefPtr<Gfx::Bitmap> corner_bitmap, CornerClip corner_clip)
DevicePixelRect border_rect() const { return m_border_rect; }
BorderRadiusCornerClipper(CornerData corner_data, NonnullRefPtr<Gfx::Bitmap> corner_bitmap, CornerClip corner_clip, DevicePixelRect const& border_rect)
: m_data(move(corner_data))
, m_corner_bitmap(corner_bitmap)
, m_corner_clip(corner_clip)
, m_border_rect(border_rect)
{
}
@ -52,6 +55,7 @@ private:
NonnullRefPtr<Gfx::Bitmap> m_corner_bitmap;
bool m_has_sampled { false };
CornerClip m_corner_clip { false };
DevicePixelRect m_border_rect;
};
struct ScopedCornerRadiusClip {

View file

@ -482,6 +482,8 @@ CommandResult DrawTriangleWave::execute(CommandExecutionState& state) const
CommandResult SampleUnderCorners::execute(CommandExecutionState& state) const
{
if (state.would_be_fully_clipped_by_painter(corner_clipper->border_rect().to_type<int>()))
return CommandResult::Continue;
auto& painter = state.painter();
corner_clipper->sample_under_corners(painter);
return CommandResult::Continue;
@ -489,6 +491,8 @@ CommandResult SampleUnderCorners::execute(CommandExecutionState& state) const
CommandResult BlitCornerClipping::execute(CommandExecutionState& state) const
{
if (state.would_be_fully_clipped_by_painter(corner_clipper->border_rect().to_type<int>()))
return CommandResult::Continue;
auto& painter = state.painter();
corner_clipper->blit_corner_clipping(painter);
return CommandResult::Continue;