Title: [109255] trunk
Revision
109255
Author
timothy_hor...@apple.com
Date
2012-02-29 13:36:12 -0800 (Wed, 29 Feb 2012)

Log Message

Make use of CG rounded-rect primitives
https://bugs.webkit.org/show_bug.cgi?id=79932
<rdar://problem/9274953>

Reviewed by Simon Fraser.

Dispatch to potentially platform-specific rounded rectangle path
construction from addPathForRoundedRect. Make use of this to call
wkCGPathAddRoundedRect on Lion and above, as long as the rounded
corners are all equivalent.

No new tests, as this is covered by many that use rounded corners,
and is only a performance improvement.

* WebCore.exp.in:
* platform/graphics/Path.cpp:
(WebCore::Path::addRoundedRect):
(WebCore):
(WebCore::Path::addPathForRoundedRect):
* platform/graphics/Path.h:
(Path):
* platform/graphics/cg/PathCG.cpp:
(WebCore::Path::addPathForRoundedRect):
(WebCore):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Add wkCGPathAddRoundedRect.

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLeopard.a:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceSnowLeopard.a:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109254 => 109255)


--- trunk/Source/WebCore/ChangeLog	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebCore/ChangeLog	2012-02-29 21:36:12 UTC (rev 109255)
@@ -1,3 +1,32 @@
+2012-02-29  Tim Horton  <timothy_hor...@apple.com>
+
+        Make use of CG rounded-rect primitives
+        https://bugs.webkit.org/show_bug.cgi?id=79932
+        <rdar://problem/9274953>
+
+        Reviewed by Simon Fraser.
+
+        Dispatch to potentially platform-specific rounded rectangle path
+        construction from addPathForRoundedRect. Make use of this to call
+        wkCGPathAddRoundedRect on Lion and above, as long as the rounded
+        corners are all equivalent.
+
+        No new tests, as this is covered by many that use rounded corners,
+        and is only a performance improvement.
+
+        * WebCore.exp.in:
+        * platform/graphics/Path.cpp:
+        (WebCore::Path::addRoundedRect):
+        (WebCore):
+        (WebCore::Path::addPathForRoundedRect):
+        * platform/graphics/Path.h:
+        (Path):
+        * platform/graphics/cg/PathCG.cpp:
+        (WebCore::Path::addPathForRoundedRect):
+        (WebCore):
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+
 2012-02-29  Leo Yang  <leo.y...@torchmobile.com.cn>
 
         [BlackBerry] Upstream the BlackBerry change to platform/graphics/FloatPoint.h

Modified: trunk/Source/WebCore/WebCore.exp.in (109254 => 109255)


--- trunk/Source/WebCore/WebCore.exp.in	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-02-29 21:36:12 UTC (rev 109255)
@@ -1516,6 +1516,9 @@
 #endif
 _wkCGContextGetShouldSmoothFonts
 _wkCGContextResetClip
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+_wkCGPathAddRoundedRect
+#endif
 _wkCGPatternCreateWithImageAndTransform
 _wkCopyCFLocalizationPreferredName
 _wkCopyCFURLResponseSuggestedFilename

Modified: trunk/Source/WebCore/platform/graphics/Path.cpp (109254 => 109255)


--- trunk/Source/WebCore/platform/graphics/Path.cpp	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebCore/platform/graphics/Path.cpp	2012-02-29 21:36:12 UTC (rev 109255)
@@ -115,7 +115,7 @@
     if (radius.height() > halfSize.height())
         radius.setHeight(halfSize.height());
 
-    addBeziersForRoundedRect(rect, radius, radius, radius, radius);
+    addPathForRoundedRect(rect, radius, radius, radius, radius);
 }
 
 void Path::addRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
@@ -132,8 +132,15 @@
         return;
     }
 
+    addPathForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+}
+
+#if !USE(CG)
+void Path::addPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
+{
     addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
 }
+#endif
 
 // Approximation of control point positions on a bezier to simulate a quarter of a circle.
 // This is 1-kappa, where kappa = 4 * (sqrt(2) - 1) / 3

Modified: trunk/Source/WebCore/platform/graphics/Path.h (109254 => 109255)


--- trunk/Source/WebCore/platform/graphics/Path.h	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebCore/platform/graphics/Path.h	2012-02-29 21:36:12 UTC (rev 109255)
@@ -146,6 +146,7 @@
         void apply(void* info, PathApplierFunction) const;
         void transform(const AffineTransform&);
 
+        void addPathForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
         void addBeziersForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
 
     private:

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


--- trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp	2012-02-29 21:36:12 UTC (rev 109255)
@@ -39,6 +39,14 @@
 #include <wtf/MathExtras.h>
 #include <wtf/RetainPtr.h>
 
+#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#include "WebCoreSystemInterface.h"
+#endif
+
+#if PLATFORM(WIN)
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
+
 namespace WebCore {
 
 static size_t putBytesNowhere(void*, const void*, size_t count)
@@ -226,6 +234,21 @@
     CGPathAddArcToPoint(m_path, 0, p1.x(), p1.y(), p2.x(), p2.y(), radius);
 }
 
