add rect-output parameter to isRect, allowing us to return the correct bounds even if a rectagular path has a trailing moveTo

 https://code.google.com/p/chromium/issues/detail?id=247770

R=caryclark@google.com

Review URL: https://codereview.chromium.org/16950021

git-svn-id: http://skia.googlecode.com/svn/trunk@9724 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 6c8f83e..41151a5 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1230,8 +1230,7 @@
         if (close) {
             path.close();
         }
-        REPORTER_ASSERT(reporter, fail ^ path.isRect(0));
-        REPORTER_ASSERT(reporter, fail ^ path.isRect(NULL, NULL));
+        REPORTER_ASSERT(reporter, fail ^ path.isRect(NULL));
 
         if (!fail) {
             SkRect computed, expected;
@@ -1242,7 +1241,7 @@
             bool isClosed;
             SkPath::Direction direction, cheapDirection;
             REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection));
-            REPORTER_ASSERT(reporter, path.isRect(&isClosed, &direction));
+            REPORTER_ASSERT(reporter, path.isRect(NULL, &isClosed, &direction));
             REPORTER_ASSERT(reporter, isClosed == close);
             REPORTER_ASSERT(reporter, direction == cheapDirection);
         } else {
@@ -1254,7 +1253,7 @@
 
             bool isClosed = (bool) -1;
             SkPath::Direction direction = (SkPath::Direction) -1;
-            REPORTER_ASSERT(reporter, !path.isRect(&isClosed, &direction));
+            REPORTER_ASSERT(reporter, !path.isRect(NULL, &isClosed, &direction));
             REPORTER_ASSERT(reporter, isClosed == (bool) -1);
             REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
         }
@@ -1275,7 +1274,7 @@
     }
     path1.close();
     path1.lineTo(1, 0);
-    REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+    REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
 
     // fail, move in the middle
     path1.reset();
@@ -1287,7 +1286,7 @@
         path1.lineTo(r1[index].fX, r1[index].fY);
     }
     path1.close();
-    REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+    REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
 
     // fail, move on the edge
     path1.reset();
@@ -1296,7 +1295,7 @@
         path1.lineTo(r1[index].fX, r1[index].fY);
     }
     path1.close();
-    REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+    REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
 
     // fail, quad
     path1.reset();
@@ -1308,7 +1307,7 @@
         path1.lineTo(r1[index].fX, r1[index].fY);
     }
     path1.close();
-    REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+    REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
 
     // fail, cubic
     path1.reset();
@@ -1320,7 +1319,7 @@
         path1.lineTo(r1[index].fX, r1[index].fY);
     }
     path1.close();
-    REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+    REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
 }
 
 static void test_isNestedRects(skiatest::Reporter* reporter) {
@@ -2409,6 +2408,19 @@
     p.addRect(bounds);
     REPORTER_ASSERT(reporter, !p.isRect(NULL));
 
+    // test isRect for a trailing moveTo
+    {
+        SkRect r;
+        p.reset();
+        p.addRect(bounds);
+        REPORTER_ASSERT(reporter, p.isRect(&r));
+        REPORTER_ASSERT(reporter, r == bounds);
+        // add a moveTo outside of our bounds
+        p.moveTo(bounds.fLeft + 10, bounds.fBottom + 10);
+        REPORTER_ASSERT(reporter, p.isRect(&r));
+        REPORTER_ASSERT(reporter, r == bounds);
+    }
+    
     test_isLine(reporter);
     test_isRect(reporter);
     test_isNestedRects(reporter);