OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2015 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 | 9 |
10 static void testOpCubicsMain(PathOpsThreadState* data) { | 10 static void testOpCirclesMain(PathOpsThreadState* data) { |
11 #if DEBUG_SHOW_TEST_NAME | 11 SkASSERT(data); |
12 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); | |
13 #endif | |
14 SkASSERT(data); | |
15 PathOpsThreadState& state = *data; | 12 PathOpsThreadState& state = *data; |
16 char pathStr[1024]; // gdb: set print elements 400 | 13 char pathStr[1024]; |
17 bool progress = state.fReporter->verbose(); // FIXME: break out into its own
parameter? | 14 bool progress = state.fReporter->verbose(); // FIXME: break out into its own
parameter? |
18 if (progress) { | 15 if (progress) { |
19 sk_bzero(pathStr, sizeof(pathStr)); | 16 sk_bzero(pathStr, sizeof(pathStr)); |
20 } | 17 } |
| 18 |
21 for (int a = 0 ; a < 6; ++a) { | 19 for (int a = 0 ; a < 6; ++a) { |
22 for (int b = a + 1 ; b < 7; ++b) { | 20 for (int b = a + 1 ; b < 7; ++b) { |
23 for (int c = 0 ; c < 6; ++c) { | 21 for (int c = 0 ; c < 6; ++c) { |
24 for (int d = c + 1 ; d < 7; ++d) { | 22 for (int d = c + 1 ; d < 7; ++d) { |
25 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO
dd_FillType; ++e) { | 23 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO
dd_FillType; ++e) { |
26 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f
) { | 24 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f
) { |
27 SkPath pathA, pathB; | 25 SkPath pathA, pathB; |
28 if (progress) { | 26 if (progress) { |
29 char* str = pathStr; | 27 char* str = pathStr; |
30 const int loopNo = 129; | 28 const int loopNo = 4; |
31 str += sprintf(str, "static void cubicOp%d(skiatest::Reporter* repor
ter," | 29 str += sprintf(str, "static void circlesOp%d(skiatest::Reporter* rep
orter," |
32 " const char* filename) {\n", loopNo); | 30 " const char* filename) {\n", loopNo); |
33 str += sprintf(str, " SkPath path, pathB;\n"); | 31 str += sprintf(str, " SkPath path, pathB;\n"); |
34 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", | 32 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", |
35 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kE
venOdd_FillType | 33 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kE
venOdd_FillType |
36 ? "EvenOdd" : "?UNDEFINED"); | 34 ? "EvenOdd" : "?UNDEFINED"); |
37 str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB)
; | 35 str += sprintf(str, " path.addCircle(%d, %d, %d, %s);\n", state.f
A, state.fB, |
38 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", stat
e.fC, state.fD, | 36 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW
_Direction"); |
39 b, a, d, c); | |
40 str += sprintf(str, " path.close();\n"); | |
41 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n"
, | 37 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n"
, |
42 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kE
venOdd_FillType | 38 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kE
venOdd_FillType |
43 ? "EvenOdd" : "?UNDEFINED"); | 39 ? "EvenOdd" : "?UNDEFINED"); |
44 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b); | 40 str += sprintf(str, " pathB.addCircle(%d, %d, %d, %s);\n", a, b, |
45 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c,
d, | 41 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); |
46 state.fB, state.fA, state.fD, state.fC); | |
47 str += sprintf(str, " pathB.close();\n"); | |
48 str += sprintf(str, " testPathOp(reporter, path, pathB, kDifferen
ce_SkPathOp," | 42 str += sprintf(str, " testPathOp(reporter, path, pathB, kDifferen
ce_SkPathOp," |
49 " filename);\n"); | 43 " filename);\n"); |
50 str += sprintf(str, "}\n"); | 44 str += sprintf(str, "}\n"); |
51 } | 45 } |
52 pathA.setFillType((SkPath::FillType) e); | 46 pathA.setFillType((SkPath::FillType) e); |
53 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB)); | 47 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntT
oScalar(state.fC), |
54 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToS
calar(b), | 48 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
55 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c)); | |
56 pathA.close(); | |
57 pathB.setFillType((SkPath::FillType) f); | 49 pathB.setFillType((SkPath::FillType) f); |
58 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b)); | 50 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c), |
59 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB
), | 51 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
60 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(
state.fC)); | |
61 pathB.close(); | |
62 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { | 52 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
63 if (progress) { | 53 if (progress) { |
64 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); | 54 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); |
65 } | 55 } |
66 testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cu
bics"); | 56 testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "ci
rcles"); |
67 } | 57 } |
68 } | 58 } |
69 } | 59 } |
70 } | 60 } |
71 } | 61 } |
72 } | 62 } |
73 } | 63 } |
74 } | 64 } |
75 | 65 |
76 DEF_TEST(PathOpsOpCubicsThreaded, reporter) { | 66 DEF_TEST(PathOpsOpCircleThreaded, reporter) { |
77 initializeTests(reporter, "cubicOp"); | 67 initializeTests(reporter, "circleOp"); |
78 PathOpsThreadedTestRunner testRunner(reporter); | 68 PathOpsThreadedTestRunner testRunner(reporter); |
79 for (int a = 0; a < 6; ++a) { // outermost | 69 for (int a = 0; a < 6; ++a) { // outermost |
80 for (int b = a + 1; b < 7; ++b) { | 70 for (int b = a + 1; b < 7; ++b) { |
81 for (int c = 0 ; c < 6; ++c) { | 71 for (int c = 0 ; c < 6; ++c) { |
82 for (int d = c + 1; d < 7; ++d) { | 72 for (int d = 0; d < 2; ++d) { |
83 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded
Runnable, | 73 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded
Runnable, |
84 (&testOpCubicsMain, a, b, c, d, &testRunner)); | 74 (&testOpCirclesMain, a, b, c, d, &testRunner)); |
85 } | 75 } |
86 } | 76 } |
87 if (!reporter->allowExtendedTest()) goto finish; | 77 if (!reporter->allowExtendedTest()) goto finish; |
88 } | 78 } |
89 } | 79 } |
90 finish: | 80 finish: |
91 testRunner.render(); | 81 testRunner.render(); |
92 ShowTestArray(); | 82 ShowTestArray("circleOp"); |
93 } | 83 } |
OLD | NEW |