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 // four rects, of four sizes | 10 // four rects, of four sizes |
10 // for 3 smaller sizes, tall, wide | 11 // for 3 smaller sizes, tall, wide |
11 // top upper mid lower bottom aligned (3 bits, 5 values) | 12 // top upper mid lower bottom aligned (3 bits, 5 values) |
12 // same with x (3 bits, 5 values) | 13 // same with x (3 bits, 5 values) |
13 // not included, square, tall, wide (2 bits) | 14 // not included, square, tall, wide (2 bits) |
14 // cw or ccw (1 bit) | 15 // cw or ccw (1 bit) |
15 | 16 |
16 static THREAD_TYPE testSimplify4x4RectsMain(void* data) | 17 static void testSimplify4x4RectsMain(PathOpsThreadState* data) |
17 { | 18 { |
18 SkASSERT(data); | 19 SkASSERT(data); |
19 State4& state = *(State4*) data; | 20 PathOpsThreadState& state = *data; |
20 char pathStr[1024]; // gdb: set print elements 400 | 21 char pathStr[1024]; // gdb: set print elements 400 |
21 sk_bzero(pathStr, sizeof(pathStr)); | 22 sk_bzero(pathStr, sizeof(pathStr)); |
22 do { | 23 int aShape = state.fA & 0x03; |
23 int aShape = state.a & 0x03; | 24 SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
24 SkPath::Direction aCW = state.a >> 2 ? SkPath::kCCW_Direction : SkPath::
kCW_Direction; | 25 int bShape = state.fB & 0x03; |
25 int bShape = state.b & 0x03; | 26 SkPath::Direction bCW = state.fB >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
26 SkPath::Direction bCW = state.b >> 2 ? SkPath::kCCW_Direction : SkPath::
kCW_Direction; | 27 int cShape = state.fC & 0x03; |
27 int cShape = state.c & 0x03; | 28 SkPath::Direction cCW = state.fC >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
28 SkPath::Direction cCW = state.c >> 2 ? SkPath::kCCW_Direction : SkPath::
kCW_Direction; | 29 int dShape = state.fD & 0x03; |
29 int dShape = state.d & 0x03; | 30 SkPath::Direction dCW = state.fD >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
30 SkPath::Direction dCW = state.d >> 2 ? SkPath::kCCW_Direction : SkPath::
kCW_Direction; | 31 for (int aXAlign = 0; aXAlign < 5; ++aXAlign) { |
31 for (int aXAlign = 0 ; aXAlign < 5; ++aXAlign) { | 32 for (int aYAlign = 0; aYAlign < 5; ++aYAlign) { |
32 for (int aYAlign = 0 ; aYAlign < 5; ++aYAlign) { | 33 for (int bXAlign = 0; bXAlign < 5; ++bXAlign) { |
33 for (int bXAlign = 0 ; bXAlign < 5; ++bXAlign) { | 34 for (int bYAlign = 0; bYAlign < 5; ++bYAlign) { |
34 for (int bYAlign = 0 ; bYAlign < 5; ++bYAlign) { | 35 for (int cXAlign = 0; cXAlign < 5; ++cXAlign) { |
35 for (int cXAlign = 0 ; cXAlign < 5; ++cXAlign) { | 36 for (int cYAlign = 0; cYAlign < 5; ++cYAlign) { |
36 for (int cYAlign = 0 ; cYAlign < 5; ++cYAlign) { | 37 for (int dXAlign = 0; dXAlign < 5; ++dXAlign) { |
37 for (int dXAlign = 0 ; dXAlign < 5; ++dXAlign)
{ | 38 for (int dYAlign = 0; dYAlign < 5; ++dYAlign) { |
38 for (int dYAlign = 0 ; dYAlign < 5; ++dYAlign)
{ | 39 SkPath path, out; |
39 SkPath path, out; | 40 char* str = pathStr; |
40 char* str = pathStr; | 41 path.setFillType(SkPath::kWinding_FillType); |
41 path.setFillType(SkPath::kWinding_FillType); | 42 int l, t, r, b; |
42 int l, t, r, b; | 43 if (aShape) { |
43 if (aShape) { | 44 switch (aShape) { |
44 switch (aShape) { | 45 case 1: // square |
45 case 1: // square | 46 l = 0; r = 60; |
46 l = 0; r = 60; | 47 t = 0; b = 60; |
47 t = 0; b = 60; | 48 aXAlign = 5; |
48 aXAlign = 5; | 49 aYAlign = 5; |
49 aYAlign = 5; | 50 break; |
50 break; | 51 case 2: |
51 case 2: | 52 l = aXAlign * 12; |
52 l = aXAlign * 12; | 53 r = l + 30; |
53 r = l + 30; | 54 t = 0; b = 60; |
54 t = 0; b = 60; | 55 aYAlign = 5; |
55 aYAlign = 5; | 56 break; |
56 break; | 57 case 3: |
57 case 3: | 58 l = 0; r = 60; |
58 l = 0; r = 60; | 59 t = aYAlign * 12; |
59 t = aYAlign * 12; | 60 b = l + 30; |
60 b = l + 30; | 61 aXAlign = 5; |
61 aXAlign = 5; | 62 break; |
62 break; | |
63 } | |
64 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r
), SkIntToScalar(b), | |
65 aCW); | |
66 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | |
67 " SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" :
""); | |
68 } else { | |
69 aXAlign = 5; | |
70 aYAlign = 5; | |
71 } | 63 } |
72 if (bShape) { | 64 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
73 switch (bShape) { | 65 aCW); |
74 case 1: // square | 66 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
75 l = bXAlign * 10; | 67 " SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : ""); |
76 r = l + 20; | 68 } else { |
77 t = bYAlign * 10; | 69 aXAlign = 5; |
78 b = l + 20; | 70 aYAlign = 5; |
79 break; | 71 } |
80 case 2: | 72 if (bShape) { |
81 l = bXAlign * 10; | 73 switch (bShape) { |
82 r = l + 20; | 74 case 1: // square |
83 t = 10; b = 40; | 75 l = bXAlign * 10; |
84 bYAlign = 5; | 76 r = l + 20; |
85 break; | 77 t = bYAlign * 10; |
86 case 3: | 78 b = l + 20; |
87 l = 10; r = 40; | 79 break; |
88 t = bYAlign * 10; | 80 case 2: |
89 b = l + 20; | 81 l = bXAlign * 10; |
90 bXAlign = 5; | 82 r = l + 20; |
91 break; | 83 t = 10; b = 40; |
92 } | 84 bYAlign = 5; |
93 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r
), SkIntToScalar(b), | 85 break; |
94 bCW); | 86 case 3: |
95 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 87 l = 10; r = 40; |
96 " SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" :
""); | 88 t = bYAlign * 10; |
97 } else { | 89 b = l + 20; |
98 bXAlign = 5; | 90 bXAlign = 5; |
99 bYAlign = 5; | 91 break; |
100 } | 92 } |
101 if (cShape) { | 93 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
102 switch (cShape) { | 94 bCW); |
103 case 1: // square | 95 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
104 l = cXAlign * 6; | 96 " SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : ""); |
105 r = l + 12; | 97 } else { |
106 t = cYAlign * 6; | 98 bXAlign = 5; |
107 b = l + 12; | 99 bYAlign = 5; |
108 break; | 100 } |
109 case 2: | 101 if (cShape) { |
110 l = cXAlign * 6; | 102 switch (cShape) { |
111 r = l + 12; | 103 case 1: // square |
112 t = 20; b = 30; | 104 l = cXAlign * 6; |
113 cYAlign = 5; | 105 r = l + 12; |
114 break; | 106 t = cYAlign * 6; |
115 case 3: | 107 b = l + 12; |
116 l = 20; r = 30; | 108 break; |
117 t = cYAlign * 6; | 109 case 2: |
118 b = l + 20; | 110 l = cXAlign * 6; |
119 cXAlign = 5; | 111 r = l + 12; |
120 break; | 112 t = 20; b = 30; |
121 } | 113 cYAlign = 5; |
122 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r
), SkIntToScalar(b), | 114 break; |
123 cCW); | 115 case 3: |
124 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 116 l = 20; r = 30; |
125 " SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" :
""); | 117 t = cYAlign * 6; |
126 } else { | 118 b = l + 20; |
127 cXAlign = 5; | 119 cXAlign = 5; |
128 cYAlign = 5; | 120 break; |
129 } | 121 } |
130 if (dShape) { | 122 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
131 switch (dShape) { | 123 cCW); |
132 case 1: // square | 124 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
133 l = dXAlign * 4; | 125 " SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : ""); |
134 r = l + 9; | 126 } else { |
135 t = dYAlign * 4; | 127 cXAlign = 5; |
136 b = l + 9; | 128 cYAlign = 5; |
137 break; | 129 } |
138 case 2: | 130 if (dShape) { |
139 l = dXAlign * 6; | 131 switch (dShape) { |
140 r = l + 9; | 132 case 1: // square |
141 t = 32; b = 36; | 133 l = dXAlign * 4; |
142 dYAlign = 5; | 134 r = l + 9; |
143 break; | 135 t = dYAlign * 4; |
144 case 3: | 136 b = l + 9; |
145 l = 32; r = 36; | 137 break; |
146 t = dYAlign * 6; | 138 case 2: |
147 b = l + 9; | 139 l = dXAlign * 6; |
148 dXAlign = 5; | 140 r = l + 9; |
149 break; | 141 t = 32; b = 36; |
150 } | 142 dYAlign = 5; |
151 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r
), SkIntToScalar(b), | 143 break; |
152 dCW); | 144 case 3: |
153 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 145 l = 32; r = 36; |
154 " SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" :
""); | 146 t = dYAlign * 6; |
155 } else { | 147 b = l + 9; |
156 dXAlign = 5; | 148 dXAlign = 5; |
157 dYAlign = 5; | 149 break; |
158 } | 150 } |
159 path.close(); | 151 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
160 outputProgress(state, pathStr, SkPath::kWinding_FillType); | 152 dCW); |
161 testSimplify(path, false, out, state, pathStr); | 153 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
162 state.testsRun++; | 154 " SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : ""); |
163 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); | 155 } else { |
164 testSimplify(path, true, out, state, pathStr); | 156 dXAlign = 5; |
165 state.testsRun++; | 157 dYAlign = 5; |
166 } | 158 } |
167 } | 159 path.close(); |
| 160 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType); |
| 161 testSimplify(path, false, out, state, pathStr); |
| 162 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType); |
| 163 testSimplify(path, true, out, state, pathStr); |
| 164 } |
168 } | 165 } |
169 } | 166 } |
170 } | 167 } |
171 } | 168 } |
172 } | 169 } |
173 } | 170 } |
174 } while (runNextTestSet(state)); | 171 } |
175 THREAD_RETURN | |
176 } | 172 } |
177 | 173 |
178 static void TestSimplifyRectsThreaded(skiatest::Reporter* reporter) | 174 static void TestSimplifyRectsThreaded(skiatest::Reporter* reporter) |
179 { | 175 { |
180 int testsRun = 0; | 176 int threadCount = initializeTests("testLine"); |
181 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__); | 177 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
182 #ifdef SK_DEBUG | |
183 gDebugMaxWindSum = 4; | |
184 gDebugMaxWindValue = 4; | |
185 #endif | |
186 const char testLineStr[] = "testLine"; | |
187 initializeTests(reporter, testLineStr, sizeof(testLineStr)); | |
188 for (int a = 0; a < 8; ++a) { // outermost | 178 for (int a = 0; a < 8; ++a) { // outermost |
189 for (int b = a ; b < 8; ++b) { | 179 for (int b = a ; b < 8; ++b) { |
190 for (int c = b ; c < 8; ++c) { | 180 for (int c = b ; c < 8; ++c) { |
191 for (int d = c; d < 8; ++d) { | 181 for (int d = c; d < 8; ++d) { |
192 testsRun += dispatchTest4(testSimplify4x4RectsMain, a, b, c,
d); | 182 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThre
adedRunnable, |
| 183 (&testSimplify4x4RectsMain, a, b, c, d, &testRun
ner)); |
193 } | 184 } |
194 if (!gAllowExtendedTest) goto finish; | 185 if (!reporter->allowExtendedTest()) goto finish; |
195 if (gShowTestProgress) SkDebugf("."); | |
196 } | 186 } |
197 if (gShowTestProgress) SkDebugf("%d", b); | |
198 } | 187 } |
199 if (gShowTestProgress) SkDebugf("\n%d", a); | |
200 } | 188 } |
201 finish: | 189 finish: |
202 testsRun += waitForCompletion(); | 190 testRunner.render(); |
203 if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun); | |
204 } | 191 } |
205 | 192 |
206 #include "TestClassDef.h" | 193 #include "TestClassDef.h" |
207 DEFINE_TESTCLASS("PathOpsSimplifyRectsThreaded",SimplifyRectsThreadedTestClass,
\ | 194 DEFINE_TESTCLASS("PathOpsSimplifyRectsThreaded",SimplifyRectsThreadedTestClass,
\ |
208 TestSimplifyRectsThreaded) | 195 TestSimplifyRectsThreaded) |
OLD | NEW |