Title: [275200] trunk
Revision
275200
Author
[email protected]
Date
2021-03-30 01:30:45 -0700 (Tue, 30 Mar 2021)

Log Message

[GTK][WPE] Timeouts on WPT css/css-images ref-tests after updating WPT import
https://bugs.webkit.org/show_bug.cgi?id=214472

Reviewed by Žan Doberšek.

Source/WebCore:

In some cases, degenerated and corner cases of grandient stops might
trigger really slow operations in Cairo due to extremely high bezier
parameters. For example, the normalization-conic-2.html triggered this
by making the conic code calculate the tangent of 90 degrees for an
interpolation stop.

This commit adds some special handling for these cases to make sure the
interpolation will be inside reasonable values.

Covered by existing tests.

* platform/graphics/cairo/GradientCairo.cpp:
(WebCore::createConic): Handle degenerated stops

LayoutTests:

* platform/glib/TestExpectations: Change expectations back to passes

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (275199 => 275200)


--- trunk/LayoutTests/ChangeLog	2021-03-30 07:40:46 UTC (rev 275199)
+++ trunk/LayoutTests/ChangeLog	2021-03-30 08:30:45 UTC (rev 275200)
@@ -1,3 +1,12 @@
+2021-03-30  Lauro Moura  <[email protected]>
+
+        [GTK][WPE] Timeouts on WPT css/css-images ref-tests after updating WPT import
+        https://bugs.webkit.org/show_bug.cgi?id=214472
+
+        Reviewed by Žan Doberšek.
+
+        * platform/glib/TestExpectations: Change expectations back to passes
+
 2021-03-30  Kimmo Kinnunen  <[email protected]>
 
         Update WebGL conformance test suite 2021-03-24

Modified: trunk/LayoutTests/platform/glib/TestExpectations (275199 => 275200)


--- trunk/LayoutTests/platform/glib/TestExpectations	2021-03-30 07:40:46 UTC (rev 275199)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2021-03-30 08:30:45 UTC (rev 275200)
@@ -1259,8 +1259,9 @@
 webkit.org/b/214461 imported/w3c/web-platform-tests/css/css-pseudo/active-selection-053.html [ Pass ]
 webkit.org/b/214461 imported/w3c/web-platform-tests/css/css-pseudo/active-selection-054.html [ Pass ]
 
-webkit.org/b/214472 imported/w3c/web-platform-tests/css/css-images/normalization-conic-degenerate.html [ Timeout ]
-webkit.org/b/214472 imported/w3c/web-platform-tests/css/css-images/normalization-conic.html [ Timeout ]
+webkit.org/b/214472 imported/w3c/web-platform-tests/css/css-images/normalization-conic-degenerate.html [ Pass ]
+webkit.org/b/214472 imported/w3c/web-platform-tests/css/css-images/normalization-conic.html [ Pass ]
+webkit.org/b/214472 imported/w3c/web-platform-tests/css/css-images/normalization-conic-2.html [ Pass ]
 
 webkit.org/b/214473 imported/w3c/web-platform-tests/css/css-images/image-orientation/image-orientation-from-image-computed-style.html [ Failure Pass ]
 webkit.org/b/214473 imported/w3c/web-platform-tests/css/css-images/image-orientation/image-orientation-none-computed-style.html [ Failure Pass ]

Modified: trunk/Source/WebCore/ChangeLog (275199 => 275200)


--- trunk/Source/WebCore/ChangeLog	2021-03-30 07:40:46 UTC (rev 275199)
+++ trunk/Source/WebCore/ChangeLog	2021-03-30 08:30:45 UTC (rev 275200)
@@ -1,3 +1,24 @@
+2021-03-30  Lauro Moura  <[email protected]>
+
+        [GTK][WPE] Timeouts on WPT css/css-images ref-tests after updating WPT import
+        https://bugs.webkit.org/show_bug.cgi?id=214472
+
+        Reviewed by Žan Doberšek.
+
+        In some cases, degenerated and corner cases of grandient stops might
+        trigger really slow operations in Cairo due to extremely high bezier
+        parameters. For example, the normalization-conic-2.html triggered this
+        by making the conic code calculate the tangent of 90 degrees for an
+        interpolation stop.
+
+        This commit adds some special handling for these cases to make sure the
+        interpolation will be inside reasonable values.
+
+        Covered by existing tests.
+
+        * platform/graphics/cairo/GradientCairo.cpp:
+        (WebCore::createConic): Handle degenerated stops
+
 2021-03-29  Antoine Quint  <[email protected]>
 
         Enable "hanging" and "each-line" keywords for the text-indent CSS property

Modified: trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp (275199 => 275200)


--- trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp	2021-03-30 07:40:46 UTC (rev 275199)
+++ trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp	2021-03-30 08:30:45 UTC (rev 275200)
@@ -137,14 +137,35 @@
 static RefPtr<cairo_pattern_t> createConic(float xo, float yo, float r, float angleRadians,
     Gradient::ColorStopVector stops, float globalAlpha)
 {
+    // Degenerated gradients with two stops at the same offset arrive with a single stop at 0.0
+    // Add another point here so it can be interpolated properly below.
+    if (stops.size() == 1)
+        stops = { stops.first(), stops.first() };
+
     // It's not possible to paint an entire circle with a single Bezier curve.
     // To have a good approximation to a circle it's necessary to use at least four Bezier curves.
     // So add three additional interpolated stops, allowing for four Bezier curves.
     if (stops.size() == 2) {
-        auto interpolatedStop = [&] (double fraction) -> Gradient::ColorStop {
-            return { blend(stops.first().offset, stops.last().offset, fraction), blendWithoutPremultiply(stops.first().color, stops.last().color, fraction) };
-        };
-        stops = { stops.first(), interpolatedStop(0.25), interpolatedStop(0.5), interpolatedStop(0.75), stops.last() };
+        // The first two checks avoid degenerated interpolations. These interpolations
+        // may cause Cairo to enter really slow operations with huge bezier parameters.
+        if (stops.first().offset == 1.0) {
+            auto first = stops.first();
+            stops = {
+                {0, first.color}, {0.25, first.color}, {0.5, first.color}, {0.75, first.color}, first
+            };
+        } else if (stops.last().offset == 0.0) {
+            auto last = stops.last();
+            stops = {
+                last, {0.25, last.color}, {0.5, last.color}, {0.75, last.color}, {1.0, last.color}
+            };
+        } else {
+            auto interpolatedStop = [&] (double fraction) -> Gradient::ColorStop {
+                auto offset = blend(stops.first().offset, stops.last().offset, fraction);
+                auto interpColor = blendWithoutPremultiply(stops.first().color, stops.last().color, fraction);
+                return { offset, interpColor };
+            };
+            stops = { stops.first(), interpolatedStop(0.25), interpolatedStop(0.5), interpolatedStop(0.75), stops.last() };
+        }
     }
 
     if (stops.first().offset > 0.0f)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to