Title: [246981] releases/WebKitGTK/webkit-2.24/Source/WebCore
Revision
246981
Author
[email protected]
Date
2019-07-01 02:21:50 -0700 (Mon, 01 Jul 2019)

Log Message

Merge r246431 - [cairo] Entering text into forms on github.com creates a trapezoid artifact
https://bugs.webkit.org/show_bug.cgi?id=126124

Reviewed by Michael Catanzaro.

Mixing antialiasing modes in the same clip is not actually supported by cairo. In the case of rectangle clips we
are already ignoring the current antialiasing to not do any antialiasing. We could do the opposite for clips
receiving a path, we want to enforce antialiasing in that case since the paths might contain curves. Doing that
we ensure all calls to clip with a path use the same antialiasing, which is the case of the github bug.

* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::doClipWithAntialias): Helper to call cairo_clip() with the given antialising mode.
(WebCore::Cairo::clip): Use doClipWithAntialias().
(WebCore::Cairo::clipOut): Ditto.
(WebCore::Cairo::clipPath): Ditto.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog (246980 => 246981)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-07-01 09:21:46 UTC (rev 246980)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-07-01 09:21:50 UTC (rev 246981)
@@ -1,3 +1,21 @@
+2019-06-14  Carlos Garcia Campos  <[email protected]>
+
+        [cairo] Entering text into forms on github.com creates a trapezoid artifact
+        https://bugs.webkit.org/show_bug.cgi?id=126124
+
+        Reviewed by Michael Catanzaro.
+
+        Mixing antialiasing modes in the same clip is not actually supported by cairo. In the case of rectangle clips we
+        are already ignoring the current antialiasing to not do any antialiasing. We could do the opposite for clips
+        receiving a path, we want to enforce antialiasing in that case since the paths might contain curves. Doing that
+        we ensure all calls to clip with a path use the same antialiasing, which is the case of the github bug.
+
+        * platform/graphics/cairo/CairoOperations.cpp:
+        (WebCore::Cairo::doClipWithAntialias): Helper to call cairo_clip() with the given antialising mode.
+        (WebCore::Cairo::clip): Use doClipWithAntialias().
+        (WebCore::Cairo::clipOut): Ditto.
+        (WebCore::Cairo::clipPath): Ditto.
+
 2019-06-12  Carlos Garcia Campos  <[email protected]>
 
         [cairo][SVG] Putting multiple path elements in clippath causes rendering artifacts

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (246980 => 246981)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp	2019-07-01 09:21:46 UTC (rev 246980)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp	2019-07-01 09:21:50 UTC (rev 246981)
@@ -1251,6 +1251,14 @@
     cairo_paint_with_alpha(cr, platformContext.layers().takeLast());
 }
 
+static void doClipWithAntialias(cairo_t* cr, cairo_antialias_t antialias)
+{
+    auto savedAntialiasRule = cairo_get_antialias(cr);
+    cairo_set_antialias(cr, antialias);
+    cairo_clip(cr);
+    cairo_set_antialias(cr, savedAntialiasRule);
+}
+
 void clip(PlatformContextCairo& platformContext, const FloatRect& rect)
 {
     cairo_t* cr = platformContext.cr();
@@ -1262,11 +1270,8 @@
     // edge fringe artifacts may occur at the layer edges
     // when a transformation is applied to the GraphicsContext
     // while drawing the transformed layer.
-    cairo_antialias_t savedAntialiasRule = cairo_get_antialias(cr);
-    cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
-    cairo_clip(cr);
+    doClipWithAntialias(cr, CAIRO_ANTIALIAS_NONE);
     cairo_set_fill_rule(cr, savedFillRule);
-    cairo_set_antialias(cr, savedAntialiasRule);
 
     if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
         graphicsContextPrivate->clip(rect);
@@ -1281,7 +1286,7 @@
     cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
     cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
     cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
-    cairo_clip(cr);
+    doClipWithAntialias(cr, CAIRO_ANTIALIAS_NONE);
     cairo_set_fill_rule(cr, savedFillRule);
 }
 
@@ -1295,7 +1300,8 @@
 
     cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
     cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
-    cairo_clip(cr);
+    // Enforce default antialias when clipping paths, since they can contain curves.
+    doClipWithAntialias(cr, CAIRO_ANTIALIAS_DEFAULT);
     cairo_set_fill_rule(cr, savedFillRule);
 }
 
@@ -1308,7 +1314,8 @@
 
     cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
     cairo_set_fill_rule(cr, clipRule == WindRule::EvenOdd ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
-    cairo_clip(cr);
+    // Enforce default antialias when clipping paths, since they can contain curves.
+    doClipWithAntialias(cr, CAIRO_ANTIALIAS_DEFAULT);
     cairo_set_fill_rule(cr, savedFillRule);
 
     if (auto* graphicsContextPrivate = platformContext.graphicsContextPrivate())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to