From 92461a2618e848c36456719bfd59767a62ab5540 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 27 Oct 2023 17:30:12 +0200 Subject: [PATCH] LibWeb: Use FillRect command in RecordingPainter if corners radius is 0 This change makes RecordingPainter to emit a FillRect command instead of FillRectWithRoundedCorners if all corners have a radius = 0. `fill_rect_with_rounded_corners()` in LibGfx already has a similar optimization. But now when we also have LibAccelGfx, which does not support painting rectangles with rounded corners yet, it makes sense to emit FillRect whenever possible. --- Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp b/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp index c325532df1..da206f5e26 100644 --- a/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp +++ b/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp @@ -352,6 +352,11 @@ void RecordingPainter::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_ void RecordingPainter::fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, Gfx::AntiAliasingPainter::CornerRadius top_left_radius, Gfx::AntiAliasingPainter::CornerRadius top_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_left_radius) { + if (!top_left_radius && !top_right_radius && !bottom_right_radius && !bottom_left_radius) { + fill_rect(rect, color); + return; + } + push_command(FillRectWithRoundedCorners { .rect = state().translation.map(rect), .color = color,