mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
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:
parent
b835d2bd66
commit
708574d373
Notes:
sideshowbarker
2024-07-17 16:23:55 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/708574d373 Pull-request: https://github.com/SerenityOS/serenity/pull/21487
3 changed files with 10 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue