clear the convex-hint in reset() and rewind(), to match its state in a newly
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Feb 2011 19:39:09 +0000 (19:39 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Feb 2011 19:39:09 +0000 (19:39 +0000)
created path.

todo: convexity perhaps should be tristate: yes, no, unknown

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

src/core/SkPath.cpp
tests/PathTest.cpp

index 73c1367..6aed669 100644 (file)
@@ -96,7 +96,7 @@ static void compute_pt_bounds(SkRect* bounds, const SkTDArray<SkPoint>& pts) {
 ////////////////////////////////////////////////////////////////////////////
 
 SkPath::SkPath() : fBoundsIsDirty(true), fFillType(kWinding_FillType) {
-    fIsConvex = false;
+    fIsConvex = false;  // really should be kUnknown
 }
 
 SkPath::SkPath(const SkPath& src) {
@@ -149,6 +149,7 @@ void SkPath::reset() {
     fPts.reset();
     fVerbs.reset();
     fBoundsIsDirty = true;
+    fIsConvex = false;  // really should be kUnknown
 }
 
 void SkPath::rewind() {
@@ -157,6 +158,7 @@ void SkPath::rewind() {
     fPts.rewind();
     fVerbs.rewind();
     fBoundsIsDirty = true;
+    fIsConvex = false;  // really should be kUnknown
 }
 
 bool SkPath::isEmpty() const {
index 9f26d01..b4b6317 100644 (file)
@@ -6,7 +6,7 @@ static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p,
                                 const SkRect& bounds) {
     REPORTER_ASSERT(reporter, p.isConvex());
     REPORTER_ASSERT(reporter, p.getBounds() == bounds);
-    
+
     SkPath p2(p);
     REPORTER_ASSERT(reporter, p2.isConvex());
     REPORTER_ASSERT(reporter, p2.getBounds() == bounds);
@@ -45,12 +45,12 @@ static void TestPath(skiatest::Reporter* reporter) {
     p.setIsConvex(false);
     p.addRoundRect(bounds, SK_Scalar1, SK_Scalar1);
     check_convex_bounds(reporter, p, bounds);
-    
+
     p.reset();
     p.setIsConvex(false);
     p.addOval(bounds);
     check_convex_bounds(reporter, p, bounds);
-    
+
     p.reset();
     p.setIsConvex(false);
     p.addRect(bounds);
@@ -88,6 +88,18 @@ static void TestPath(skiatest::Reporter* reporter) {
     p.moveTo(SK_Scalar1, 0);
     p.getLastPt(&pt);
     REPORTER_ASSERT(reporter, pt.fX == SK_Scalar1);
+
+    // check that reset and rewind clear the convex hint back to false
+    p.setIsConvex(false);
+    REPORTER_ASSERT(reporter, !p.isConvex());
+    p.setIsConvex(true);
+    REPORTER_ASSERT(reporter, p.isConvex());
+    p.reset();
+    REPORTER_ASSERT(reporter, !p.isConvex());
+    p.setIsConvex(true);
+    REPORTER_ASSERT(reporter, p.isConvex());
+    p.rewind();
+    REPORTER_ASSERT(reporter, !p.isConvex());
 }
 
 #include "TestClassDef.h"