Bläddra i källkod

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.
Aliaksandr Kalenik 1 år sedan
förälder
incheckning
92461a2618
1 ändrade filer med 5 tillägg och 0 borttagningar
  1. 5 0
      Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp

+ 5 - 0
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,