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

LibWeb: Remove "cached corner bitmap" and its use in the corner clipper

With the recording painter the actual painting operations are delayed,
so now if multiple corner clippers are constructed, and they use a
shared bitmap they can interfere with each other. The use of this shared
bitmap was somewhat questionable anyway, so this is not much of a loss.

This fixes the border-radius.html test page.
This commit is contained in:
MacDue 2023-10-21 19:17:49 +01:00 committed by Alexander Kalenik
parent 1a58fee0fd
commit 1c012f0a4a
5 changed files with 8 additions and 50 deletions

View file

@ -545,31 +545,6 @@ void paint_border(PaintContext& context, BorderEdge edge, DevicePixelRect const&
}
}
RefPtr<Gfx::Bitmap> get_cached_corner_bitmap(DevicePixelSize corners_size)
{
auto allocate_mask_bitmap = [&]() -> RefPtr<Gfx::Bitmap> {
auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, corners_size.to_type<int>());
if (!bitmap.is_error())
return bitmap.release_value();
return nullptr;
};
// FIXME: Allocate per page?
static thread_local auto corner_bitmap = allocate_mask_bitmap();
// Only reallocate the corner bitmap is the existing one is too small.
// (should mean no more allocations after the first paint -- amortised zero allocations :^))
if (corner_bitmap && corner_bitmap->rect().size().contains(corners_size.to_type<int>())) {
Gfx::Painter painter { *corner_bitmap };
painter.clear_rect({ { 0, 0 }, corners_size }, Gfx::Color());
} else {
corner_bitmap = allocate_mask_bitmap();
if (!corner_bitmap) {
dbgln("Failed to allocate corner bitmap with size {}", corners_size);
return nullptr;
}
}
return corner_bitmap;
}
void paint_all_borders(PaintContext& context, DevicePixelRect const& border_rect, BorderRadiiData const& border_radii_data, BordersData const& borders_data)
{
if (borders_data.top.width <= 0 && borders_data.right.width <= 0 && borders_data.left.width <= 0 && borders_data.bottom.width <= 0)