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 int loopNo = 158; | 11 static int loopNo = 158; |
11 | 12 |
12 static void testOpCubicsMain(PathOpsThreadState* data) { | 13 static void testOpCubicsMain(PathOpsThreadState* data) { |
13 #if DEBUG_SHOW_TEST_NAME | 14 #if DEBUG_SHOW_TEST_NAME |
14 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); | 15 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); |
15 #endif | 16 #endif |
16 SkASSERT(data); | 17 SkASSERT(data); |
17 PathOpsThreadState& state = *data; | 18 PathOpsThreadState& state = *data; |
18 char pathStr[1024]; | 19 SkString pathStr; |
19 bool progress = state.fReporter->verbose(); // FIXME: break out into its own
parameter? | |
20 if (progress) { | |
21 sk_bzero(pathStr, sizeof(pathStr)); | |
22 } | |
23 for (int a = 0 ; a < 6; ++a) { | 20 for (int a = 0 ; a < 6; ++a) { |
24 for (int b = a + 1 ; b < 7; ++b) { | 21 for (int b = a + 1 ; b < 7; ++b) { |
25 for (int c = 0 ; c < 6; ++c) { | 22 for (int c = 0 ; c < 6; ++c) { |
26 for (int d = c + 1 ; d < 7; ++d) { | 23 for (int d = c + 1 ; d < 7; ++d) { |
27 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO
dd_FillType; ++e) { | 24 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO
dd_FillType; ++e) { |
28 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f
) { | 25 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f
) { |
29 SkPath pathA, pathB; | 26 SkPath pathA, pathB; |
30 pathA.setFillType((SkPath::FillType) e); | 27 pathA.setFillType((SkPath::FillType) e); |
31 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB)); | 28 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB)); |
32 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToS
calar(b), | 29 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToS
calar(b), |
33 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c)); | 30 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c)); |
34 pathA.close(); | 31 pathA.close(); |
35 pathB.setFillType((SkPath::FillType) f); | 32 pathB.setFillType((SkPath::FillType) f); |
36 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b)); | 33 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b)); |
37 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB
), | 34 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB
), |
38 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(
state.fC)); | 35 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(
state.fC)); |
39 pathB.close(); | 36 pathB.close(); |
40 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { | 37 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
41 if (progress) { | 38 if (state.fReporter->verbose()) { |
42 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); | 39 pathStr.printf("static void cubicOp%d(skiatest::Reporter* report
er," |
43 } | |
44 if (progress) { | |
45 char* str = pathStr; | |
46 str += sprintf(str, "static void cubicOp%d(skiatest::Reporter* r
eporter," | |
47 " const char* filename) {\n", loopNo); | 40 " const char* filename) {\n", loopNo); |
48 str += sprintf(str, " SkPath path, pathB;\n"); | 41 pathStr.appendf(" SkPath path, pathB;\n"); |
49 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);
\n", | 42 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", |
50 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath
::kEvenOdd_FillType | 43 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath
::kEvenOdd_FillType |
51 ? "EvenOdd" : "?UNDEFINED"); | 44 ? "EvenOdd" : "?UNDEFINED"); |
52 str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state
.fB); | 45 pathStr.appendf(" path.moveTo(%d,%d);\n", state.fA, state.fB)
; |
53 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n",
state.fC, state.fD, | 46 pathStr.appendf(" path.cubicTo(%d,%d, %d,%d, %d,%d);\n", stat
e.fC, state.fD, |
54 b, a, d, c); | 47 b, a, d, c); |
55 str += sprintf(str, " path.close();\n"); | 48 pathStr.appendf(" path.close();\n"); |
56 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType)
;\n", | 49 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n"
, |
57 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath
::kEvenOdd_FillType | 50 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath
::kEvenOdd_FillType |
58 ? "EvenOdd" : "?UNDEFINED"); | 51 ? "EvenOdd" : "?UNDEFINED"); |
59 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b); | 52 pathStr.appendf(" pathB.moveTo(%d,%d);\n", a, b); |
60 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n",
c, d, | 53 pathStr.appendf(" pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c,
d, |
61 state.fB, state.fA, state.fD, state.fC); | 54 state.fB, state.fA, state.fD, state.fC); |
62 str += sprintf(str, " pathB.close();\n"); | 55 pathStr.appendf(" pathB.close();\n"); |
63 str += sprintf(str, " testPathOp(reporter, path, pathB, %s, f
ilename);\n", | 56 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filen
ame);\n", |
64 SkPathOpsDebug::OpStr((SkPathOp) op)); | 57 SkPathOpsDebug::OpStr((SkPathOp) op)); |
65 str += sprintf(str, "}\n"); | 58 pathStr.appendf("}\n"); |
| 59 outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op); |
66 } | 60 } |
67 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubic
s")) { | 61 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubic
s")) { |
68 if (progress) { | 62 if (state.fReporter->verbose()) { |
69 ++loopNo; | 63 ++loopNo; |
70 goto skipToNext; | 64 goto skipToNext; |
71 } | 65 } |
72 } | 66 } |
73 } | 67 } |
74 } | 68 } |
75 } | 69 } |
76 skipToNext: ; | 70 skipToNext: ; |
77 } | 71 } |
78 } | 72 } |
(...skipping 11 matching lines...) Expand all Loading... |
90 *testRunner.fRunnables.append() = | 84 *testRunner.fRunnables.append() = |
91 new PathOpsThreadedRunnable(&testOpCubicsMain, a, b,
c, d, &testRunner); | 85 new PathOpsThreadedRunnable(&testOpCubicsMain, a, b,
c, d, &testRunner); |
92 } | 86 } |
93 } | 87 } |
94 if (!reporter->allowExtendedTest()) goto finish; | 88 if (!reporter->allowExtendedTest()) goto finish; |
95 } | 89 } |
96 } | 90 } |
97 finish: | 91 finish: |
98 testRunner.render(); | 92 testRunner.render(); |
99 } | 93 } |
OLD | NEW |