Avoid filling a rounded rect when radii are zero
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Jan 2013 20:36:54 +0000 (20:36 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Jan 2013 20:36:54 +0000 (20:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107402
<rdar://problem/12793315>

Reviewed by Sam Weinig.

It's more efficient to clip and fill rects than rounded rects,
so optimize for the case where rounded rect radii are zero.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::clipRoundedRect):
(WebCore::GraphicsContext::clipOutRoundedRect):
(WebCore::GraphicsContext::fillRoundedRect):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140279 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.cpp

index 01316af..711f4cc 100644 (file)
@@ -1,3 +1,19 @@
+2013-01-20  Simon Fraser  <simon.fraser@apple.com>
+
+        Avoid filling a rounded rect when radii are zero
+        https://bugs.webkit.org/show_bug.cgi?id=107402
+        <rdar://problem/12793315>
+
+        Reviewed by Sam Weinig.
+
+        It's more efficient to clip and fill rects than rounded rects,
+        so optimize for the case where rounded rect radii are zero.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::clipRoundedRect):
+        (WebCore::GraphicsContext::clipOutRoundedRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+
 2013-01-20  Alexey Proskuryakov  <ap@apple.com>
 
         Remove obsolete plug-in sandboxing code.
index 69ad4fd..1d57207 100644 (file)
@@ -602,6 +602,11 @@ void GraphicsContext::clipRoundedRect(const RoundedRect& rect)
     if (paintingDisabled())
         return;
 
+    if (!rect.isRounded()) {
+        clip(rect.rect());
+        return;
+    }
+
     Path path;
     path.addRoundedRect(rect);
     clip(path);
@@ -613,6 +618,11 @@ void GraphicsContext::clipOutRoundedRect(const RoundedRect& rect)
     if (paintingDisabled())
         return;
 
+    if (!rect.isRounded()) {
+        clipOut(rect.rect());
+        return;
+    }
+
     Path path;
     path.addRoundedRect(rect);
     clipOut(path);
@@ -666,7 +676,10 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
 
 void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace)
 {
-    fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
+    if (rect.isRounded())
+        fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
+    else
+        fillRect(rect.rect(), color, colorSpace);
 }
 
 #if !USE(CG)