explicitly call "our" version of clipPath in the case when clipRect needs to
authorreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 2 Mar 2009 19:41:36 +0000 (19:41 +0000)
committerreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 2 Mar 2009 19:41:36 +0000 (19:41 +0000)
turn itself into a path when the matrix rotates. This avoids infinite recursion
when the canvas is subclassed (e.g. SkPicture's recording canvas).

git-svn-id: http://skia.googlecode.com/svn/trunk@100 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkCanvas.cpp

index 9b1f768..00461b0 100644 (file)
@@ -813,6 +813,10 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op) {
     fLocalBoundsCompareTypeDirty = true;
 
     if (fMCRec->fMatrix->rectStaysRect()) {
+        // for these simpler matrices, we can stay a rect ever after applying
+        // the matrix. This means we don't have to a) make a path, and b) tell
+        // the region code to scan-convert the path, only to discover that it
+        // is really just a rect.
         SkRect      r;
         SkIRect     ir;
 
@@ -820,10 +824,14 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op) {
         r.round(&ir);
         return fMCRec->fRegion->op(ir, op);
     } else {
+        // since we're rotate or some such thing, we convert the rect to a path
+        // and clip against that, since it can handle any matrix. However, to
+        // avoid recursion in the case where we are subclassed (e.g. Pictures)
+        // we explicitly call "our" version of clipPath.
         SkPath  path;
 
         path.addRect(rect);
-        return this->clipPath(path, op);
+        return this->SkCanvas::clipPath(path, op);
     }
 }