+void Path::addPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
+{
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    bool equalWidths = (topLeftRadius.width() == topRightRadius.width() && topRightRadius.width() == bottomLeftRadius.width() && bottomLeftRadius.width() == bottomRightRadius.width());
+    bool equalHeights = (topLeftRadius.height() == bottomLeftRadius.height() && bottomLeftRadius.height() == topRightRadius.height() && topRightRadius.height() == bottomRightRadius.height());
+
+    if (equalWidths && equalHeights) {
+        wkCGPathAddRoundedRect(m_path, 0, rect, topLeftRadius.width(), topLeftRadius.height());
+        return;
+    }
+#endif
+
+    addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+}
+
 void Path::closeSubpath()
 {
     CGPathCloseSubpath(m_path);

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (109254 => 109255)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2012-02-29 21:36:12 UTC (rev 109255)
@@ -41,6 +41,7 @@
 typedef struct CGFont *CGFontRef;
 typedef struct CGColorSpace *CGColorSpaceRef;
 typedef struct CGPattern *CGPatternRef;
+typedef struct CGPath *CGMutablePathRef;
 typedef unsigned short CGGlyph;
 typedef struct __CFReadStream * CFReadStreamRef;
 typedef struct __CFRunLoop * CFRunLoopRef;
@@ -305,6 +306,10 @@
 extern bool (*wkExecutableWasLinkedOnOrBeforeLion)(void);
 #endif
 
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+extern void (*wkCGPathAddRoundedRect)(CGMutablePathRef path, const CGAffineTransform* matrix, CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight);
+#endif
+
 }
 
 #endif

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (109254 => 109255)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2012-02-29 21:36:12 UTC (rev 109255)
@@ -185,3 +185,7 @@
 NSString *(*wkGetMacOSXVersionString)(void);
 bool (*wkExecutableWasLinkedOnOrBeforeLion)(void);
 #endif
+
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+void (*wkCGPathAddRoundedRect)(CGMutablePathRef path, const CGAffineTransform* matrix, CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight);
+#endif

Modified: trunk/Source/WebKit/mac/ChangeLog (109254 => 109255)


--- trunk/Source/WebKit/mac/ChangeLog	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-02-29 21:36:12 UTC (rev 109255)
@@ -1,3 +1,16 @@
+2012-02-29  Tim Horton  <timothy_hor...@apple.com>
+
+        Make use of CG rounded-rect primitives
+        https://bugs.webkit.org/show_bug.cgi?id=79932
+        <rdar://problem/9274953>
+
+        Reviewed by Simon Fraser.
+
+        Add wkCGPathAddRoundedRect.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2012-02-29  Enrica Casucci  <enr...@apple.com>
 
         Crash at -[WebFrame(WebInternal) _setTypingStyle:withUndoAction:]

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm (109254 => 109255)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm	2012-02-29 21:36:12 UTC (rev 109255)
@@ -178,5 +178,9 @@
     INIT(ExecutableWasLinkedOnOrBeforeLion);
 #endif
 
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    INIT(CGPathAddRoundedRect);
+#endif
+
     didInit = true;
 }

Modified: trunk/Source/WebKit2/ChangeLog (109254 => 109255)


--- trunk/Source/WebKit2/ChangeLog	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-29 21:36:12 UTC (rev 109255)
@@ -1,3 +1,16 @@
+2012-02-29  Tim Horton  <timothy_hor...@apple.com>
+
+        Make use of CG rounded-rect primitives
+        https://bugs.webkit.org/show_bug.cgi?id=79932
+        <rdar://problem/9274953>
+
+        Reviewed by Simon Fraser.
+
+        Add wkCGPathAddRoundedRect.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2012-02-29  Andy Estes  <aes...@apple.com>
 
         CFURLDownloadScheduleWithCurrentMessageQueue only exists on Windows

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (109254 => 109255)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2012-02-29 21:36:12 UTC (rev 109255)
@@ -163,5 +163,9 @@
         INIT(ExecutableWasLinkedOnOrBeforeLion);
 #endif
 
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+        INIT(CGPathAddRoundedRect);
+#endif
+
     });
 }

Modified: trunk/WebKitLibraries/ChangeLog (109254 => 109255)


--- trunk/WebKitLibraries/ChangeLog	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/WebKitLibraries/ChangeLog	2012-02-29 21:36:12 UTC (rev 109255)
@@ -1,3 +1,18 @@
+2012-02-29  Tim Horton  <timothy_hor...@apple.com>
+
+        Make use of CG rounded-rect primitives
+        https://bugs.webkit.org/show_bug.cgi?id=79932
+        <rdar://problem/9274953>
+
+        Reviewed by Simon Fraser.
+
+        Add wkCGPathAddRoundedRect.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceLion.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+
 2012-02-28  Jer Noble  <jer.no...@apple.com>
 
         Full screen video volume slider has "progress bar"

Modified: trunk/WebKitLibraries/WebKitSystemInterface.h (109254 => 109255)


--- trunk/WebKitLibraries/WebKitSystemInterface.h	2012-02-29 21:28:00 UTC (rev 109254)
+++ trunk/WebKitLibraries/WebKitSystemInterface.h	2012-02-29 21:36:12 UTC (rev 109255)
@@ -471,6 +471,10 @@
 bool WKExecutableWasLinkedOnOrBeforeLion(void);
 #endif
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+void WKCGPathAddRoundedRect(CGMutablePathRef path, const CGAffineTransform* matrix, CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight);
+#endif
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/WebKitLibraries/libWebKitSystemInterfaceLeopard.a


(Binary files differ)

Modified: trunk/WebKitLibraries/libWebKitSystemInterfaceLion.a


(Binary files differ)

Modified: trunk/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a


(Binary files differ)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to