blob: 51f65348f1c4793cfd85a7b44555adf80b53ad8b [file] [log] [blame]
caryclark@google.comcd4421d2012-03-01 19:16:31 +00001#include "EdgeWalker_Test.h"
2#include "Intersection_Tests.h"
3
4static void testSimplifyTriangle() {
5 SkPath path, out;
6 path.setFillType(SkPath::kWinding_FillType);
7 path.moveTo(10,10); // triangle |\ .
8 path.lineTo(10,30); // |_\ .
9 path.lineTo(20,30);
10 path.close();
11 path.moveTo(20,10); // triangle /|
12 path.lineTo(10,30); // /_|
13 path.lineTo(20,30);
14 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +000015 testSimplify(path, true, out); // expect |\/|
16 // |__|
caryclark@google.comcd4421d2012-03-01 19:16:31 +000017}
18
19static void testSimplifyTriangle3() {
20 SkPath path, out;
21 path.moveTo(0, 0);
22 path.lineTo(1, 0);
23 path.lineTo(0, 1);
24 path.close();
25 path.moveTo(0, 0);
26 path.lineTo(1, 0);
27 path.lineTo(3, 1);
28 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +000029 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +000030}
31
32static void testSimplifyTriangle4() {
33 SkPath path, out;
34 path.moveTo(0, 0);
35 path.lineTo(1, 0);
36 path.lineTo(0, 1);
37 path.close();
38 path.moveTo(0, 0);
39 path.lineTo(1, 0);
40 path.lineTo(2, 1);
41 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +000042 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +000043}
44
45static void testSimplifyTriangle5() {
46 SkPath path, out;
47 path.moveTo(0, 0);
48 path.lineTo(1, 0);
49 path.lineTo(0, 1);
50 path.close();
51 path.moveTo(0, 0);
52 path.lineTo(1, 1);
53 path.lineTo(2, 1);
54 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +000055 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +000056}
57
58static void testSimplifyTriangle6() {
59 SkPath path, out;
60 path.moveTo(0, 0);
61 path.lineTo(1, 0);
62 path.lineTo(0, 1);
63 path.lineTo(0, 0);
64 path.close();
65 path.moveTo(0, 0);
66 path.lineTo(0, 1);
67 path.lineTo(3, 1);
68 path.lineTo(0, 0);
69 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +000070 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +000071}
72
73static void testSimplifyTriangle7() {
74 SkPath path, out;
75 path.moveTo(0, 0);
76 path.lineTo(1, 0);
77 path.lineTo(0, 1);
78 path.lineTo(0, 0);
79 path.close();
80 path.moveTo(0, 0);
81 path.lineTo(1, 1);
82 path.lineTo(0, 2);
83 path.lineTo(0, 0);
84 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +000085 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +000086}
87
88static void testSimplifyTriangle8() {
89 SkPath path, out;
90 path.moveTo(0, 0);
91 path.lineTo(1, 0);
92 path.lineTo(0, 1);
93 path.lineTo(0, 0);
94 path.close();
95 path.moveTo(0, 1);
96 path.lineTo(1, 2);
97 path.lineTo(1, 3);
98 path.lineTo(0, 1);
99 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000100 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000101}
102
103static void testSimplifyTriangle9() {
104 SkPath path, out;
105 path.moveTo(0, 0);
106 path.lineTo(1, 0);
107 path.lineTo(1, 1);
108 path.lineTo(0, 0);
109 path.close();
110 path.moveTo(0, 0);
111 path.lineTo(1, 1);
112 path.lineTo(2, 1);
113 path.lineTo(0, 0);
114 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000115 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000116}
117
118static void testSimplifyTriangle10() {
119 SkPath path, out;
120 path.moveTo(0, 0);
121 path.lineTo(1, 0);
122 path.lineTo(1, 1);
123 path.lineTo(0, 0);
124 path.close();
125 path.moveTo(0, 0);
126 path.lineTo(2, 0);
127 path.lineTo(0, 1);
128 path.lineTo(0, 0);
129 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000130 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000131}
132
133static void testSimplifyTriangle11() {
134 SkPath path, out;
135 path.moveTo(0, 0);
136 path.lineTo(1, 0);
137 path.lineTo(0, 2);
138 path.lineTo(0, 0);
139 path.close();
140 path.moveTo(0, 0);
141 path.lineTo(2, 1);
142 path.lineTo(2, 2);
143 path.lineTo(0, 0);
144 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000145 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000146}
147
148static void testSimplifyTriangle12() {
149 SkPath path, out;
150 path.moveTo(0, 0);
151 path.lineTo(1, 0);
152 path.lineTo(1, 2);
153 path.lineTo(0, 0);
154 path.close();
155 path.moveTo(2, 0);
156 path.lineTo(0, 3);
157 path.lineTo(1, 1);
158 path.lineTo(2, 0);
159 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000160 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000161}
162
163static void testSimplifyTriangle13() {
164 SkPath path, out;
165 path.moveTo(0, 0);
166 path.lineTo(1, 0);
167 path.lineTo(0, 3);
168 path.lineTo(0, 0);
169 path.close();
170 path.moveTo(3, 0);
171 path.lineTo(0, 3);
172 path.lineTo(1, 1);
173 path.lineTo(3, 0);
174 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000175 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000176}
177
178static void testSimplifyTriangle14() {
179 SkPath path, out;
180 path.moveTo(0, 0);
181 path.lineTo(1, 0);
182 path.lineTo(0, 1);
183 path.lineTo(0, 0);
184 path.close();
185 path.moveTo(0, 0);
186 path.lineTo(1, 0);
187 path.lineTo(0, 1);
188 path.lineTo(0, 0);
189 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000190 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000191}
192
193static void testSimplifyTriangle15() {
194 SkPath path, out;
195 path.setFillType(SkPath::kEvenOdd_FillType);
196 path.moveTo(0, 0);
197 path.lineTo(0, 1);
198 path.lineTo(1, 2);
199 path.close();
200 path.moveTo(0, 0);
201 path.lineTo(0, 1);
202 path.lineTo(2, 2);
203 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000204 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000205}
206
207static void testSimplifyTriangle16() {
208 SkPath path, out;
209 path.moveTo(0, 0);
210 path.lineTo(0, 1);
211 path.lineTo(1, 2);
212 path.close();
213 path.moveTo(0, 0);
214 path.lineTo(0, 1);
215 path.lineTo(1, 3);
216 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000217 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000218}
219
220static void testSimplifyTriangle17() {
221 SkPath path, out;
222 path.moveTo(0, 0);
223 path.lineTo(0, 1);
224 path.lineTo(1, 2);
225 path.close();
226 path.moveTo(0, 0);
227 path.lineTo(1, 3);
228 path.lineTo(0, 1);
229 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000230 testSimplify(path, true, out);
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000231}
232
caryclark@google.com4917f172012-03-05 22:01:21 +0000233static void testSimplifyTriangle18() {
234 SkPath path, out;
235 path.moveTo(0, 0);
236 path.lineTo(0, 1);
237 path.lineTo(1, 2);
238 path.close();
239 path.moveTo(1, 0);
240 path.lineTo(0, 1);
241 path.lineTo(0, 3);
242 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000243 testSimplify(path, true, out);
caryclark@google.com4917f172012-03-05 22:01:21 +0000244}
245
246static void testSimplifyTriangle19() {
247 SkPath path, out;
248 path.setFillType(SkPath::kEvenOdd_FillType);
249 path.moveTo(0, 0);
250 path.lineTo(0, 1);
251 path.lineTo(3, 2);
252 path.close();
253 path.moveTo(0, 0);
254 path.lineTo(1, 1);
255 path.lineTo(2, 1);
256 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000257 testSimplify(path, true, out);
caryclark@google.com4917f172012-03-05 22:01:21 +0000258}
259
260static void testSimplifyTriangle20() {
261 SkPath path, out;
262 path.moveTo(0, 0);
263 path.lineTo(2, 1);
264 path.lineTo(1, 3);
265 path.close();
266 path.moveTo(2, 0);
267 path.lineTo(3, 2);
268 path.lineTo(0, 3);
269 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000270 testSimplify(path, true, out);
caryclark@google.com4917f172012-03-05 22:01:21 +0000271}
272
273static void testSimplifyTriangle21() {
274 SkPath path, out;
275 path.moveTo(0, 0);
276 path.lineTo(1, 0);
277 path.lineTo(1, 2);
278 path.close();
279 path.moveTo(2, 0);
280 path.lineTo(2, 1);
281 path.lineTo(0, 3);
282 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000283 testSimplify(path, true, out);
caryclark@google.com4917f172012-03-05 22:01:21 +0000284}
285
286static void testSimplifyDegenerateTriangle1() {
287 SkPath path, out;
288 path.moveTo(0, 0);
289 path.lineTo(0, 0);
290 path.lineTo(0, 0);
291 path.close();
292 path.moveTo(0, 0);
293 path.lineTo(0, 0);
294 path.lineTo(0, 0);
295 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000296 testSimplify(path, true, out);
caryclark@google.com4917f172012-03-05 22:01:21 +0000297}
298
299static void testSimplifyDegenerateTriangle2() {
300 SkPath path, out;
301 path.moveTo(0, 0);
302 path.lineTo(1, 1);
303 path.lineTo(2, 2);
304 path.close();
305 path.moveTo(1, 0);
306 path.lineTo(2, 2);
307 path.lineTo(3, 3);
308 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000309 testSimplify(path, true, out);
caryclark@google.com4917f172012-03-05 22:01:21 +0000310}
311
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000312static void testSimplifyWindingParallelogram() {
313 SkPath path, out;
314 path.setFillType(SkPath::kWinding_FillType);
315 path.moveTo(20,10); // parallelogram _
316 path.lineTo(30,30); // \ \ .
317 path.lineTo(40,30); // \_\ .
318 path.lineTo(30,10);
319 path.close();
320 path.moveTo(20,10); // parallelogram _
321 path.lineTo(10,30); // / /
322 path.lineTo(20,30); // /_/
323 path.lineTo(30,10);
324 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000325 testSimplify(path, true, out); // expect _
326 // / \ .
327} // /___\ .
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000328
329static void testSimplifyXorParallelogram() {
330 SkPath path, out;
331 path.setFillType(SkPath::kEvenOdd_FillType);
332 path.moveTo(20,10); // parallelogram _
333 path.lineTo(30,30); // \ \ .
334 path.lineTo(40,30); // \_\ .
335 path.lineTo(30,10);
336 path.close();
337 path.moveTo(20,10); // parallelogram _
338 path.lineTo(10,30); // / /
339 path.lineTo(20,30); // /_/
340 path.lineTo(30,10);
341 path.close();
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000342 testSimplify(path, true, out); // expect _
343} // \ /
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000344
345static void testSimplifyTriangle2() {
346 SkPath path, out;
347 path.setFillType(SkPath::kWinding_FillType);
348 path.moveTo(10,10); // triangle |\ .
349 path.lineTo(10,30); // |_\ .
350 path.lineTo(20,30);
351 path.close();
352 path.moveTo(10,10); // triangle _
353 path.lineTo(20,10); // \ |
354 path.lineTo(20,30); // \|
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000355 path.close(); // _
356 testSimplify(path, true, out); // expect | |
357} // |_|
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000358
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000359static void testPathTriangleRendering() {
360 SkPath one, two;
361 one.moveTo(0, 0);
362 one.lineTo(3, 3);
363 one.lineTo(0, 3);
364 one.lineTo(1, 2);
365 one.close();
366 for (float x = .1f; x <= 2.9f; x += .1f) {
367 SkDebugf("%s x=%g\n", __FUNCTION__, x);
368 two.moveTo(0, 0);
369 two.lineTo(x, x);
370 two.lineTo(3, 3);
371 two.lineTo(0, 3);
372 two.lineTo(1, 2);
373 two.close();
374 comparePaths(one, two);
375 two.reset();
376 }
377}
378
caryclark@google.com752b60e2012-03-22 21:11:17 +0000379static void simplify(const char* functionName, const SkPath& path,
380 bool fill, SkPath& out) {
381 SkDebugf("%s\n", functionName);
382 simplify(path, fill, out);
383}
384
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000385static void testSimplifySkinnyTriangle1() {
386 for (int x = 1; x < 255; ++x) {
387 SkPath path, out;
388 path.moveTo((x * 101) % 10, 0);
389 path.lineTo((x * 91) % 10, 1000);
390 path.lineTo((x * 71) % 10, 2000);
391 path.lineTo((x * 51) % 10, 3000);
392 path.close();
393 path.moveTo((x * 101) % 20, 0);
394 path.lineTo((x * 91) % 20, 1000);
395 path.lineTo((x * 71) % 20, 2000);
396 path.lineTo((x * 51) % 20, 3000);
397 path.close();
398 path.moveTo((x * 101) % 30, 0);
399 path.lineTo((x * 91) % 30, 1000);
400 path.lineTo((x * 71) % 30, 2000);
401 path.lineTo((x * 51) % 30, 3000);
402 path.close();
caryclark@google.com752b60e2012-03-22 21:11:17 +0000403 simplify(path, true, out);
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000404 }
405}
406
407static void testSimplifySkinnyTriangle2() {
408 SkPath path, out;
409#if 01
410path.moveTo(591.091064, 627.534851);
411path.lineTo(541.088135, 560.707642);
412path.lineTo(491.085175, 493.880310);
413path.lineTo(441.082214, 427.053101);
414//path.lineTo(591.091064, 627.534851);
415path.close();
416#endif
417path.moveTo(317.093445, 592.013306);
418path.lineTo(366.316162, 542.986572);
419path.lineTo(416.051514, 486.978577);
420path.lineTo(465.786865, 430.970581);
421//path.lineTo(317.093445, 592.013306);
422path.close();
423#if 0
424path.moveTo(289.392517, 517.138489);
425path.lineTo(249.886078, 508.598022);
426path.lineTo(217.110916, 450.916443);
427path.lineTo(196.621033, 394.917633);
428//path.lineTo(289.392517, 517.138489);
429path.close();
430#endif
caryclark@google.com752b60e2012-03-22 21:11:17 +0000431 simplify(__FUNCTION__, path, true, out);
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000432}
433
434static void testSimplifySkinnyTriangle3() {
435 SkPath path, out;
436 path.moveTo(591, 627.534851);
437 path.lineTo(541, 560.707642);
438 path.lineTo(491, 493.880310);
439 path.lineTo(441, 427.053101);
440 path.close();
441 path.moveTo(317, 592.013306);
442 path.lineTo(366, 542.986572);
443 path.lineTo(416, 486.978577);
444 path.lineTo(465, 430.970581);
445 path.close();
caryclark@google.com752b60e2012-03-22 21:11:17 +0000446 simplify(__FUNCTION__, path, true, out);
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000447}
448
449static void testSimplifySkinnyTriangle4() {
450 SkPath path, out;
451path.moveTo(572.655212, 614.959961);
452path.lineTo(524.618896, 549.339600);
453path.lineTo(476.582581, 483.719269);
454path.lineTo(428.546265, 418.098938);
455path.lineTo(572.655212, 614.959961);
456path.close();
457path.moveTo(312.166382, 583.723083);
458path.lineTo(361.047791, 529.824219);
459path.lineTo(409.929230, 475.925354);
460path.lineTo(458.810669, 422.026520);
461path.lineTo(312.166382, 583.723083);
462path.close();
463path.moveTo(278.742737, 508.065643);
464path.lineTo(241.475800, 493.465118);
465path.lineTo(210.344177, 437.315125);
466path.lineTo(197.019455, 383.794556);
467path.lineTo(278.742737, 508.065643);
468path.close();
caryclark@google.com752b60e2012-03-22 21:11:17 +0000469 simplify(__FUNCTION__, path, true, out);
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000470}
471
472static void testSimplifySkinnyTriangle5() {
473 SkPath path, out;
474path.moveTo(554.690613, 602.286072);
475path.lineTo(508.590057, 537.906250);
476path.lineTo(462.489441, 473.526520);
477path.lineTo(416.388855, 409.146729);
478path.lineTo(554.690613, 602.286072);
479path.close();
480path.moveTo(307.216949, 575.189270);
481path.lineTo(355.826965, 516.804688);
482path.lineTo(403.815918, 464.990753);
483path.lineTo(451.804871, 413.176819);
484path.lineTo(307.216949, 575.189270);
485path.close();
486path.moveTo(271.998901, 521.301025);
487path.lineTo(234.619705, 499.687683);
488path.lineTo(203.059692, 441.332336);
489path.lineTo(195.994370, 386.856506);
490path.lineTo(271.998901, 521.301025);
491path.close();
caryclark@google.com752b60e2012-03-22 21:11:17 +0000492 simplify(__FUNCTION__, path, true, out);
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000493}
494
caryclark@google.com752b60e2012-03-22 21:11:17 +0000495static void testSimplifySkinnyTriangle6() {
496 SkPath path, out;
497path.moveTo(591.091064, 627.534851);
498path.lineTo(541.088135, 560.707642);
499path.lineTo(491.085175, 493.880310);
500path.lineTo(441.082214, 427.053101);
501path.lineTo(591.091064, 627.534851);
502path.close();
503path.moveTo(317.093445, 592.013306);
504path.lineTo(366.316162, 542.986572);
505path.lineTo(416.051514, 486.978577);
506path.lineTo(465.786865, 430.970581);
507path.lineTo(317.093445, 592.013306);
508path.close();
509path.moveTo(289.392517, 517.138489);
510path.lineTo(249.886078, 508.598022);
511path.lineTo(217.110916, 450.916443);
512path.lineTo(196.621033, 394.917633);
513path.lineTo(289.392517, 517.138489);
514path.close();
515 simplify(__FUNCTION__, path, true, out);
516}
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000517
518static void testSimplifyTriangle22() {
519 SkPath path, out;
520 path.moveTo(0, 0);
521 path.lineTo(1, 0);
522 path.lineTo(0, 2);
523 path.close();
524 path.moveTo(1, 0);
525 path.lineTo(0, 2);
526 path.lineTo(0, 1);
527 path.close();
528 testSimplify(path, true, out);
529}
530
531static void testSimplifyTriangle23() {
532 SkPath path, out;
533 path.moveTo(0, 0);
534 path.lineTo(0, 0);
535 path.lineTo(0, 0);
536 path.close();
537 path.moveTo(0, 0);
538 path.lineTo(0, 1);
539 path.lineTo(1, 2);
540 path.close();
541 testSimplify(path, true, out);
542}
543
544static void testSimplifyTriangle24() {
545 SkPath path, out;
546 path.moveTo(0, 0);
547 path.lineTo(0, 0);
548 path.lineTo(0, 1);
549 path.close();
550 path.moveTo(0, 0);
551 path.lineTo(1, 0);
552 path.lineTo(0, 1);
553 path.close();
554 testSimplify(path, true, out);
555}
556
caryclark@google.com752b60e2012-03-22 21:11:17 +0000557static void testSimplifySkinnyTriangle7() {
558 SkPath path, out;
559path.moveTo(487.502319, 550.811279);
560path.lineTo(448.826050, 491.720123);
561path.lineTo(410.149780, 432.628967);
562path.lineTo(371.473572, 373.537781);
563path.lineTo(487.502319, 550.811279);
564path.close();
565path.moveTo(295.817108, 532.655579);
566path.lineTo(342.896271, 485.912292);
567path.lineTo(389.975433, 439.169006);
568path.lineTo(437.054596, 392.425781);
569path.lineTo(295.817108, 532.655579);
570path.close();
571path.moveTo(239.726822, 575.025269);
572path.lineTo(204.117569, 521.429688);
573path.lineTo(171.275452, 454.110382);
574path.lineTo(193.328583, 397.859497);
575path.lineTo(239.726822, 575.025269);
576path.close();
577 simplify(__FUNCTION__, path, true, out);
578}
579
580static void testSimplifySkinnyTriangle8() {
581 SkPath path, out;
582path.moveTo(441.943115, 511.678040);
583path.lineTo(408.487549, 456.880920);
584path.lineTo(375.031952, 402.083801);
585path.lineTo(341.576385, 347.286682);
586path.lineTo(441.943115, 511.678040);
587path.close();
588path.moveTo(297.548492, 557.246704);
589path.lineTo(350.768494, 507.627014);
590path.lineTo(403.988525, 458.007385);
591path.lineTo(457.208527, 408.387695);
592path.lineTo(297.548492, 557.246704);
593path.close();
594path.moveTo(209.857895, 615.802979);
595path.lineTo(178.249481, 534.230347);
596path.lineTo(144.905640, 460.056824);
597path.lineTo(192.953125, 404.972900);
598path.lineTo(209.857895, 615.802979);
599path.close();
600 simplify(__FUNCTION__, path, true, out);
601}
602
603static void testSimplifySkinnyTriangle9() {
604 SkPath path, out;
605path.moveTo(439.867065, 528.291931);
606path.lineTo(405.413025, 469.107178);
607path.lineTo(370.958954, 409.922363);
608path.lineTo(336.504883, 350.737610);
609path.lineTo(439.867065, 528.291931);
610path.close();
611path.moveTo(298.922455, 573.251953);
612path.lineTo(356.360962, 521.905090);
613path.lineTo(413.799438, 470.558228);
614path.lineTo(471.237915, 419.211365);
615path.lineTo(298.922455, 573.251953);
616path.close();
617path.moveTo(187.200775, 643.035156);
618path.lineTo(159.713165, 540.993774);
619path.lineTo(126.257164, 462.198517);
620path.lineTo(193.534012, 409.266235);
621path.lineTo(187.200775, 643.035156);
622path.close();
623path.close();
624 simplify(__FUNCTION__, path, true, out);
625}
626
627static void testSimplifySkinnyTriangle10() {
628 SkPath path, out;
629#if 0
630path.moveTo(99.270325, 239.365234);
631path.lineTo(105.967056, 173.361206);
632path.lineTo(148.821381, 141.309891);
633path.lineTo(159.101013, 189.235138);
634path.lineTo(99.270325, 239.365234);
635path.close();
636#endif
637path.moveTo(213.673737, 413.292938);
638path.lineTo(225.200134, 343.616821);
639path.lineTo(236.726532, 273.940704);
640path.lineTo(219.386414, 231.373322);
641path.lineTo(213.673737, 413.292938);
642path.close();
643path.moveTo(43.485352, 308.984497);
644path.lineTo(122.610657, 305.950134);
645path.lineTo(201.735962, 302.915802);
646path.lineTo(280.861267, 299.881470);
647path.lineTo(43.485352, 308.984497);
648path.close();
649 simplify(__FUNCTION__, path, true, out);
650}
651
caryclark@google.comd88e0892012-03-27 13:23:51 +0000652static void testSimplifySkinnyTriangle11() {
653 SkPath path, out;
654path.moveTo(-177.878387, 265.368988);
655path.lineTo(-254.415771, 303.709961);
656path.lineTo(-317.465363, 271.325562);
657path.lineTo(-374.520386, 207.507660);
658path.lineTo(-177.878387, 265.368988);
659path.close();
660path.moveTo(-63.582489, -3.679123);
661path.lineTo(-134.496841, 26.434566);
662path.lineTo(-205.411209, 56.548256);
663path.lineTo(-276.325562, 86.661942);
664path.lineTo(-63.582489, -3.679123);
665path.close();
666path.moveTo(-57.078423, 162.633453);
667path.lineTo(-95.963928, 106.261139);
668path.lineTo(-134.849457, 49.888824);
669path.lineTo(-173.734955, -6.483480);
670path.lineTo(-57.078423, 162.633453);
671path.close();
672 simplify(__FUNCTION__, path, true, out);
673}
674
675static void testSimplifySkinnyTriangle12() {
676 SkPath path, out;
677path.moveTo(98.666489, -94.295059);
678path.lineTo(156.584320, -61.939133);
679path.lineTo(174.672974, -12.343765);
680path.lineTo(158.622345, 52.028267);
681path.lineTo(98.666489, -94.295059);
682path.close();
683path.moveTo(-133.225616, -48.622055);
684path.lineTo(-73.855499, -10.375397);
685path.lineTo(-14.485367, 27.871277);
686path.lineTo(44.884750, 66.117935);
687path.lineTo(-133.225616, -48.622055);
688path.close();
689path.moveTo( 9.030045, -163.413132);
690path.lineTo(-19.605331, -89.588760);
691path.lineTo(-48.240707, -15.764404);
692path.lineTo(-76.876053, 58.059944);
693path.lineTo( 9.030045, -163.413132);
694path.close();
695 simplify(__FUNCTION__, path, true, out);
696}
697
698static void testSimplifySkinnyTriangle13() {
699 SkPath path, out;
700path.moveTo(340.41568, -170.97171);
701path.lineTo(418.846893, -142.428329);
702path.lineTo(497.278107, -113.884933);
703path.lineTo(449.18222, -45.6723022);
704path.lineTo(340.41568, -170.97171);
705path.close();
706path.moveTo(301.372925, -213.590073);
707path.lineTo(348.294434, -271.975586);
708path.lineTo(395.215973, -330.361145);
709path.lineTo(400.890381, -263.276855);
710path.lineTo(301.372925, -213.590073);
711path.close();
712path.moveTo(326.610535, 34.0393639);
713path.lineTo(371.334595, -14.9620667);
714path.lineTo(416.058624, -63.9634857);
715path.lineTo(460.782654, -112.96492);
716path.lineTo(326.610535, 34.0393639);
717path.close();
718 simplify(__FUNCTION__, path, true, out);
719}
720
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000721static void (*simplifyTests[])() = {
caryclark@google.comd88e0892012-03-27 13:23:51 +0000722 testSimplifySkinnyTriangle13,
723 testSimplifySkinnyTriangle12,
724 testSimplifySkinnyTriangle11,
caryclark@google.com752b60e2012-03-22 21:11:17 +0000725 testSimplifySkinnyTriangle10,
726 testSimplifySkinnyTriangle9,
727 testSimplifySkinnyTriangle8,
728 testSimplifySkinnyTriangle7,
729 testSimplifySkinnyTriangle6,
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000730 testSimplifySkinnyTriangle5,
731 testSimplifySkinnyTriangle4,
732 testSimplifySkinnyTriangle3,
733 testSimplifySkinnyTriangle2,
734 testSimplifySkinnyTriangle1,
735 testSimplifyTriangle24,
736 testSimplifyTriangle23,
737 testSimplifyTriangle22,
caryclark@google.com4917f172012-03-05 22:01:21 +0000738 testSimplifyDegenerateTriangle2,
739 testSimplifyDegenerateTriangle1,
740 testSimplifyTriangle21,
741 testSimplifyTriangle20,
742 testSimplifyTriangle19,
743 testSimplifyTriangle18,
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000744 testSimplifyTriangle17,
745 testSimplifyTriangle16,
746 testSimplifyTriangle15,
747 testSimplifyTriangle14,
748 testSimplifyTriangle13,
749 testSimplifyTriangle12,
750 testSimplifyTriangle11,
751 testSimplifyTriangle10,
752 testSimplifyTriangle7,
753 testSimplifyTriangle9,
754 testSimplifyTriangle8,
755 testSimplifyTriangle6,
756 testSimplifyTriangle5,
757 testSimplifyTriangle4,
758 testSimplifyTriangle3,
759 testSimplifyTriangle,
760 testSimplifyTriangle2,
761 testSimplifyWindingParallelogram,
762 testSimplifyXorParallelogram,
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000763 testPathTriangleRendering,
764};
765
766static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]);
767
caryclark@google.com752b60e2012-03-22 21:11:17 +0000768static void (*firstTest)() = 0;
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000769
770void SimplifyPolygonPaths_Test() {
771 size_t index = 0;
772 if (firstTest) {
773 while (index < simplifyTestsCount && simplifyTests[index] != firstTest) {
774 ++index;
775 }
776 }
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000777 bool firstTestComplete = false;
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000778 for ( ; index < simplifyTestsCount; ++index) {
779 (*simplifyTests[index])();
caryclark@google.com752b60e2012-03-22 21:11:17 +0000780 if (simplifyTests[index] == testSimplifySkinnyTriangle2) {
781 SkDebugf("%s last fast skinny test\n", __FUNCTION__);
782 }
caryclark@google.com2e7f4c82012-03-20 21:11:59 +0000783 firstTestComplete = true;
caryclark@google.comcd4421d2012-03-01 19:16:31 +0000784 }
785}
786