| Index: tests/PathTest.cpp
|
| ===================================================================
|
| --- tests/PathTest.cpp (revision 9163)
|
| +++ tests/PathTest.cpp (working copy)
|
| @@ -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;
|
|
|