diff options
author | MacDue <macdue@dueutil.tech> | 2022-07-04 20:43:40 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-04 23:09:06 +0200 |
commit | 9a97adf121bd032bad11a7c659ca6763669b91a0 (patch) | |
tree | 9558118ae5238ec62626eeb41782151860b15677 /Userland/Libraries/LibWeb/Painting | |
parent | 13b4d91f66d1dce494d24ed08a845a5ca3060263 (diff) | |
download | serenity-9a97adf121bd032bad11a7c659ca6763669b91a0.zip |
LibWeb: Add option to allocate new bitmap for BorderRadiusCornerClipper
This will be needed for overflow: hidden, that clips things which may
themselves use the BorderRadiusCornerClipper.
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting')
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp | 13 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.h | 7 |
2 files changed, 15 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp b/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp index 6e73d7fa00..7b21ebe38c 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp +++ b/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp @@ -10,7 +10,7 @@ namespace Web::Painting { -ErrorOr<BorderRadiusCornerClipper> BorderRadiusCornerClipper::create(Gfx::IntRect const& border_rect, BorderRadiiData const& border_radii, CornerClip corner_clip) +ErrorOr<BorderRadiusCornerClipper> BorderRadiusCornerClipper::create(Gfx::IntRect const& border_rect, BorderRadiiData const& border_radii, CornerClip corner_clip, UseCachedBitmap use_cached_bitmap) { VERIFY(border_radii.has_any_radius()); @@ -28,9 +28,14 @@ ErrorOr<BorderRadiusCornerClipper> BorderRadiusCornerClipper::create(Gfx::IntRec top_right.vertical_radius + bottom_right.vertical_radius) }; - auto corner_bitmap = get_cached_corner_bitmap(corners_bitmap_size); - if (!corner_bitmap) - return Error::from_errno(ENOMEM); + RefPtr<Gfx::Bitmap> corner_bitmap; + if (use_cached_bitmap == UseCachedBitmap::Yes) { + corner_bitmap = get_cached_corner_bitmap(corners_bitmap_size); + if (!corner_bitmap) + return Error::from_errno(ENOMEM); + } else { + corner_bitmap = TRY(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, corners_bitmap_size)); + } CornerData corner_data { .corner_radii = { diff --git a/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.h b/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.h index cdb8176503..c60cf747de 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.h +++ b/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.h @@ -18,7 +18,12 @@ enum class CornerClip { class BorderRadiusCornerClipper { public: - static ErrorOr<BorderRadiusCornerClipper> create(Gfx::IntRect const& border_rect, BorderRadiiData const& border_radii, CornerClip corner_clip = CornerClip::Outside); + enum class UseCachedBitmap { + Yes, + No + }; + + static ErrorOr<BorderRadiusCornerClipper> create(Gfx::IntRect const& border_rect, BorderRadiiData const& border_radii, CornerClip corner_clip = CornerClip::Outside, UseCachedBitmap use_cached_bitmap = UseCachedBitmap::Yes); void sample_under_corners(Gfx::Painter& page_painter); void blit_corner_clipping(Gfx::Painter& page_painter); |