Selaa lähdekoodia

LibWeb: Paint list markers antialiased

MacDue 3 vuotta sitten
vanhempi
commit
a705741be3
1 muutettua tiedostoa jossa 5 lisäystä ja 7 poistoa
  1. 5 7
      Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp

+ 5 - 7
Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp

@@ -4,6 +4,7 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
+#include <LibGfx/AntiAliasingPainter.h>
 #include <LibGfx/StylePainter.h>
 #include <LibWeb/Layout/ListItemMarkerBox.h>
 #include <LibWeb/Painting/MarkerPaintable.h>
@@ -43,20 +44,17 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const
     Gfx::IntRect marker_rect { 0, 0, marker_width, marker_width };
     marker_rect.center_within(enclosing);
 
+    Gfx::AntiAliasingPainter aa_painter { context.painter() };
+
     switch (layout_box().list_style_type()) {
     case CSS::ListStyleType::Square:
         context.painter().fill_rect(marker_rect, color);
         break;
     case CSS::ListStyleType::Circle:
-        // For some reason for draw_ellipse() the ellipse is outside of the rect while for fill_ellipse() the ellipse is inside.
-        // Scale the marker_rect with sqrt(2) to get an ellipse arc (circle) that appears as if it was inside of the marker_rect.
-        marker_rect.set_height(marker_rect.height() / 1.41);
-        marker_rect.set_width(marker_rect.width() / 1.41);
-        marker_rect.center_within(enclosing);
-        context.painter().draw_ellipse_intersecting(marker_rect, color);
+        aa_painter.draw_ellipse(marker_rect, color, 1);
         break;
     case CSS::ListStyleType::Disc:
-        context.painter().fill_ellipse(marker_rect, color);
+        aa_painter.fill_ellipse(marker_rect, color);
         break;
     case CSS::ListStyleType::Decimal:
     case CSS::ListStyleType::DecimalLeadingZero: