Add special handling of rectori case for gpu

https://codereview.chromium.org/15080010/



git-svn-id: http://skia.googlecode.com/svn/trunk@9175 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index d62a8e4..bf55f9b 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1322,22 +1322,22 @@
 
 static void test_isNestedRects(skiatest::Reporter* reporter) {
     // passing tests (all moveTo / lineTo...
-    SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
+    SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW
     SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}};
     SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}};
     SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}};
-    SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};
+    SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW
     SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}};
     SkPoint r7[] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}};
     SkPoint r8[] = {{1, 0}, {0, 0}, {0, 1}, {1, 1}};
     SkPoint r9[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}};
-    SkPoint ra[] = {{0, 0}, {0, .5f}, {0, 1}, {.5f, 1}, {1, 1}, {1, .5f},
+    SkPoint ra[] = {{0, 0}, {0, .5f}, {0, 1}, {.5f, 1}, {1, 1}, {1, .5f}, // CCW
         {1, 0}, {.5f, 0}};
-    SkPoint rb[] = {{0, 0}, {.5f, 0}, {1, 0}, {1, .5f}, {1, 1}, {.5f, 1},
+    SkPoint rb[] = {{0, 0}, {.5f, 0}, {1, 0}, {1, .5f}, {1, 1}, {.5f, 1}, // CW
         {0, 1}, {0, .5f}};
-    SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}};
-    SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}};
-    SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}};
+    SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}; // CW
+    SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; // CCW
+    SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW
 
     // failing tests
     SkPoint f1[] = {{0, 0}, {1, 0}, {1, 1}}; // too few points
@@ -1366,6 +1366,18 @@
         f1, f2, f3, f4, f5, f6, f7, f8,
         c1, c2
     };
+    SkPath::Direction dirs[] = { 
+        SkPath::kCW_Direction, SkPath::kCW_Direction, SkPath::kCW_Direction, 
+        SkPath::kCW_Direction, SkPath::kCCW_Direction, SkPath::kCCW_Direction,
+        SkPath::kCCW_Direction, SkPath::kCCW_Direction, SkPath::kCCW_Direction, 
+        SkPath::kCCW_Direction, SkPath::kCW_Direction, SkPath::kCW_Direction, 
+        SkPath::kCCW_Direction, SkPath::kCW_Direction, SkPath::kUnknown_Direction,
+        SkPath::kUnknown_Direction, SkPath::kUnknown_Direction, SkPath::kUnknown_Direction,
+        SkPath::kUnknown_Direction, SkPath::kUnknown_Direction, SkPath::kUnknown_Direction,
+        SkPath::kUnknown_Direction, SkPath::kUnknown_Direction, SkPath::kUnknown_Direction,
+    };
+    SkASSERT(SK_ARRAY_COUNT(tests) == SK_ARRAY_COUNT(dirs));
+
     const SkPoint* lastPass = re;
     const SkPoint* lastClose = f8;
     const size_t testCount = sizeof(tests) / sizeof(tests[0]);
@@ -1391,13 +1403,22 @@
             REPORTER_ASSERT(reporter, fail ^ path.isNestedRects(0));
             if (!fail) {
                 SkRect expected[2], computed[2];
+                SkPath::Direction expectedDirs[2], computedDirs[2];
                 SkRect testBounds;
                 testBounds.set(tests[testIndex], testLen[testIndex] / sizeof(SkPoint));
                 expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2);
                 expected[1] = testBounds;
-                REPORTER_ASSERT(reporter, path.isNestedRects(computed));
+                if (rectFirst) {
+                    expectedDirs[0] = SkPath::kCW_Direction;
+                } else {
+                    expectedDirs[0] = SkPath::kCCW_Direction;
+                }
+                expectedDirs[1] = dirs[testIndex];
+                REPORTER_ASSERT(reporter, path.isNestedRects(computed, computedDirs));
                 REPORTER_ASSERT(reporter, expected[0] == computed[0]);
                 REPORTER_ASSERT(reporter, expected[1] == computed[1]);
+                REPORTER_ASSERT(reporter, expectedDirs[0] == computedDirs[0]);
+                REPORTER_ASSERT(reporter, expectedDirs[1] == computedDirs[1]);
             }
             if (tests[testIndex] == lastPass) {
                 fail = true;