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 #include "PathOpsThreadedCommon.h" |
| 9 #include "SkString.h" |
9 | 10 |
10 static void testSimplifyTrianglesMain(PathOpsThreadState* data) { | 11 static void testSimplifyTrianglesMain(PathOpsThreadState* data) { |
11 SkASSERT(data); | 12 SkASSERT(data); |
12 PathOpsThreadState& state = *data; | 13 PathOpsThreadState& state = *data; |
13 char pathStr[1024]; | |
14 bool progress = state.fReporter->verbose(); // FIXME: break out into its own
parameter? | |
15 if (progress) { | |
16 sk_bzero(pathStr, sizeof(pathStr)); | |
17 } | |
18 state.fKey = "?"; | 14 state.fKey = "?"; |
19 int ax = state.fA & 0x03; | 15 int ax = state.fA & 0x03; |
20 int ay = state.fA >> 2; | 16 int ay = state.fA >> 2; |
21 int bx = state.fB & 0x03; | 17 int bx = state.fB & 0x03; |
22 int by = state.fB >> 2; | 18 int by = state.fB >> 2; |
23 int cx = state.fC & 0x03; | 19 int cx = state.fC & 0x03; |
24 int cy = state.fC >> 2; | 20 int cy = state.fC >> 2; |
25 for (int d = 0; d < 15; ++d) { | 21 for (int d = 0; d < 15; ++d) { |
26 int dx = d & 0x03; | 22 int dx = d & 0x03; |
27 int dy = d >> 2; | 23 int dy = d >> 2; |
28 for (int e = d + 1; e < 16; ++e) { | 24 for (int e = d + 1; e < 16; ++e) { |
29 int ex = e & 0x03; | 25 int ex = e & 0x03; |
30 int ey = e >> 2; | 26 int ey = e >> 2; |
31 for (int f = d + 1; f < 16; ++f) { | 27 for (int f = d + 1; f < 16; ++f) { |
32 if (e == f) { | 28 if (e == f) { |
33 continue; | 29 continue; |
34 } | 30 } |
35 int fx = f & 0x03; | 31 int fx = f & 0x03; |
36 int fy = f >> 2; | 32 int fy = f >> 2; |
37 if ((ex - dx) * (fy - dy) == (ey - dy) * (fx - dx)) { | 33 if ((ex - dx) * (fy - dy) == (ey - dy) * (fx - dx)) { |
38 continue; | 34 continue; |
39 } | 35 } |
| 36 SkString pathStr; |
40 SkPath path, out; | 37 SkPath path, out; |
41 path.setFillType(SkPath::kWinding_FillType); | 38 path.setFillType(SkPath::kWinding_FillType); |
42 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | 39 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |
43 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | 40 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); |
44 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | 41 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); |
45 path.close(); | 42 path.close(); |
46 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); | 43 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); |
47 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); | 44 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); |
48 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | 45 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |
49 path.close(); | 46 path.close(); |
50 if (progress) { | 47 if (state.fReporter->verbose()) { |
51 char* str = pathStr; | 48 pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay); |
52 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); | 49 pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by); |
53 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by); | 50 pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy); |
54 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy); | 51 pathStr.appendf(" path.close();\n"); |
55 str += sprintf(str, " path.close();\n"); | 52 pathStr.appendf(" path.moveTo(%d, %d);\n", dx, dy); |
56 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy); | 53 pathStr.appendf(" path.lineTo(%d, %d);\n", ex, ey); |
57 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey); | 54 pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy); |
58 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); | 55 pathStr.appendf(" path.close();\n"); |
59 str += sprintf(str, " path.close();\n"); | 56 outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWin
ding_FillType); |
60 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_Fil
lType); | |
61 } | 57 } |
62 ShowTestName(&state, d, e, f, 0); | 58 ShowTestName(&state, d, e, f, 0); |
63 testSimplify(path, false, out, state, pathStr); | 59 testSimplify(path, false, out, state, pathStr.c_str()); |
64 path.setFillType(SkPath::kEvenOdd_FillType); | 60 path.setFillType(SkPath::kEvenOdd_FillType); |
65 if (progress) { | 61 if (state.fReporter->verbose()) { |
66 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_Fil
lType); | 62 outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEve
nOdd_FillType); |
67 } | 63 } |
68 ShowTestName(&state, d, e, f, 1); | 64 ShowTestName(&state, d, e, f, 1); |
69 testSimplify(path, true, out, state, pathStr); | 65 testSimplify(path, true, out, state, pathStr.c_str()); |
70 } | 66 } |
71 } | 67 } |
72 } | 68 } |
73 } | 69 } |
74 | 70 |
75 DEF_TEST(PathOpsSimplifyTrianglesThreaded, reporter) { | 71 DEF_TEST(PathOpsSimplifyTrianglesThreaded, reporter) { |
76 initializeTests(reporter, "testTriangles"); | 72 initializeTests(reporter, "testTriangles"); |
77 PathOpsThreadedTestRunner testRunner(reporter); | 73 PathOpsThreadedTestRunner testRunner(reporter); |
78 for (int a = 0; a < 15; ++a) { | 74 for (int a = 0; a < 15; ++a) { |
79 int ax = a & 0x03; | 75 int ax = a & 0x03; |
(...skipping 12 matching lines...) Expand all Loading... |
92 } | 88 } |
93 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( | 89 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( |
94 &testSimplifyTrianglesMain, a, b, c, 0, &testRunner); | 90 &testSimplifyTrianglesMain, a, b, c, 0, &testRunner); |
95 } | 91 } |
96 if (!reporter->allowExtendedTest()) goto finish; | 92 if (!reporter->allowExtendedTest()) goto finish; |
97 } | 93 } |
98 } | 94 } |
99 finish: | 95 finish: |
100 testRunner.render(); | 96 testRunner.render(); |
101 } | 97 } |
OLD | NEW |