fix validate() to note that an empty path can (by side-effect) have an empty but
authorreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 11 Aug 2009 19:54:35 +0000 (19:54 +0000)
committerreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 11 Aug 2009 19:54:35 +0000 (19:54 +0000)
translated fBounds

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

src/core/SkPath.cpp

index 794681c81e9766cd0c8b4e1a6724a6137f7a1beb..63c3eb06fa51fc9b1a7ead2328d9fe1fd5da2a01 100644 (file)
@@ -1233,11 +1233,16 @@ void SkPath::validate() const {
     if (!fBoundsIsDirty) {
         SkRect bounds;
         compute_pt_bounds(&bounds, fPts);
-        // can't call contains(), since it returns false if the rect is empty
-        SkASSERT(fBounds.fLeft <= bounds.fLeft);
-        SkASSERT(fBounds.fTop <= bounds.fTop);
-        SkASSERT(fBounds.fRight >= bounds.fRight);
-        SkASSERT(fBounds.fBottom >= bounds.fBottom);
+        if (fPts.count() <= 1) {
+            // if we're empty, fBounds may be empty but translated, so we can't
+            // necessarily compare to bounds directly
+            // try path.addOval(2, 2, 2, 2) which is empty, but the bounds will
+            // be [2, 2, 2, 2]
+            SkASSERT(bounds.isEmpty());
+            SkASSERT(fBounds.isEmpty());
+        } else {
+            fBounds.contains(bounds);
+        }
     }
 }