OLD | NEW |
1 #include "PathOpsCubicIntersectionTestData.h" | 1 #include "PathOpsCubicIntersectionTestData.h" |
2 #include "PathOpsQuadIntersectionTestData.h" | 2 #include "PathOpsQuadIntersectionTestData.h" |
3 #include "SkCommonFlags.h" | 3 #include "SkCommonFlags.h" |
4 #include "SkPaint.h" | 4 #include "SkPaint.h" |
5 #include "SkPath.h" | 5 #include "SkPath.h" |
6 #include "SkRandom.h" | 6 #include "SkRandom.h" |
7 #include "SkStrokerPriv.h" | 7 #include "SkStrokerPriv.h" |
8 #include "SkTime.h" | 8 #include "SkTime.h" |
9 #include "Test.h" | 9 #include "Test.h" |
10 | 10 |
11 #ifndef SK_BUILD_FOR_IOS | 11 DEFINE_bool(timeout, true, "run until alloted time expires"); |
12 DEFINE_bool2(extendedTest, x, false, "run extended tests regardless of how long
takes"); | |
13 #else | |
14 DECLARE_bool(extendedTest); | |
15 #endif | |
16 | 12 |
17 #define MS_TEST_DURATION 10 | 13 #define MS_TEST_DURATION 10 |
18 | 14 |
19 const SkScalar widths[] = {-FLT_MAX, -1, -0.1f, -FLT_EPSILON, 0, FLT_EPSILON, | 15 const SkScalar widths[] = {-FLT_MAX, -1, -0.1f, -FLT_EPSILON, 0, FLT_EPSILON, |
20 0.0000001f, 0.000001f, 0.00001f, 0.0001f, 0.001f, 0.01f, | 16 0.0000001f, 0.000001f, 0.00001f, 0.0001f, 0.001f, 0.01f, |
21 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 1, 1.1f, 2, 10, 10e2f, 10e3f, 10e4f, 10e5f
, 10e6f, 10e7f, | 17 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 1, 1.1f, 2, 10, 10e2f, 10e3f, 10e4f, 10e5f
, 10e6f, 10e7f, |
22 10e8f, 10e9f, 10e10f, 10e20f, FLT_MAX }; | 18 10e8f, 10e9f, 10e10f, 10e20f, FLT_MAX }; |
23 size_t widths_count = SK_ARRAY_COUNT(widths); | 19 size_t widths_count = SK_ARRAY_COUNT(widths); |
24 | 20 |
25 static void pathTest(const SkPath& path) { | 21 static void pathTest(const SkPath& path) { |
(...skipping 20 matching lines...) Expand all Loading... |
46 pathTest(path); | 42 pathTest(path); |
47 } | 43 } |
48 | 44 |
49 static void cubicSetTest(const SkDCubic* dCubic, size_t count) { | 45 static void cubicSetTest(const SkDCubic* dCubic, size_t count) { |
50 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 46 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
51 for (size_t index = 0; index < count; ++index) { | 47 for (size_t index = 0; index < count; ++index) { |
52 const SkDCubic& d = dCubic[index]; | 48 const SkDCubic& d = dCubic[index]; |
53 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[
1].fX, (float) d[1].fY}, | 49 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[
1].fX, (float) d[1].fY}, |
54 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, (
float) d[3].fY} }; | 50 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, (
float) d[3].fY} }; |
55 cubicTest(c); | 51 cubicTest(c); |
56 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 52 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
57 return; | 53 return; |
58 } | 54 } |
59 } | 55 } |
60 } | 56 } |
61 | 57 |
62 static void cubicPairSetTest(const SkDCubic dCubic[][2], size_t count) { | 58 static void cubicPairSetTest(const SkDCubic dCubic[][2], size_t count) { |
63 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 59 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
64 for (size_t index = 0; index < count; ++index) { | 60 for (size_t index = 0; index < count; ++index) { |
65 for (int pair = 0; pair < 2; ++pair) { | 61 for (int pair = 0; pair < 2; ++pair) { |
66 const SkDCubic& d = dCubic[index][pair]; | 62 const SkDCubic& d = dCubic[index][pair]; |
67 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(f
loat) d[1].fX, (float) d[1].fY}, | 63 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(f
loat) d[1].fX, (float) d[1].fY}, |
68 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].f
X, (float) d[3].fY} }; | 64 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].f
X, (float) d[3].fY} }; |
69 cubicTest(c); | 65 cubicTest(c); |
70 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 66 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
71 return; | 67 return; |
72 } | 68 } |
73 } | 69 } |
74 } | 70 } |
75 } | 71 } |
76 | 72 |
77 static void quadSetTest(const SkDQuad* dQuad, size_t count) { | 73 static void quadSetTest(const SkDQuad* dQuad, size_t count) { |
78 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 74 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
79 for (size_t index = 0; index < count; ++index) { | 75 for (size_t index = 0; index < count; ++index) { |
80 const SkDQuad& d = dQuad[index]; | 76 const SkDQuad& d = dQuad[index]; |
81 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[
1].fX, (float) d[1].fY}, | 77 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[
1].fX, (float) d[1].fY}, |
82 {(float) d[2].fX, (float) d[2].fY} }; | 78 {(float) d[2].fX, (float) d[2].fY} }; |
83 quadTest(c); | 79 quadTest(c); |
84 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 80 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
85 return; | 81 return; |
86 } | 82 } |
87 } | 83 } |
88 } | 84 } |
89 | 85 |
90 static void quadPairSetTest(const SkDQuad dQuad[][2], size_t count) { | 86 static void quadPairSetTest(const SkDQuad dQuad[][2], size_t count) { |
91 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 87 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
92 for (size_t index = 0; index < count; ++index) { | 88 for (size_t index = 0; index < count; ++index) { |
93 for (int pair = 0; pair < 2; ++pair) { | 89 for (int pair = 0; pair < 2; ++pair) { |
94 const SkDQuad& d = dQuad[index][pair]; | 90 const SkDQuad& d = dQuad[index][pair]; |
95 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(f
loat) d[1].fX, (float) d[1].fY}, | 91 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(f
loat) d[1].fX, (float) d[1].fY}, |
96 {(float) d[2].fX, (float) d[2].fY} }; | 92 {(float) d[2].fX, (float) d[2].fY} }; |
97 quadTest(c); | 93 quadTest(c); |
98 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 94 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
99 return; | 95 return; |
100 } | 96 } |
101 } | 97 } |
102 } | 98 } |
103 } | 99 } |
104 | 100 |
105 DEF_TEST(QuadStrokerSet, reporter) { | 101 DEF_TEST(QuadStrokerSet, reporter) { |
106 quadSetTest(quadraticLines, quadraticLines_count); | 102 quadSetTest(quadraticLines, quadraticLines_count); |
107 quadSetTest(quadraticPoints, quadraticPoints_count); | 103 quadSetTest(quadraticPoints, quadraticPoints_count); |
108 quadSetTest(quadraticModEpsilonLines, quadraticModEpsilonLines_count); | 104 quadSetTest(quadraticModEpsilonLines, quadraticModEpsilonLines_count); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 #endif | 136 #endif |
141 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 137 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
142 for (int i = 0; i < 1000000; ++i) { | 138 for (int i = 0; i < 1000000; ++i) { |
143 SkPath path, fill; | 139 SkPath path, fill; |
144 path.moveTo(unbounded(r), unbounded(r)); | 140 path.moveTo(unbounded(r), unbounded(r)); |
145 path.quadTo(unbounded(r), unbounded(r), unbounded(r), unbounded(r)); | 141 path.quadTo(unbounded(r), unbounded(r), unbounded(r), unbounded(r)); |
146 p.setStrokeWidth(unboundedPos(r)); | 142 p.setStrokeWidth(unboundedPos(r)); |
147 p.getFillPath(path, &fill); | 143 p.getFillPath(path, &fill); |
148 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 144 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
149 if (best < gMaxRecursion[2]) { | 145 if (best < gMaxRecursion[2]) { |
150 if (FLAGS_verbose) { | 146 if (FLAGS_veryVerbose) { |
151 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursi
on[2], | 147 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursi
on[2], |
152 p.getStrokeWidth()); | 148 p.getStrokeWidth()); |
153 path.dumpHex(); | 149 path.dumpHex(); |
154 SkDebugf("fill:\n"); | 150 SkDebugf("fill:\n"); |
155 fill.dumpHex(); | 151 fill.dumpHex(); |
156 } | 152 } |
157 best = gMaxRecursion[2]; | 153 best = gMaxRecursion[2]; |
158 } | 154 } |
159 #endif | 155 #endif |
160 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 156 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
161 return; | 157 return; |
162 } | 158 } |
163 } | 159 } |
164 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 160 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
165 if (FLAGS_verbose) { | 161 if (FLAGS_veryVerbose) { |
166 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); | 162 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); |
167 } | 163 } |
168 #endif | 164 #endif |
169 } | 165 } |
170 | 166 |
171 DEF_TEST(CubicStrokerUnbounded, reporter) { | 167 DEF_TEST(CubicStrokerUnbounded, reporter) { |
172 SkLCGRandom r; | 168 SkLCGRandom r; |
173 SkPaint p; | 169 SkPaint p; |
174 p.setStyle(SkPaint::kStroke_Style); | 170 p.setStyle(SkPaint::kStroke_Style); |
175 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 171 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
176 int bestTan = 0; | 172 int bestTan = 0; |
177 int bestCubic = 0; | 173 int bestCubic = 0; |
178 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); | 174 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); |
179 #endif | 175 #endif |
180 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 176 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
181 for (int i = 0; i < 1000000; ++i) { | 177 for (int i = 0; i < 1000000; ++i) { |
182 SkPath path, fill; | 178 SkPath path, fill; |
183 path.moveTo(unbounded(r), unbounded(r)); | 179 path.moveTo(unbounded(r), unbounded(r)); |
184 path.cubicTo(unbounded(r), unbounded(r), unbounded(r), unbounded(r), | 180 path.cubicTo(unbounded(r), unbounded(r), unbounded(r), unbounded(r), |
185 unbounded(r), unbounded(r)); | 181 unbounded(r), unbounded(r)); |
186 p.setStrokeWidth(unboundedPos(r)); | 182 p.setStrokeWidth(unboundedPos(r)); |
187 p.getFillPath(path, &fill); | 183 p.getFillPath(path, &fill); |
188 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 184 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
189 if (bestTan < gMaxRecursion[0] || bestCubic < gMaxRecursion[1]) { | 185 if (bestTan < gMaxRecursion[0] || bestCubic < gMaxRecursion[1]) { |
190 if (FLAGS_verbose) { | 186 if (FLAGS_veryVerbose) { |
191 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMa
xRecursion[0], | 187 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMa
xRecursion[0], |
192 gMaxRecursion[1], p.getStrokeWidth()); | 188 gMaxRecursion[1], p.getStrokeWidth()); |
193 path.dumpHex(); | 189 path.dumpHex(); |
194 SkDebugf("fill:\n"); | 190 SkDebugf("fill:\n"); |
195 fill.dumpHex(); | 191 fill.dumpHex(); |
196 } | 192 } |
197 bestTan = SkTMax(bestTan, gMaxRecursion[0]); | 193 bestTan = SkTMax(bestTan, gMaxRecursion[0]); |
198 bestCubic = SkTMax(bestCubic, gMaxRecursion[1]); | 194 bestCubic = SkTMax(bestCubic, gMaxRecursion[1]); |
199 } | 195 } |
200 #endif | 196 #endif |
201 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 197 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
202 return; | 198 return; |
203 } | 199 } |
204 } | 200 } |
205 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 201 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
206 if (FLAGS_verbose) { | 202 if (FLAGS_veryVerbose) { |
207 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic)
; | 203 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic)
; |
208 } | 204 } |
209 #endif | 205 #endif |
210 } | 206 } |
211 | 207 |
212 DEF_TEST(QuadStrokerConstrained, reporter) { | 208 DEF_TEST(QuadStrokerConstrained, reporter) { |
213 SkLCGRandom r; | 209 SkLCGRandom r; |
214 SkPaint p; | 210 SkPaint p; |
215 p.setStyle(SkPaint::kStroke_Style); | 211 p.setStyle(SkPaint::kStroke_Style); |
216 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 212 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
(...skipping 15 matching lines...) Expand all Loading... |
232 quad[2].fX = r.nextRangeF(0, 500); | 228 quad[2].fX = r.nextRangeF(0, 500); |
233 quad[2].fY = r.nextRangeF(0, 500); | 229 quad[2].fY = r.nextRangeF(0, 500); |
234 } while (quad[0].distanceToSqd(quad[2]) < halfSquared | 230 } while (quad[0].distanceToSqd(quad[2]) < halfSquared |
235 || quad[1].distanceToSqd(quad[2]) < halfSquared); | 231 || quad[1].distanceToSqd(quad[2]) < halfSquared); |
236 path.moveTo(quad[0].fX, quad[0].fY); | 232 path.moveTo(quad[0].fX, quad[0].fY); |
237 path.quadTo(quad[1].fX, quad[1].fY, quad[2].fX, quad[2].fY); | 233 path.quadTo(quad[1].fX, quad[1].fY, quad[2].fX, quad[2].fY); |
238 p.setStrokeWidth(r.nextRangeF(0, 500)); | 234 p.setStrokeWidth(r.nextRangeF(0, 500)); |
239 p.getFillPath(path, &fill); | 235 p.getFillPath(path, &fill); |
240 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 236 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
241 if (best < gMaxRecursion[2]) { | 237 if (best < gMaxRecursion[2]) { |
242 if (FLAGS_verbose) { | 238 if (FLAGS_veryVerbose) { |
243 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursi
on[2], | 239 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursi
on[2], |
244 p.getStrokeWidth()); | 240 p.getStrokeWidth()); |
245 path.dumpHex(); | 241 path.dumpHex(); |
246 SkDebugf("fill:\n"); | 242 SkDebugf("fill:\n"); |
247 fill.dumpHex(); | 243 fill.dumpHex(); |
248 } | 244 } |
249 best = gMaxRecursion[2]; | 245 best = gMaxRecursion[2]; |
250 } | 246 } |
251 #endif | 247 #endif |
252 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 248 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
253 return; | 249 return; |
254 } | 250 } |
255 } | 251 } |
256 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 252 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
257 if (FLAGS_verbose) { | 253 if (FLAGS_veryVerbose) { |
258 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); | 254 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); |
259 } | 255 } |
260 #endif | 256 #endif |
261 } | 257 } |
262 | 258 |
263 DEF_TEST(CubicStrokerConstrained, reporter) { | 259 DEF_TEST(CubicStrokerConstrained, reporter) { |
264 SkLCGRandom r; | 260 SkLCGRandom r; |
265 SkPaint p; | 261 SkPaint p; |
266 p.setStyle(SkPaint::kStroke_Style); | 262 p.setStyle(SkPaint::kStroke_Style); |
267 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 263 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
(...skipping 22 matching lines...) Expand all Loading... |
290 cubic[3].fY = r.nextRangeF(0, 500); | 286 cubic[3].fY = r.nextRangeF(0, 500); |
291 } while ( cubic[0].distanceToSqd(cubic[3]) < halfSquared | 287 } while ( cubic[0].distanceToSqd(cubic[3]) < halfSquared |
292 || cubic[1].distanceToSqd(cubic[3]) < halfSquared | 288 || cubic[1].distanceToSqd(cubic[3]) < halfSquared |
293 || cubic[2].distanceToSqd(cubic[3]) < halfSquared); | 289 || cubic[2].distanceToSqd(cubic[3]) < halfSquared); |
294 path.moveTo(cubic[0].fX, cubic[0].fY); | 290 path.moveTo(cubic[0].fX, cubic[0].fY); |
295 path.cubicTo(cubic[1].fX, cubic[1].fY, cubic[2].fX, cubic[2].fY, cubic[3
].fX, cubic[3].fY); | 291 path.cubicTo(cubic[1].fX, cubic[1].fY, cubic[2].fX, cubic[2].fY, cubic[3
].fX, cubic[3].fY); |
296 p.setStrokeWidth(r.nextRangeF(0, 500)); | 292 p.setStrokeWidth(r.nextRangeF(0, 500)); |
297 p.getFillPath(path, &fill); | 293 p.getFillPath(path, &fill); |
298 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 294 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
299 if (bestTan < gMaxRecursion[0] || bestCubic < gMaxRecursion[1]) { | 295 if (bestTan < gMaxRecursion[0] || bestCubic < gMaxRecursion[1]) { |
300 if (FLAGS_verbose) { | 296 if (FLAGS_veryVerbose) { |
301 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMa
xRecursion[0], | 297 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMa
xRecursion[0], |
302 gMaxRecursion[1], p.getStrokeWidth()); | 298 gMaxRecursion[1], p.getStrokeWidth()); |
303 path.dumpHex(); | 299 path.dumpHex(); |
304 SkDebugf("fill:\n"); | 300 SkDebugf("fill:\n"); |
305 fill.dumpHex(); | 301 fill.dumpHex(); |
306 } | 302 } |
307 bestTan = SkTMax(bestTan, gMaxRecursion[0]); | 303 bestTan = SkTMax(bestTan, gMaxRecursion[0]); |
308 bestCubic = SkTMax(bestCubic, gMaxRecursion[1]); | 304 bestCubic = SkTMax(bestCubic, gMaxRecursion[1]); |
309 } | 305 } |
310 #endif | 306 #endif |
311 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 307 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
312 return; | 308 return; |
313 } | 309 } |
314 } | 310 } |
315 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 311 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
316 if (FLAGS_verbose) { | 312 if (FLAGS_veryVerbose) { |
317 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic)
; | 313 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic)
; |
318 } | 314 } |
319 #endif | 315 #endif |
320 } | 316 } |
321 | 317 |
322 DEF_TEST(QuadStrokerRange, reporter) { | 318 DEF_TEST(QuadStrokerRange, reporter) { |
323 SkLCGRandom r; | 319 SkLCGRandom r; |
324 SkPaint p; | 320 SkPaint p; |
325 p.setStyle(SkPaint::kStroke_Style); | 321 p.setStyle(SkPaint::kStroke_Style); |
326 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 322 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
327 int best = 0; | 323 int best = 0; |
328 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); | 324 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); |
329 #endif | 325 #endif |
330 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 326 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
331 for (int i = 0; i < 1000000; ++i) { | 327 for (int i = 0; i < 1000000; ++i) { |
332 SkPath path, fill; | 328 SkPath path, fill; |
333 SkPoint quad[3]; | 329 SkPoint quad[3]; |
334 quad[0].fX = r.nextRangeF(0, 500); | 330 quad[0].fX = r.nextRangeF(0, 500); |
335 quad[0].fY = r.nextRangeF(0, 500); | 331 quad[0].fY = r.nextRangeF(0, 500); |
336 quad[1].fX = r.nextRangeF(0, 500); | 332 quad[1].fX = r.nextRangeF(0, 500); |
337 quad[1].fY = r.nextRangeF(0, 500); | 333 quad[1].fY = r.nextRangeF(0, 500); |
338 quad[2].fX = r.nextRangeF(0, 500); | 334 quad[2].fX = r.nextRangeF(0, 500); |
339 quad[2].fY = r.nextRangeF(0, 500); | 335 quad[2].fY = r.nextRangeF(0, 500); |
340 path.moveTo(quad[0].fX, quad[0].fY); | 336 path.moveTo(quad[0].fX, quad[0].fY); |
341 path.quadTo(quad[1].fX, quad[1].fY, quad[2].fX, quad[2].fY); | 337 path.quadTo(quad[1].fX, quad[1].fY, quad[2].fX, quad[2].fY); |
342 p.setStrokeWidth(r.nextRangeF(0, 500)); | 338 p.setStrokeWidth(r.nextRangeF(0, 500)); |
343 p.getFillPath(path, &fill); | 339 p.getFillPath(path, &fill); |
344 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 340 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
345 if (best < gMaxRecursion[2]) { | 341 if (best < gMaxRecursion[2]) { |
346 if (FLAGS_verbose) { | 342 if (FLAGS_veryVerbose) { |
347 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursi
on[2], | 343 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursi
on[2], |
348 p.getStrokeWidth()); | 344 p.getStrokeWidth()); |
349 path.dumpHex(); | 345 path.dumpHex(); |
350 SkDebugf("fill:\n"); | 346 SkDebugf("fill:\n"); |
351 fill.dumpHex(); | 347 fill.dumpHex(); |
352 } | 348 } |
353 best = gMaxRecursion[2]; | 349 best = gMaxRecursion[2]; |
354 } | 350 } |
355 #endif | 351 #endif |
356 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 352 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
357 return; | 353 return; |
358 } | 354 } |
359 } | 355 } |
360 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 356 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
361 if (FLAGS_verbose) { | 357 if (FLAGS_verbose) { |
362 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); | 358 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); |
363 } | 359 } |
364 #endif | 360 #endif |
365 } | 361 } |
366 | 362 |
367 DEF_TEST(CubicStrokerRange, reporter) { | 363 DEF_TEST(CubicStrokerRange, reporter) { |
368 SkLCGRandom r; | 364 SkLCGRandom r; |
369 SkPaint p; | 365 SkPaint p; |
370 p.setStyle(SkPaint::kStroke_Style); | 366 p.setStyle(SkPaint::kStroke_Style); |
371 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 367 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
372 int best[2] = { 0 }; | 368 int best[2] = { 0 }; |
373 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); | 369 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); |
374 #endif | 370 #endif |
375 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; | 371 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; |
376 for (int i = 0; i < 1000000; ++i) { | 372 for (int i = 0; i < 1000000; ++i) { |
377 SkPath path, fill; | 373 SkPath path, fill; |
378 path.moveTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500)); | 374 path.moveTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500)); |
379 path.cubicTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500), r.nextRangeF(0,
500), | 375 path.cubicTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500), r.nextRangeF(0,
500), |
380 r.nextRangeF(0, 500), r.nextRangeF(0, 500), r.nextRangeF(0, 500)
); | 376 r.nextRangeF(0, 500), r.nextRangeF(0, 500), r.nextRangeF(0, 500)
); |
381 p.setStrokeWidth(r.nextRangeF(0, 100)); | 377 p.setStrokeWidth(r.nextRangeF(0, 100)); |
382 p.getFillPath(path, &fill); | 378 p.getFillPath(path, &fill); |
383 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 379 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
384 if (best[0] < gMaxRecursion[0] || best[1] < gMaxRecursion[1]) { | 380 if (best[0] < gMaxRecursion[0] || best[1] < gMaxRecursion[1]) { |
385 if (FLAGS_verbose) { | 381 if (FLAGS_veryVerbose) { |
386 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMa
xRecursion[0], | 382 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMa
xRecursion[0], |
387 gMaxRecursion[1], p.getStrokeWidth()); | 383 gMaxRecursion[1], p.getStrokeWidth()); |
388 path.dumpHex(); | 384 path.dumpHex(); |
389 SkDebugf("fill:\n"); | 385 SkDebugf("fill:\n"); |
390 fill.dumpHex(); | 386 fill.dumpHex(); |
391 } | 387 } |
392 best[0] = SkTMax(best[0], gMaxRecursion[0]); | 388 best[0] = SkTMax(best[0], gMaxRecursion[0]); |
393 best[1] = SkTMax(best[1], gMaxRecursion[1]); | 389 best[1] = SkTMax(best[1], gMaxRecursion[1]); |
394 } | 390 } |
395 #endif | 391 #endif |
396 if (!FLAGS_extendedTest && SkTime::GetMSecs() > limit) { | 392 if (FLAGS_timeout && SkTime::GetMSecs() > limit) { |
397 return; | 393 return; |
398 } | 394 } |
399 } | 395 } |
400 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 396 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
401 if (FLAGS_verbose) { | 397 if (FLAGS_veryVerbose) { |
402 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, best[0], best[1]); | 398 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, best[0], best[1]); |
403 } | 399 } |
404 #endif | 400 #endif |
405 } | 401 } |
406 | 402 |
407 | 403 |
408 DEF_TEST(QuadStrokerOneOff, reporter) { | 404 DEF_TEST(QuadStrokerOneOff, reporter) { |
409 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 405 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
410 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); | 406 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); |
411 #endif | 407 #endif |
412 SkPaint p; | 408 SkPaint p; |
413 p.setStyle(SkPaint::kStroke_Style); | 409 p.setStyle(SkPaint::kStroke_Style); |
414 p.setStrokeWidth(SkDoubleToScalar(164.683548)); | 410 p.setStrokeWidth(SkDoubleToScalar(164.683548)); |
415 | 411 |
416 SkPath path, fill; | 412 SkPath path, fill; |
417 path.moveTo(SkBits2Float(0x43c99223), SkBits2Float(0x42b7417e)); | 413 path.moveTo(SkBits2Float(0x43c99223), SkBits2Float(0x42b7417e)); |
418 path.quadTo(SkBits2Float(0x4285d839), SkBits2Float(0x43ed6645), SkBits2Float(0x4
3c941c8), SkBits2Float(0x42b3ace3)); | 414 path.quadTo(SkBits2Float(0x4285d839), SkBits2Float(0x43ed6645), SkBits2Float(0x4
3c941c8), SkBits2Float(0x42b3ace3)); |
419 p.getFillPath(path, &fill); | 415 p.getFillPath(path, &fill); |
420 if (FLAGS_verbose) { | 416 if (FLAGS_veryVerbose) { |
421 SkDebugf("\n%s path\n", __FUNCTION__); | 417 SkDebugf("\n%s path\n", __FUNCTION__); |
422 path.dump(); | 418 path.dump(); |
423 SkDebugf("fill:\n"); | 419 SkDebugf("fill:\n"); |
424 fill.dump(); | 420 fill.dump(); |
425 } | 421 } |
426 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 422 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
427 if (FLAGS_verbose) { | 423 if (FLAGS_veryVerbose) { |
428 SkDebugf("max quad=%d\n", gMaxRecursion[2]); | 424 SkDebugf("max quad=%d\n", gMaxRecursion[2]); |
429 } | 425 } |
430 #endif | 426 #endif |
431 } | 427 } |
432 | 428 |
433 DEF_TEST(CubicStrokerOneOff, reporter) { | 429 DEF_TEST(CubicStrokerOneOff, reporter) { |
434 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 430 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
435 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); | 431 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); |
436 #endif | 432 #endif |
437 SkPaint p; | 433 SkPaint p; |
438 p.setStyle(SkPaint::kStroke_Style); | 434 p.setStyle(SkPaint::kStroke_Style); |
439 p.setStrokeWidth(SkDoubleToScalar(42.835968)); | 435 p.setStrokeWidth(SkDoubleToScalar(42.835968)); |
440 | 436 |
441 SkPath path, fill; | 437 SkPath path, fill; |
442 path.moveTo(SkBits2Float(0x433f5370), SkBits2Float(0x43d1f4b3)); | 438 path.moveTo(SkBits2Float(0x433f5370), SkBits2Float(0x43d1f4b3)); |
443 path.cubicTo(SkBits2Float(0x4331cb76), SkBits2Float(0x43ea3340), SkBits2Float(0x
4388f498), SkBits2Float(0x42f7f08d), SkBits2Float(0x43f1cd32), SkBits2Float(0x42
802ec1)); | 439 path.cubicTo(SkBits2Float(0x4331cb76), SkBits2Float(0x43ea3340), SkBits2Float(0x
4388f498), SkBits2Float(0x42f7f08d), SkBits2Float(0x43f1cd32), SkBits2Float(0x42
802ec1)); |
444 p.getFillPath(path, &fill); | 440 p.getFillPath(path, &fill); |
445 if (FLAGS_verbose) { | 441 if (FLAGS_veryVerbose) { |
446 SkDebugf("\n%s path\n", __FUNCTION__); | 442 SkDebugf("\n%s path\n", __FUNCTION__); |
447 path.dump(); | 443 path.dump(); |
448 SkDebugf("fill:\n"); | 444 SkDebugf("fill:\n"); |
449 fill.dump(); | 445 fill.dump(); |
450 } | 446 } |
451 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION | 447 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION |
452 if (FLAGS_verbose) { | 448 if (FLAGS_veryVerbose) { |
453 SkDebugf("max tan=%d cubic=%d\n", gMaxRecursion[0], gMaxRecursion[1]); | 449 SkDebugf("max tan=%d cubic=%d\n", gMaxRecursion[0], gMaxRecursion[1]); |
454 } | 450 } |
455 #endif | 451 #endif |
456 } | 452 } |
OLD | NEW |