summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2022-06-13 11:45:01 +0100
committerLinus Groh <mail@linusgroh.de>2022-06-13 12:00:39 +0100
commitc0486f93d4416b4f67885e6b787de542e1f680c5 (patch)
tree0cfa1f9809e3f2e81b51225833171ac7c56842e3 /Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
parent16c4b606f6eb79405a8e5132fa7cc895397c14aa (diff)
downloadserenity-c0486f93d4416b4f67885e6b787de542e1f680c5.zip
LibGfx: Optimize rounded rectangle with all radii 50% to single ellipse
It's a common pattern on the web to draw a circle/ellipse by setting the border-radius to 50%. Previously the painter would do a lot of extra work painting and clipping each corner, this now detects that case and replaces it with a single call to fill_ellipse().
Diffstat (limited to 'Userland/Libraries/LibGfx/AntiAliasingPainter.cpp')
-rw-r--r--Userland/Libraries/LibGfx/AntiAliasingPainter.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
index 1c2aaa6348..fe0e47bc8f 100644
--- a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
+++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
@@ -470,6 +470,10 @@ void Gfx::AntiAliasingPainter::fill_rect_with_rounded_corners(IntRect const& a_r
a_rect.y() + a_rect.height() - bottom_right.vertical_radius
};
+ // All corners are centered at the same point, so this can be painted as a single ellipse.
+ if (top_left_corner == top_right_corner && top_right_corner == bottom_left_corner && bottom_left_corner == bottom_right_corner)
+ return fill_ellipse(a_rect, color);
+
IntRect top_rect {
a_rect.x() + top_left.horizontal_radius,
a_rect.y(),