OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "PathOpsExtendedTest.h" | 7 #include "PathOpsExtendedTest.h" |
| 8 #include "PathOpsThreadedCommon.h" |
8 | 9 |
9 static THREAD_TYPE testSimplifyDegeneratesMain(void* data) { | 10 static void testSimplifyDegeneratesMain(PathOpsThreadState* data) { |
10 SkASSERT(data); | 11 SkASSERT(data); |
11 State4& state = *(State4*) data; | 12 PathOpsThreadState& state = *data; |
12 char pathStr[1024]; | 13 char pathStr[1024]; |
13 sk_bzero(pathStr, sizeof(pathStr)); | 14 sk_bzero(pathStr, sizeof(pathStr)); |
14 do { | 15 int ax = state.fA & 0x03; |
15 int ax = state.a & 0x03; | 16 int ay = state.fA >> 2; |
16 int ay = state.a >> 2; | 17 int bx = state.fB & 0x03; |
17 int bx = state.b & 0x03; | 18 int by = state.fB >> 2; |
18 int by = state.b >> 2; | 19 int cx = state.fC & 0x03; |
19 int cx = state.c & 0x03; | 20 int cy = state.fC >> 2; |
20 int cy = state.c >> 2; | 21 for (int d = 0; d < 16; ++d) { |
21 for (int d = 0; d < 16; ++d) { | 22 int dx = d & 0x03; |
22 int dx = d & 0x03; | 23 int dy = d >> 2; |
23 int dy = d >> 2; | 24 for (int e = d ; e < 16; ++e) { |
24 for (int e = d ; e < 16; ++e) { | 25 int ex = e & 0x03; |
25 int ex = e & 0x03; | 26 int ey = e >> 2; |
26 int ey = e >> 2; | 27 for (int f = d ; f < 16; ++f) { |
27 for (int f = d ; f < 16; ++f) { | 28 int fx = f & 0x03; |
28 int fx = f & 0x03; | 29 int fy = f >> 2; |
29 int fy = f >> 2; | 30 if (state.fD && (ex - dx) * (fy - dy) |
30 if (state.d && (ex - dx) * (fy - dy) | 31 != (ey - dy) * (fx - dx)) { |
31 != (ey - dy) * (fx - dx)) { | 32 continue; |
32 continue; | |
33 } | |
34 SkPath path, out; | |
35 path.setFillType(SkPath::kWinding_FillType); | |
36 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | |
37 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | |
38 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | |
39 path.close(); | |
40 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); | |
41 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); | |
42 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | |
43 path.close(); | |
44 if (1) { | |
45 char* str = pathStr; | |
46 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay
); | |
47 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by
); | |
48 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy
); | |
49 str += sprintf(str, " path.close();\n"); | |
50 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy
); | |
51 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey
); | |
52 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy
); | |
53 str += sprintf(str, " path.close();\n"); | |
54 } | |
55 outputProgress(state, pathStr, SkPath::kWinding_FillType); | |
56 testSimplify(path, false, out, state, pathStr); | |
57 state.testsRun++; | |
58 path.setFillType(SkPath::kEvenOdd_FillType); | |
59 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); | |
60 testSimplify(path, true, out, state, pathStr); | |
61 state.testsRun++; | |
62 } | 33 } |
| 34 SkPath path, out; |
| 35 path.setFillType(SkPath::kWinding_FillType); |
| 36 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |
| 37 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); |
| 38 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); |
| 39 path.close(); |
| 40 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); |
| 41 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); |
| 42 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |
| 43 path.close(); |
| 44 char* str = pathStr; |
| 45 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); |
| 46 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by); |
| 47 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy); |
| 48 str += sprintf(str, " path.close();\n"); |
| 49 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy); |
| 50 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey); |
| 51 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); |
| 52 str += sprintf(str, " path.close();\n"); |
| 53 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillTyp
e); |
| 54 testSimplify(path, false, out, state, pathStr); |
| 55 path.setFillType(SkPath::kEvenOdd_FillType); |
| 56 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillTyp
e); |
| 57 testSimplify(path, true, out, state, pathStr); |
63 } | 58 } |
64 } | 59 } |
65 } while (runNextTestSet(state)); | 60 } |
66 THREAD_RETURN | |
67 } | 61 } |
68 | 62 |
69 static void TestSimplifyDegeneratesThreaded(skiatest::Reporter* reporter) { | 63 static void TestSimplifyDegeneratesThreaded(skiatest::Reporter* reporter) { |
70 int testsRun = 0; | 64 int threadCount = initializeTests("testDegenerates"); |
71 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__); | 65 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
72 #ifdef SK_DEBUG | |
73 gDebugMaxWindSum = 2; | |
74 gDebugMaxWindValue = 2; | |
75 #endif | |
76 const char testStr[] = "testDegenerates"; | |
77 initializeTests(reporter, testStr, sizeof(testStr)); | |
78 for (int a = 0; a < 16; ++a) { | 66 for (int a = 0; a < 16; ++a) { |
79 int ax = a & 0x03; | 67 int ax = a & 0x03; |
80 int ay = a >> 2; | 68 int ay = a >> 2; |
81 for (int b = a ; b < 16; ++b) { | 69 for (int b = a ; b < 16; ++b) { |
82 int bx = b & 0x03; | 70 int bx = b & 0x03; |
83 int by = b >> 2; | 71 int by = b >> 2; |
84 for (int c = a ; c < 16; ++c) { | 72 for (int c = a ; c < 16; ++c) { |
85 int cx = c & 0x03; | 73 int cx = c & 0x03; |
86 int cy = c >> 2; | 74 int cy = c >> 2; |
87 bool abcIsATriangle = (bx - ax) * (cy - ay) != (by - ay) * (cx -
ax); | 75 bool abcIsATriangle = (bx - ax) * (cy - ay) != (by - ay) * (cx -
ax); |
88 testsRun += dispatchTest4(testSimplifyDegeneratesMain, | 76 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunn
able, |
89 a, b, c, abcIsATriangle); | 77 (&testSimplifyDegeneratesMain, a, b, c, abcIsATriangle, |
| 78 &testRunner)); |
90 } | 79 } |
91 if (!gAllowExtendedTest) goto finish; | 80 if (!reporter->allowExtendedTest()) goto finish; |
92 if (gShowTestProgress) SkDebugf("."); | |
93 } | 81 } |
94 if (gShowTestProgress) SkDebugf("\n%d", a); | |
95 } | 82 } |
96 finish: | 83 finish: |
97 testsRun += waitForCompletion(); | 84 testRunner.render(); |
98 if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun); | |
99 } | 85 } |
100 | 86 |
101 #include "TestClassDef.h" | 87 #include "TestClassDef.h" |
102 DEFINE_TESTCLASS("PathOpsSimplifyDegeneratesThreaded", SimplifyDegeneratesThread
edTestClass, \ | 88 DEFINE_TESTCLASS("PathOpsSimplifyDegeneratesThreaded", SimplifyDegeneratesThread
edTestClass, \ |
103 TestSimplifyDegeneratesThreaded) | 89 TestSimplifyDegeneratesThreaded) |
OLD | NEW |