blob: 68792d9d47e2b46113be0669fcbfc29cbe363b9f [file] [log] [blame]
benjaminwagnerec4d4d72016-03-25 12:59:53 -07001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
caryclarkfeff7d22014-10-09 05:36:03 -07008#include "PathOpsCubicIntersectionTestData.h"
9#include "PathOpsQuadIntersectionTestData.h"
10#include "SkCommonFlags.h"
11#include "SkPaint.h"
12#include "SkPath.h"
13#include "SkRandom.h"
14#include "SkStrokerPriv.h"
15#include "SkTime.h"
16#include "Test.h"
17
caryclark99d59152014-10-09 07:08:59 -070018DEFINE_bool(timeout, true, "run until alloted time expires");
caryclarkfeff7d22014-10-09 05:36:03 -070019
20#define MS_TEST_DURATION 10
21
22const SkScalar widths[] = {-FLT_MAX, -1, -0.1f, -FLT_EPSILON, 0, FLT_EPSILON,
23 0.0000001f, 0.000001f, 0.00001f, 0.0001f, 0.001f, 0.01f,
24 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 1, 1.1f, 2, 10, 10e2f, 10e3f, 10e4f, 10e5f, 10e6f, 10e7f,
25 10e8f, 10e9f, 10e10f, 10e20f, FLT_MAX };
26size_t widths_count = SK_ARRAY_COUNT(widths);
27
28static void pathTest(const SkPath& path) {
29 SkPaint p;
benjaminwagnerec4d4d72016-03-25 12:59:53 -070030 SkPath fill;
caryclarkfeff7d22014-10-09 05:36:03 -070031 p.setStyle(SkPaint::kStroke_Style);
32 for (size_t index = 0; index < widths_count; ++index) {
33 p.setStrokeWidth(widths[index]);
34 p.getFillPath(path, &fill);
35 }
36}
37
38static void cubicTest(const SkPoint c[4]) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -070039 SkPath path;
40 path.moveTo(c[0].fX, c[0].fY);
41 path.cubicTo(c[1].fX, c[1].fY, c[2].fX, c[2].fY, c[3].fX, c[3].fY);
42 pathTest(path);
caryclarkfeff7d22014-10-09 05:36:03 -070043}
44
45static void quadTest(const SkPoint c[3]) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -070046 SkPath path;
47 path.moveTo(c[0].fX, c[0].fY);
48 path.quadTo(c[1].fX, c[1].fY, c[2].fX, c[2].fY);
49 pathTest(path);
caryclarkfeff7d22014-10-09 05:36:03 -070050}
51
52static void cubicSetTest(const SkDCubic* dCubic, size_t count) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -070053 skiatest::Timer timer;
54 for (size_t index = 0; index < count; ++index) {
55 const SkDCubic& d = dCubic[index];
56 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
caryclarkfeff7d22014-10-09 05:36:03 -070057 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, (float) d[3].fY} };
benjaminwagnerec4d4d72016-03-25 12:59:53 -070058 cubicTest(c);
59 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -070060 return;
61 }
benjaminwagnerec4d4d72016-03-25 12:59:53 -070062 }
caryclarkfeff7d22014-10-09 05:36:03 -070063}
64
65static void cubicPairSetTest(const SkDCubic dCubic[][2], size_t count) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -070066 skiatest::Timer timer;
67 for (size_t index = 0; index < count; ++index) {
68 for (int pair = 0; pair < 2; ++pair) {
69 const SkDCubic& d = dCubic[index][pair];
70 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
caryclarkfeff7d22014-10-09 05:36:03 -070071 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, (float) d[3].fY} };
benjaminwagnerec4d4d72016-03-25 12:59:53 -070072 cubicTest(c);
73 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -070074 return;
75 }
benjaminwagnerec4d4d72016-03-25 12:59:53 -070076 }
77 }
caryclarkfeff7d22014-10-09 05:36:03 -070078}
79
80static void quadSetTest(const SkDQuad* dQuad, size_t count) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -070081 skiatest::Timer timer;
82 for (size_t index = 0; index < count; ++index) {
83 const SkDQuad& d = dQuad[index];
84 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
caryclarkfeff7d22014-10-09 05:36:03 -070085 {(float) d[2].fX, (float) d[2].fY} };
benjaminwagnerec4d4d72016-03-25 12:59:53 -070086 quadTest(c);
87 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -070088 return;
89 }
benjaminwagnerec4d4d72016-03-25 12:59:53 -070090 }
caryclarkfeff7d22014-10-09 05:36:03 -070091}
92
93static void quadPairSetTest(const SkDQuad dQuad[][2], size_t count) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -070094 skiatest::Timer timer;
95 for (size_t index = 0; index < count; ++index) {
96 for (int pair = 0; pair < 2; ++pair) {
97 const SkDQuad& d = dQuad[index][pair];
98 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
caryclarkfeff7d22014-10-09 05:36:03 -070099 {(float) d[2].fX, (float) d[2].fY} };
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700100 quadTest(c);
101 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -0700102 return;
103 }
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700104 }
105 }
caryclarkfeff7d22014-10-09 05:36:03 -0700106}
107
108DEF_TEST(QuadStrokerSet, reporter) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700109 quadSetTest(quadraticLines, quadraticLines_count);
110 quadSetTest(quadraticPoints, quadraticPoints_count);
111 quadSetTest(quadraticModEpsilonLines, quadraticModEpsilonLines_count);
112 quadPairSetTest(quadraticTests, quadraticTests_count);
caryclarkfeff7d22014-10-09 05:36:03 -0700113}
114
115DEF_TEST(CubicStrokerSet, reporter) {
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700116 cubicSetTest(pointDegenerates, pointDegenerates_count);
117 cubicSetTest(notPointDegenerates, notPointDegenerates_count);
118 cubicSetTest(lines, lines_count);
119 cubicSetTest(notLines, notLines_count);
120 cubicSetTest(modEpsilonLines, modEpsilonLines_count);
121 cubicSetTest(lessEpsilonLines, lessEpsilonLines_count);
122 cubicSetTest(negEpsilonLines, negEpsilonLines_count);
123 cubicPairSetTest(tests, tests_count);
caryclarkfeff7d22014-10-09 05:36:03 -0700124}
125
scroggof9d61012014-12-15 12:54:51 -0800126static SkScalar unbounded(SkRandom& r) {
caryclarkfeff7d22014-10-09 05:36:03 -0700127 uint32_t val = r.nextU();
128 return SkBits2Float(val);
129}
130
scroggof9d61012014-12-15 12:54:51 -0800131static SkScalar unboundedPos(SkRandom& r) {
caryclarkfeff7d22014-10-09 05:36:03 -0700132 uint32_t val = r.nextU() & 0x7fffffff;
133 return SkBits2Float(val);
134}
135
136DEF_TEST(QuadStrokerUnbounded, reporter) {
scroggof9d61012014-12-15 12:54:51 -0800137 SkRandom r;
caryclarkfeff7d22014-10-09 05:36:03 -0700138 SkPaint p;
139 p.setStyle(SkPaint::kStroke_Style);
140#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
141 int best = 0;
142 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
143#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700144 skiatest::Timer timer;
caryclarkfeff7d22014-10-09 05:36:03 -0700145 for (int i = 0; i < 1000000; ++i) {
146 SkPath path, fill;
147 path.moveTo(unbounded(r), unbounded(r));
148 path.quadTo(unbounded(r), unbounded(r), unbounded(r), unbounded(r));
149 p.setStrokeWidth(unboundedPos(r));
150 p.getFillPath(path, &fill);
151#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
152 if (best < gMaxRecursion[2]) {
caryclark99d59152014-10-09 07:08:59 -0700153 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700154 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursion[2],
155 p.getStrokeWidth());
156 path.dumpHex();
157 SkDebugf("fill:\n");
158 fill.dumpHex();
159 }
160 best = gMaxRecursion[2];
161 }
162#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700163 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -0700164 return;
165 }
166 }
167#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
caryclark99d59152014-10-09 07:08:59 -0700168 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700169 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best);
170 }
171#endif
172}
173
174DEF_TEST(CubicStrokerUnbounded, reporter) {
scroggof9d61012014-12-15 12:54:51 -0800175 SkRandom r;
caryclarkfeff7d22014-10-09 05:36:03 -0700176 SkPaint p;
177 p.setStyle(SkPaint::kStroke_Style);
178#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
179 int bestTan = 0;
180 int bestCubic = 0;
181 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
182#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700183 skiatest::Timer timer;
caryclarkfeff7d22014-10-09 05:36:03 -0700184 for (int i = 0; i < 1000000; ++i) {
185 SkPath path, fill;
186 path.moveTo(unbounded(r), unbounded(r));
187 path.cubicTo(unbounded(r), unbounded(r), unbounded(r), unbounded(r),
188 unbounded(r), unbounded(r));
189 p.setStrokeWidth(unboundedPos(r));
190 p.getFillPath(path, &fill);
191 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
192 if (bestTan < gMaxRecursion[0] || bestCubic < gMaxRecursion[1]) {
caryclark99d59152014-10-09 07:08:59 -0700193 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700194 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMaxRecursion[0],
195 gMaxRecursion[1], p.getStrokeWidth());
196 path.dumpHex();
197 SkDebugf("fill:\n");
198 fill.dumpHex();
199 }
200 bestTan = SkTMax(bestTan, gMaxRecursion[0]);
201 bestCubic = SkTMax(bestCubic, gMaxRecursion[1]);
202 }
203 #endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700204 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -0700205 return;
206 }
207 }
208#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
caryclark99d59152014-10-09 07:08:59 -0700209 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700210 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic);
211 }
212#endif
213}
214
215DEF_TEST(QuadStrokerConstrained, reporter) {
scroggof9d61012014-12-15 12:54:51 -0800216 SkRandom r;
caryclarkfeff7d22014-10-09 05:36:03 -0700217 SkPaint p;
218 p.setStyle(SkPaint::kStroke_Style);
219#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
220 int best = 0;
221 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
222#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700223 skiatest::Timer timer;
caryclarkfeff7d22014-10-09 05:36:03 -0700224 for (int i = 0; i < 1000000; ++i) {
225 SkPath path, fill;
226 SkPoint quad[3];
227 quad[0].fX = r.nextRangeF(0, 500);
228 quad[0].fY = r.nextRangeF(0, 500);
229 const SkScalar halfSquared = 0.5f * 0.5f;
230 do {
231 quad[1].fX = r.nextRangeF(0, 500);
232 quad[1].fY = r.nextRangeF(0, 500);
233 } while (quad[0].distanceToSqd(quad[1]) < halfSquared);
234 do {
235 quad[2].fX = r.nextRangeF(0, 500);
236 quad[2].fY = r.nextRangeF(0, 500);
237 } while (quad[0].distanceToSqd(quad[2]) < halfSquared
238 || quad[1].distanceToSqd(quad[2]) < halfSquared);
239 path.moveTo(quad[0].fX, quad[0].fY);
240 path.quadTo(quad[1].fX, quad[1].fY, quad[2].fX, quad[2].fY);
241 p.setStrokeWidth(r.nextRangeF(0, 500));
242 p.getFillPath(path, &fill);
243#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
244 if (best < gMaxRecursion[2]) {
caryclark99d59152014-10-09 07:08:59 -0700245 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700246 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursion[2],
247 p.getStrokeWidth());
248 path.dumpHex();
249 SkDebugf("fill:\n");
250 fill.dumpHex();
251 }
252 best = gMaxRecursion[2];
253 }
254#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700255 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -0700256 return;
257 }
258 }
259#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
caryclark99d59152014-10-09 07:08:59 -0700260 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700261 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best);
262 }
263#endif
264}
265
266DEF_TEST(CubicStrokerConstrained, reporter) {
scroggof9d61012014-12-15 12:54:51 -0800267 SkRandom r;
caryclarkfeff7d22014-10-09 05:36:03 -0700268 SkPaint p;
269 p.setStyle(SkPaint::kStroke_Style);
270#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
271 int bestTan = 0;
272 int bestCubic = 0;
273 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
274#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700275 skiatest::Timer timer;
caryclarkfeff7d22014-10-09 05:36:03 -0700276 for (int i = 0; i < 1000000; ++i) {
277 SkPath path, fill;
278 SkPoint cubic[4];
279 cubic[0].fX = r.nextRangeF(0, 500);
280 cubic[0].fY = r.nextRangeF(0, 500);
281 const SkScalar halfSquared = 0.5f * 0.5f;
282 do {
283 cubic[1].fX = r.nextRangeF(0, 500);
284 cubic[1].fY = r.nextRangeF(0, 500);
285 } while (cubic[0].distanceToSqd(cubic[1]) < halfSquared);
286 do {
287 cubic[2].fX = r.nextRangeF(0, 500);
288 cubic[2].fY = r.nextRangeF(0, 500);
289 } while ( cubic[0].distanceToSqd(cubic[2]) < halfSquared
290 || cubic[1].distanceToSqd(cubic[2]) < halfSquared);
291 do {
292 cubic[3].fX = r.nextRangeF(0, 500);
293 cubic[3].fY = r.nextRangeF(0, 500);
294 } while ( cubic[0].distanceToSqd(cubic[3]) < halfSquared
295 || cubic[1].distanceToSqd(cubic[3]) < halfSquared
296 || cubic[2].distanceToSqd(cubic[3]) < halfSquared);
297 path.moveTo(cubic[0].fX, cubic[0].fY);
298 path.cubicTo(cubic[1].fX, cubic[1].fY, cubic[2].fX, cubic[2].fY, cubic[3].fX, cubic[3].fY);
299 p.setStrokeWidth(r.nextRangeF(0, 500));
300 p.getFillPath(path, &fill);
301#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
302 if (bestTan < gMaxRecursion[0] || bestCubic < gMaxRecursion[1]) {
caryclark99d59152014-10-09 07:08:59 -0700303 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700304 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMaxRecursion[0],
305 gMaxRecursion[1], p.getStrokeWidth());
306 path.dumpHex();
307 SkDebugf("fill:\n");
308 fill.dumpHex();
309 }
310 bestTan = SkTMax(bestTan, gMaxRecursion[0]);
311 bestCubic = SkTMax(bestCubic, gMaxRecursion[1]);
312 }
313#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700314 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -0700315 return;
316 }
317 }
318#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
caryclark99d59152014-10-09 07:08:59 -0700319 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700320 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic);
321 }
322#endif
323}
324
325DEF_TEST(QuadStrokerRange, reporter) {
scroggof9d61012014-12-15 12:54:51 -0800326 SkRandom r;
caryclarkfeff7d22014-10-09 05:36:03 -0700327 SkPaint p;
328 p.setStyle(SkPaint::kStroke_Style);
329#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
330 int best = 0;
331 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
332#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700333 skiatest::Timer timer;
caryclarkfeff7d22014-10-09 05:36:03 -0700334 for (int i = 0; i < 1000000; ++i) {
335 SkPath path, fill;
336 SkPoint quad[3];
337 quad[0].fX = r.nextRangeF(0, 500);
338 quad[0].fY = r.nextRangeF(0, 500);
339 quad[1].fX = r.nextRangeF(0, 500);
340 quad[1].fY = r.nextRangeF(0, 500);
341 quad[2].fX = r.nextRangeF(0, 500);
342 quad[2].fY = r.nextRangeF(0, 500);
343 path.moveTo(quad[0].fX, quad[0].fY);
344 path.quadTo(quad[1].fX, quad[1].fY, quad[2].fX, quad[2].fY);
345 p.setStrokeWidth(r.nextRangeF(0, 500));
346 p.getFillPath(path, &fill);
347#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
348 if (best < gMaxRecursion[2]) {
caryclark99d59152014-10-09 07:08:59 -0700349 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700350 SkDebugf("\n%s quad=%d width=%1.9g\n", __FUNCTION__, gMaxRecursion[2],
351 p.getStrokeWidth());
352 path.dumpHex();
353 SkDebugf("fill:\n");
354 fill.dumpHex();
355 }
356 best = gMaxRecursion[2];
357 }
358#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700359 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -0700360 return;
361 }
362 }
363#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
364 if (FLAGS_verbose) {
365 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best);
366 }
367#endif
368}
369
370DEF_TEST(CubicStrokerRange, reporter) {
scroggof9d61012014-12-15 12:54:51 -0800371 SkRandom r;
caryclarkfeff7d22014-10-09 05:36:03 -0700372 SkPaint p;
373 p.setStyle(SkPaint::kStroke_Style);
374#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
375 int best[2] = { 0 };
376 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
377#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700378 skiatest::Timer timer;
caryclarkfeff7d22014-10-09 05:36:03 -0700379 for (int i = 0; i < 1000000; ++i) {
380 SkPath path, fill;
381 path.moveTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500));
382 path.cubicTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500), r.nextRangeF(0, 500),
383 r.nextRangeF(0, 500), r.nextRangeF(0, 500), r.nextRangeF(0, 500));
384 p.setStrokeWidth(r.nextRangeF(0, 100));
385 p.getFillPath(path, &fill);
386#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
387 if (best[0] < gMaxRecursion[0] || best[1] < gMaxRecursion[1]) {
caryclark99d59152014-10-09 07:08:59 -0700388 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700389 SkDebugf("\n%s tan=%d cubic=%d width=%1.9g\n", __FUNCTION__, gMaxRecursion[0],
390 gMaxRecursion[1], p.getStrokeWidth());
391 path.dumpHex();
392 SkDebugf("fill:\n");
393 fill.dumpHex();
394 }
395 best[0] = SkTMax(best[0], gMaxRecursion[0]);
396 best[1] = SkTMax(best[1], gMaxRecursion[1]);
397 }
398#endif
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700399 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
caryclarkfeff7d22014-10-09 05:36:03 -0700400 return;
401 }
402 }
403#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
caryclark99d59152014-10-09 07:08:59 -0700404 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700405 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, best[0], best[1]);
406 }
407#endif
408}
409
410
411DEF_TEST(QuadStrokerOneOff, reporter) {
412#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
413 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
414#endif
415 SkPaint p;
416 p.setStyle(SkPaint::kStroke_Style);
417 p.setStrokeWidth(SkDoubleToScalar(164.683548));
418
419 SkPath path, fill;
420path.moveTo(SkBits2Float(0x43c99223), SkBits2Float(0x42b7417e));
421path.quadTo(SkBits2Float(0x4285d839), SkBits2Float(0x43ed6645), SkBits2Float(0x43c941c8), SkBits2Float(0x42b3ace3));
422 p.getFillPath(path, &fill);
caryclark99d59152014-10-09 07:08:59 -0700423 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700424 SkDebugf("\n%s path\n", __FUNCTION__);
425 path.dump();
426 SkDebugf("fill:\n");
427 fill.dump();
428 }
429#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
caryclark99d59152014-10-09 07:08:59 -0700430 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700431 SkDebugf("max quad=%d\n", gMaxRecursion[2]);
432 }
433#endif
434}
435
436DEF_TEST(CubicStrokerOneOff, reporter) {
437#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
438 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
439#endif
440 SkPaint p;
441 p.setStyle(SkPaint::kStroke_Style);
442 p.setStrokeWidth(SkDoubleToScalar(42.835968));
443
444 SkPath path, fill;
445path.moveTo(SkBits2Float(0x433f5370), SkBits2Float(0x43d1f4b3));
446path.cubicTo(SkBits2Float(0x4331cb76), SkBits2Float(0x43ea3340), SkBits2Float(0x4388f498), SkBits2Float(0x42f7f08d), SkBits2Float(0x43f1cd32), SkBits2Float(0x42802ec1));
447 p.getFillPath(path, &fill);
caryclark99d59152014-10-09 07:08:59 -0700448 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700449 SkDebugf("\n%s path\n", __FUNCTION__);
450 path.dump();
451 SkDebugf("fill:\n");
452 fill.dump();
453 }
454#if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
caryclark99d59152014-10-09 07:08:59 -0700455 if (FLAGS_veryVerbose) {
caryclarkfeff7d22014-10-09 05:36:03 -0700456 SkDebugf("max tan=%d cubic=%d\n", gMaxRecursion[0], gMaxRecursion[1]);
457 }
458#endif
459}