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 // four rects, of four sizes | 11 // four rects, of four sizes |
11 // for 3 smaller sizes, tall, wide | 12 // for 3 smaller sizes, tall, wide |
12 // top upper mid lower bottom aligned (3 bits, 5 values) | 13 // top upper mid lower bottom aligned (3 bits, 5 values) |
13 // same with x (3 bits, 5 values) | 14 // same with x (3 bits, 5 values) |
14 // not included, square, tall, wide (2 bits) | 15 // not included, square, tall, wide (2 bits) |
15 // cw or ccw (1 bit) | 16 // cw or ccw (1 bit) |
16 | 17 |
18 static int loopNo = 6; | |
scroggo
2016/10/06 14:42:00
nit: gLoopNo
| |
19 | |
17 static void testPathOpsRectsMain(PathOpsThreadState* data) | 20 static void testPathOpsRectsMain(PathOpsThreadState* data) |
18 { | 21 { |
19 SkASSERT(data); | 22 SkASSERT(data); |
20 PathOpsThreadState& state = *data; | 23 PathOpsThreadState& state = *data; |
21 char pathStr[1024]; // gdb: set print elements 400 | 24 SkString pathStr; |
22 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? | |
23 if (progress) { | |
24 sk_bzero(pathStr, sizeof(pathStr)); | |
25 } | |
26 for (int a = 0 ; a < 6; ++a) { | 25 for (int a = 0 ; a < 6; ++a) { |
27 for (int b = a + 1 ; b < 7; ++b) { | 26 for (int b = a + 1 ; b < 7; ++b) { |
28 for (int c = 0 ; c < 6; ++c) { | 27 for (int c = 0 ; c < 6; ++c) { |
29 for (int d = c + 1 ; d < 7; ++d) { | 28 for (int d = c + 1 ; d < 7; ++d) { |
30 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) { | 29 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) { |
31 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) { | 30 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) { |
32 static int testNum = 6; | |
33 if (progress) { | |
34 char* str = pathStr; | |
35 str += sprintf(str, | |
36 "static void rects%d(skiatest::Reporter* reporter, const cha r* filename) {\n", | |
37 testNum); | |
38 str += sprintf(str, " SkPath path, pathB;"); | |
39 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", | |
40 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kE venOdd_FillType | |
41 ? "EvenOdd" : "?UNDEFINED"); | |
42 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | |
43 " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB); | |
44 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | |
45 " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD); | |
46 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n" , | |
47 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kE venOdd_FillType | |
48 ? "EvenOdd" : "?UNDEFINED"); | |
49 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," | |
50 " SkPath::kCW_Direction);\n", a, a, b, b); | |
51 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," | |
52 " SkPath::kCW_Direction);\n", c, c, d, d); | |
53 str += sprintf(str, | |
54 " testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);\n"); | |
55 str += sprintf(str, "}\n\n"); | |
56 } | |
57 SkPath pathA, pathB; | 31 SkPath pathA, pathB; |
58 pathA.setFillType((SkPath::FillType) e); | 32 pathA.setFillType((SkPath::FillType) e); |
59 pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToS calar(state.fB), | 33 pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToS calar(state.fB), |
60 SkIntToScalar(state.fB), SkPath::kCW_Direction); | 34 SkIntToScalar(state.fB), SkPath::kCW_Direction); |
61 pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToS calar(state.fD), | 35 pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToS calar(state.fD), |
62 SkIntToScalar(state.fD), SkPath::kCW_Direction); | 36 SkIntToScalar(state.fD), SkPath::kCW_Direction); |
63 pathA.close(); | 37 pathA.close(); |
64 pathB.setFillType((SkPath::FillType) f); | 38 pathB.setFillType((SkPath::FillType) f); |
65 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), | 39 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), |
66 SkIntToScalar(b), SkPath::kCW_Direction); | 40 SkIntToScalar(b), SkPath::kCW_Direction); |
67 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), | 41 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), |
68 SkIntToScalar(d), SkPath::kCW_Direction); | 42 SkIntToScalar(d), SkPath::kCW_Direction); |
69 pathB.close(); | 43 pathB.close(); |
70 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { | 44 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
71 if (progress) { | 45 if (state.fReporter->verbose()) { |
72 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); | 46 pathStr.printf( |
47 "static void rects%d(skiatest::Reporter* reporter," | |
48 "const char* filename) {\n", loopNo); | |
49 pathStr.appendf(" SkPath path, pathB;"); | |
50 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", | |
51 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath ::kEvenOdd_FillType | |
52 ? "EvenOdd" : "?UNDEFINED"); | |
53 pathStr.appendf(" path.addRect(%d, %d, %d, %d," | |
54 " SkPath::kCW_Direction);\n", state.fA, state.fA, state. fB, state.fB); | |
55 pathStr.appendf(" path.addRect(%d, %d, %d, %d," | |
56 " SkPath::kCW_Direction);\n", state.fC, state.fC, state. fD, state.fD); | |
57 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n" , | |
58 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath ::kEvenOdd_FillType | |
59 ? "EvenOdd" : "?UNDEFINED"); | |
60 pathStr.appendf(" pathB.addRect(%d, %d, %d, %d," | |
61 " SkPath::kCW_Direction);\n", a, a, b, b); | |
62 pathStr.appendf(" pathB.addRect(%d, %d, %d, %d," | |
63 " SkPath::kCW_Direction);\n", c, c, d, d); | |
64 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filen ame);\n", | |
65 SkPathOpsDebug::OpStr((SkPathOp) op)); | |
66 pathStr.appendf("}\n\n"); | |
67 outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op); | |
73 } | 68 } |
74 testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects"); | 69 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects ")) { |
70 if (state.fReporter->verbose()) { | |
71 ++loopNo; | |
72 goto skipToNext; | |
73 } | |
74 } | |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 skipToNext: ; | |
78 } | 79 } |
79 } | 80 } |
80 } | 81 } |
81 } | 82 } |
82 } | 83 } |
83 | 84 |
84 DEF_TEST(PathOpsRectsThreaded, reporter) { | 85 DEF_TEST(PathOpsRectsThreaded, reporter) { |
85 initializeTests(reporter, "testOp"); | 86 initializeTests(reporter, "testOp"); |
86 PathOpsThreadedTestRunner testRunner(reporter); | 87 PathOpsThreadedTestRunner testRunner(reporter); |
87 for (int a = 0; a < 6; ++a) { // outermost | 88 for (int a = 0; a < 6; ++a) { // outermost |
88 for (int b = a + 1; b < 7; ++b) { | 89 for (int b = a + 1; b < 7; ++b) { |
89 for (int c = 0 ; c < 6; ++c) { | 90 for (int c = 0 ; c < 6; ++c) { |
90 for (int d = c + 1; d < 7; ++d) { | 91 for (int d = c + 1; d < 7; ++d) { |
91 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( | 92 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( |
92 &testPathOpsRectsMain, a, b, c, d, &testRunner); | 93 &testPathOpsRectsMain, a, b, c, d, &testRunner); |
93 } | 94 } |
94 } | 95 } |
95 if (!reporter->allowExtendedTest()) goto finish; | 96 if (!reporter->allowExtendedTest()) goto finish; |
96 } | 97 } |
97 } | 98 } |
98 finish: | 99 finish: |
99 testRunner.render(); | 100 testRunner.render(); |
100 } | 101 } |
OLD | NEW |