Title: [237280] trunk
Revision
237280
Author
commit-qu...@webkit.org
Date
2018-10-18 21:39:30 -0700 (Thu, 18 Oct 2018)

Log Message

[CG] Adopt CG SPI for non-even cornered rounded rects
https://bugs.webkit.org/show_bug.cgi?id=190155

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2018-10-18
Reviewed by Simon Fraser.

Source/WebCore:

Instead of creating bezier curves for the non-even corners of the rounded
rects, we should use the optimized SPI provided by CG.

* platform/graphics/cg/PathCG.cpp:
(WebCore::Path::platformAddPathForRoundedRect):

Source/WebCore/PAL:

* pal/spi/cg/CoreGraphicsSPI.h:

LayoutTests:

This test fails on iOS simulator because of just one pixel difference.
I think it happens because of anti aliasing the color at the border of
the black shadow. Since this test is testing the radius attribute of the
CSS box-shadow and this should not be affected by whether the shadow has
non-even rounded corners or not, I am going to change it to have even
rounded corners.

* fast/box-shadow/box-shadow-with-zero-radius-expected.html:
* fast/box-shadow/box-shadow-with-zero-radius.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237279 => 237280)


--- trunk/LayoutTests/ChangeLog	2018-10-19 03:54:51 UTC (rev 237279)
+++ trunk/LayoutTests/ChangeLog	2018-10-19 04:39:30 UTC (rev 237280)
@@ -1,3 +1,20 @@
+2018-10-18  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        [CG] Adopt CG SPI for non-even cornered rounded rects
+        https://bugs.webkit.org/show_bug.cgi?id=190155
+
+        Reviewed by Simon Fraser.
+
+        This test fails on iOS simulator because of just one pixel difference.
+        I think it happens because of anti aliasing the color at the border of
+        the black shadow. Since this test is testing the radius attribute of the
+        CSS box-shadow and this should not be affected by whether the shadow has
+        non-even rounded corners or not, I am going to change it to have even 
+        rounded corners.
+
+        * fast/box-shadow/box-shadow-with-zero-radius-expected.html:
+        * fast/box-shadow/box-shadow-with-zero-radius.html:
+
 2018-10-18  Justin Fan  <justin_...@apple.com>
 
         Add test expectations for webgpu-enabled.html

Modified: trunk/LayoutTests/fast/box-shadow/box-shadow-with-zero-radius-expected.html (237279 => 237280)


--- trunk/LayoutTests/fast/box-shadow/box-shadow-with-zero-radius-expected.html	2018-10-19 03:54:51 UTC (rev 237279)
+++ trunk/LayoutTests/fast/box-shadow/box-shadow-with-zero-radius-expected.html	2018-10-19 04:39:30 UTC (rev 237280)
@@ -20,7 +20,7 @@
     width: 120px;
     height: 120px;
     border-top-right-radius: 60px 60px;
-    border-bottom-left-radius: 70px 60px;
+    border-bottom-left-radius: 60px 60px;
     background-color: yellow;
 }
 
@@ -42,7 +42,7 @@
     width: 140px;
     height: 140px;
     border-top-right-radius: 70px 70px;
-    border-bottom-left-radius: 80px 70px;
+    border-bottom-left-radius: 70px 70px;
     background-color: black;
 }
 

Modified: trunk/LayoutTests/fast/box-shadow/box-shadow-with-zero-radius.html (237279 => 237280)


--- trunk/LayoutTests/fast/box-shadow/box-shadow-with-zero-radius.html	2018-10-19 03:54:51 UTC (rev 237279)
+++ trunk/LayoutTests/fast/box-shadow/box-shadow-with-zero-radius.html	2018-10-19 04:39:30 UTC (rev 237280)
@@ -21,7 +21,7 @@
     width: 120px;
     height: 120px;
     border-top-right-radius: 60px 60px;
-    border-bottom-left-radius: 70px 60px;
+    border-bottom-left-radius: 60px 60px;
     background-color: yellow;
     box-shadow: 110px 150px 0px 10px #000000;
 }

Modified: trunk/Source/WebCore/ChangeLog (237279 => 237280)


--- trunk/Source/WebCore/ChangeLog	2018-10-19 03:54:51 UTC (rev 237279)
+++ trunk/Source/WebCore/ChangeLog	2018-10-19 04:39:30 UTC (rev 237280)
@@ -1,3 +1,16 @@
+2018-10-18  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        [CG] Adopt CG SPI for non-even cornered rounded rects
+        https://bugs.webkit.org/show_bug.cgi?id=190155
+
+        Reviewed by Simon Fraser.
+
+        Instead of creating bezier curves for the non-even corners of the rounded
+        rects, we should use the optimized SPI provided by CG.
+
+        * platform/graphics/cg/PathCG.cpp:
+        (WebCore::Path::platformAddPathForRoundedRect):
+
 2018-10-18  Justin Michaud  <justin_mich...@apple.com>
 
         Add new image type for CSS painting API

Modified: trunk/Source/WebCore/PAL/ChangeLog (237279 => 237280)


--- trunk/Source/WebCore/PAL/ChangeLog	2018-10-19 03:54:51 UTC (rev 237279)
+++ trunk/Source/WebCore/PAL/ChangeLog	2018-10-19 04:39:30 UTC (rev 237280)
@@ -1,3 +1,12 @@
+2018-10-18  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        [CG] Adopt CG SPI for non-even cornered rounded rects
+        https://bugs.webkit.org/show_bug.cgi?id=190155
+
+        Reviewed by Simon Fraser.
+
+        * pal/spi/cg/CoreGraphicsSPI.h:
+
 2018-10-18  Alexey Proskuryakov  <a...@apple.com>
 
         Switch from PLATFORM(IOS) to PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h (237279 => 237280)


--- trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2018-10-19 03:54:51 UTC (rev 237279)
+++ trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2018-10-19 04:39:30 UTC (rev 237280)
@@ -281,7 +281,11 @@
 void CGContextSetStyle(CGContextRef, CGStyleRef);
 
 void CGContextDrawConicGradient(CGContextRef, CGGradientRef, CGPoint center, CGFloat angle);
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
+void CGPathAddUnevenCornersRoundedRect(CGMutablePathRef, const CGAffineTransform *, CGRect, const CGSize corners[4]);
 #endif
+#endif
 
 #if PLATFORM(WIN)
 CGFontCache* CGFontCacheGetLocalCache();

Modified: trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp (237279 => 237280)


--- trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp	2018-10-19 03:54:51 UTC (rev 237279)
+++ trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp	2018-10-19 04:39:30 UTC (rev 237280)
@@ -318,7 +318,14 @@
         CGPathAddRoundedRect(ensurePlatformPath(), nullptr, rectToDraw, radiusWidth, radiusHeight);
         return;
     }
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
+    CGRect rectToDraw = rect;
+    CGSize corners[4] = { bottomLeftRadius, bottomRightRadius, topRightRadius, topLeftRadius };
+    CGPathAddUnevenCornersRoundedRect(ensurePlatformPath(), nullptr, rectToDraw, corners);
+    return;
 #endif
+#endif
 
     addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to