Title: [112676] trunk/Source/WebCore
Revision
112676
Author
r...@google.com
Date
2012-03-30 09:33:11 -0700 (Fri, 30 Mar 2012)

Log Message

remove unneeded copies of SkPaths, remove unneeded save/restore
https://bugs.webkit.org/show_bug.cgi?id=82641

Reviewed by Stephen White.

Performance change, existing webkit tests apply.

* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::clipOut):
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::strokePath):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112675 => 112676)


--- trunk/Source/WebCore/ChangeLog	2012-03-30 16:31:14 UTC (rev 112675)
+++ trunk/Source/WebCore/ChangeLog	2012-03-30 16:33:11 UTC (rev 112676)
@@ -1,3 +1,19 @@
+2012-03-30  Mike Reed  <r...@google.com>
+
+        remove unneeded copies of SkPaths, remove unneeded save/restore
+        https://bugs.webkit.org/show_bug.cgi?id=82641
+
+        Reviewed by Stephen White.
+
+        Performance change, existing webkit tests apply.
+
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::clipOut):
+        (WebCore::GraphicsContext::clipPath):
+        (WebCore::GraphicsContext::fillPath):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::strokePath):
+
 2012-03-30  Pavel Feldman  <pfeld...@chromium.org>
 
         Web Inspector: undo-ing edit that consists of a Tab does not work.

Modified: trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp (112675 => 112676)


--- trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2012-03-30 16:31:14 UTC (rev 112675)
+++ trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2012-03-30 16:33:11 UTC (rev 112676)
@@ -395,7 +395,8 @@
     if (paintingDisabled())
         return;
 
-    SkPath path = *p.platformPath();
+    // We must make a copy of the path, to mark it as inverse-filled.
+    SkPath path(*p.platformPath());
     if (!isPathSkiaSafe(getCTM(), path))
         return;
 
@@ -408,12 +409,18 @@
     if (paintingDisabled())
         return;
 
-    SkPath path = *pathToClip.platformPath();
-    if (!isPathSkiaSafe(getCTM(), path))
+    const SkPath* path = pathToClip.platformPath();
+    if (!isPathSkiaSafe(getCTM(), *path))
         return;
 
-    path.setFillType(clipRule == RULE_EVENODD ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
-    platformContext()->clipPathAntiAliased(path);
+    SkPath::FillType ftype = (clipRule == RULE_EVENODD) ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
+    SkPath storage;
+    if (path->getFillType() != ftype) {
+        storage = *path;
+        storage.setFillType(ftype);
+        path = &storage;
+    }
+    platformContext()->clipPathAntiAliased(*path);
 }
 
 void GraphicsContext::concatCTM(const AffineTransform& affine)
@@ -802,19 +809,26 @@
     if (paintingDisabled())
         return;
 
-    SkPath path = *pathToFill.platformPath();
-    if (!isPathSkiaSafe(getCTM(), path))
+    const SkPath* path = pathToFill.platformPath();
+    if (!isPathSkiaSafe(getCTM(), *path))
       return;
 
     const GraphicsContextState& state = m_state;
-    path.setFillType(state.fillRule == RULE_EVENODD ?
-        SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
+    SkPath::FillType ftype = state.fillRule == RULE_EVENODD ?
+        SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
 
+    SkPath storage;
+    if (path->getFillType() != ftype) {
+        storage = *path;
+        storage.setFillType(ftype);
+        path = &storage;
+    }
+
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
 
-    platformContext()->canvas()->drawPath(path, paint);
-    platformContext()->didDrawPath(path, paint);
+    platformContext()->canvas()->drawPath(*path, paint);
+    platformContext()->didDrawPath(*path, paint);
 }
 
 void GraphicsContext::fillRect(const FloatRect& rect)
@@ -828,14 +842,10 @@
         ClipRectToCanvas(*platformContext()->canvas(), r, &r);
     }
 
-    platformContext()->save();
-
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
     platformContext()->canvas()->drawRect(r, paint);
     platformContext()->didDrawRect(r, paint);
-
-    platformContext()->restore();
 }
 
 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
@@ -1195,7 +1205,7 @@
     if (paintingDisabled())
         return;
 
-    SkPath path = *pathToStroke.platformPath();
+    const SkPath& path = *pathToStroke.platformPath();
     if (!isPathSkiaSafe(getCTM(), path))
         return;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to