blob: b70865274a25294747a46b2d9defedefcf1480f4 [file] [log] [blame]
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001/*
2 * Copyright 2012 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
caryclark@google.comaf46cff2012-05-22 21:12:00 +00008#include "EdgeWalker_Test.h"
9#include "Intersection_Tests.h"
caryclark@google.com8dcf1142012-07-02 20:27:02 +000010#include "ShapeOps.h"
caryclark@google.comaf46cff2012-05-22 21:12:00 +000011
caryclark@google.com47580692012-07-23 12:14:49 +000012#define TEST(name) { name, #name }
13
caryclark@google.comaf46cff2012-05-22 21:12:00 +000014static void testLine1() {
caryclark@google.com59823f72012-08-09 18:17:47 +000015 SkPath path;
caryclark@google.comaf46cff2012-05-22 21:12:00 +000016 path.moveTo(2,0);
17 path.lineTo(1,1);
18 path.lineTo(0,0);
19 path.close();
caryclark@google.com88f7d0c2012-06-07 21:09:20 +000020 testSimplifyx(path);
caryclark@google.comaf46cff2012-05-22 21:12:00 +000021}
22
23static void addInnerCWTriangle(SkPath& path) {
24 path.moveTo(3,0);
25 path.lineTo(4,1);
26 path.lineTo(2,1);
27 path.close();
28}
29
30static void addInnerCCWTriangle(SkPath& path) {
31 path.moveTo(3,0);
32 path.lineTo(2,1);
33 path.lineTo(4,1);
34 path.close();
35}
36
37static void addOuterCWTriangle(SkPath& path) {
38 path.moveTo(3,0);
39 path.lineTo(6,2);
40 path.lineTo(0,2);
41 path.close();
42}
43
44static void addOuterCCWTriangle(SkPath& path) {
45 path.moveTo(3,0);
46 path.lineTo(0,2);
47 path.lineTo(6,2);
48 path.close();
49}
50
51static void testLine2() {
caryclark@google.com59823f72012-08-09 18:17:47 +000052 SkPath path;
caryclark@google.comaf46cff2012-05-22 21:12:00 +000053 addInnerCWTriangle(path);
54 addOuterCWTriangle(path);
caryclark@google.com88f7d0c2012-06-07 21:09:20 +000055 testSimplifyx(path);
caryclark@google.comaf46cff2012-05-22 21:12:00 +000056}
57
caryclark@google.com495f8e42012-05-31 13:13:11 +000058static void testLine3() {
caryclark@google.com59823f72012-08-09 18:17:47 +000059 SkPath path;
caryclark@google.com495f8e42012-05-31 13:13:11 +000060 addInnerCCWTriangle(path);
61 addOuterCWTriangle(path);
caryclark@google.com88f7d0c2012-06-07 21:09:20 +000062 testSimplifyx(path);
caryclark@google.com495f8e42012-05-31 13:13:11 +000063}
64
caryclark@google.com534aa5b2012-08-02 20:08:21 +000065static void testLine3a() {
caryclark@google.com59823f72012-08-09 18:17:47 +000066 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +000067 addInnerCWTriangle(path);
68 addOuterCCWTriangle(path);
69 testSimplifyx(path);
70}
71
72static void testLine3b() {
caryclark@google.com59823f72012-08-09 18:17:47 +000073 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +000074 addInnerCCWTriangle(path);
75 addOuterCCWTriangle(path);
76 testSimplifyx(path);
77}
78
caryclark@google.com495f8e42012-05-31 13:13:11 +000079static void testLine4() {
caryclark@google.com59823f72012-08-09 18:17:47 +000080 SkPath path;
caryclark@google.com495f8e42012-05-31 13:13:11 +000081 addOuterCCWTriangle(path);
82 addOuterCWTriangle(path);
caryclark@google.com88f7d0c2012-06-07 21:09:20 +000083 testSimplifyx(path);
caryclark@google.com495f8e42012-05-31 13:13:11 +000084}
85
86static void testLine5() {
caryclark@google.com59823f72012-08-09 18:17:47 +000087 SkPath path;
caryclark@google.com495f8e42012-05-31 13:13:11 +000088 addOuterCWTriangle(path);
89 addOuterCWTriangle(path);
caryclark@google.com88f7d0c2012-06-07 21:09:20 +000090 testSimplifyx(path);
caryclark@google.com495f8e42012-05-31 13:13:11 +000091}
caryclark@google.comaf46cff2012-05-22 21:12:00 +000092
caryclark@google.com88f7d0c2012-06-07 21:09:20 +000093static void testLine6() {
caryclark@google.com59823f72012-08-09 18:17:47 +000094 SkPath path;
caryclark@google.com88f7d0c2012-06-07 21:09:20 +000095 path.moveTo(0,0);
96 path.lineTo(4,0);
97 path.lineTo(2,2);
98 path.close();
99 path.moveTo(2,0);
100 path.lineTo(6,0);
101 path.lineTo(4,2);
102 path.close();
103 testSimplifyx(path);
104}
105
106static void testLine7() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000107 SkPath path;
caryclark@google.com88f7d0c2012-06-07 21:09:20 +0000108 path.moveTo(0,0);
109 path.lineTo(4,0);
110 path.lineTo(2,2);
111 path.close();
112 path.moveTo(6,0);
113 path.lineTo(2,0);
114 path.lineTo(4,2);
115 path.close();
116 testSimplifyx(path);
117}
118
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000119static void testLine7a() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000120 SkPath path;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000121 path.moveTo(0,0);
122 path.lineTo(4,0);
123 path.lineTo(2,2);
124 path.close();
125 testSimplifyx(path);
126}
127
128static void testLine7b() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000129 SkPath path;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000130 path.moveTo(0,0);
131 path.lineTo(4,0);
132 path.close();
133 path.moveTo(6,0);
134 path.lineTo(2,0);
135 path.lineTo(4,2);
136 path.close();
137 testSimplifyx(path);
138}
139
caryclark@google.com88f7d0c2012-06-07 21:09:20 +0000140static void testLine8() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000141 SkPath path;
caryclark@google.com88f7d0c2012-06-07 21:09:20 +0000142 path.moveTo(0,4);
143 path.lineTo(4,4);
144 path.lineTo(2,2);
145 path.close();
146 path.moveTo(2,4);
147 path.lineTo(6,4);
148 path.lineTo(4,2);
149 path.close();
150 testSimplifyx(path);
151}
152
153static void testLine9() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000154 SkPath path;
caryclark@google.com88f7d0c2012-06-07 21:09:20 +0000155 path.moveTo(0,4);
156 path.lineTo(4,4);
157 path.lineTo(2,2);
158 path.close();
159 path.moveTo(6,4);
160 path.lineTo(2,4);
161 path.lineTo(4,2);
162 path.close();
163 testSimplifyx(path);
164}
165
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000166static void testLine10() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000167 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000168 path.moveTo(0,4);
169 path.lineTo(4,4);
170 path.lineTo(2,2);
171 path.close();
172 path.moveTo(2,1);
173 path.lineTo(3,4);
174 path.lineTo(6,1);
175 path.close();
176 testSimplifyx(path);
177}
caryclark@google.com88f7d0c2012-06-07 21:09:20 +0000178
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000179static void testLine10a() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000180 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000181 path.moveTo(0,4);
182 path.lineTo(8,4);
183 path.lineTo(4,0);
184 path.close();
185 path.moveTo(2,2);
186 path.lineTo(3,3);
187 path.lineTo(4,2);
188 path.close();
189 testSimplifyx(path);
190}
191
192static void addCWContainer(SkPath& path) {
193 path.moveTo(6,4);
194 path.lineTo(0,4);
195 path.lineTo(3,1);
196 path.close();
197}
198
199static void addCCWContainer(SkPath& path) {
200 path.moveTo(0,4);
201 path.lineTo(6,4);
202 path.lineTo(3,1);
203 path.close();
204}
205
206static void addCWContents(SkPath& path) {
207 path.moveTo(2,3);
208 path.lineTo(3,2);
209 path.lineTo(4,3);
210 path.close();
211}
212
213static void addCCWContents(SkPath& path) {
214 path.moveTo(3,2);
215 path.lineTo(2,3);
216 path.lineTo(4,3);
217 path.close();
218}
219
220static void testLine11() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000221 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000222 addCWContainer(path);
223 addCWContents(path);
224 testSimplifyx(path);
225}
226
227static void testLine12() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000228 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000229 addCCWContainer(path);
230 addCWContents(path);
231 testSimplifyx(path);
232}
233
234static void testLine13() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000235 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000236 addCWContainer(path);
237 addCCWContents(path);
238 testSimplifyx(path);
239}
240
241static void testLine14() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000242 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000243 addCCWContainer(path);
244 addCCWContents(path);
245 testSimplifyx(path);
246}
247
248static void testLine15() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000249 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000250 path.addRect(0, 0, 9, 9, (SkPath::Direction) 0);
251 testSimplifyx(path);
252}
253
254static void testLine16() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000255 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000256 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
257 path.addRect(0, 4, 9, 9, (SkPath::Direction) 0);
258 testSimplifyx(path);
259}
260
261static void testLine17() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000262 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000263 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
264 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
265 testSimplifyx(path);
266}
267
268static void testLine18() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000269 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000270 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
271 path.addRect(12, 4, 21, 21, (SkPath::Direction) 0);
272 testSimplifyx(path);
273}
274
275static void testLine19() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000276 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000277 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
278 path.addRect(12, 16, 21, 21, (SkPath::Direction) 0);
279 testSimplifyx(path);
280}
281
282static void testLine20() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000283 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000284 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
285 path.addRect(0, 12, 9, 9, (SkPath::Direction) 0);
286 testSimplifyx(path);
287}
288
289static void testLine21() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000290 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000291 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
292 path.addRect(0, 16, 9, 9, (SkPath::Direction) 0);
293 testSimplifyx(path);
294}
295
296static void testLine22() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000297 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000298 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
299 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
300 testSimplifyx(path);
301}
302
303static void testLine23() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000304 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000305 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
306 path.addRect(12, 0, 21, 21, (SkPath::Direction) 0);
307 testSimplifyx(path);
308}
309
310
311
312static void testLine24a() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000313 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000314 path.moveTo(2,0);
315 path.lineTo(4,4);
316 path.lineTo(0,4);
317 path.close();
318 path.moveTo(2,0);
319 path.lineTo(1,2);
320 path.lineTo(2,2);
321 path.close();
322 testSimplifyx(path);
323}
324
325static void testLine24() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000326 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000327 path.addRect(0, 18, 12, 12, (SkPath::Direction) 0);
328 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
329 testSimplifyx(path);
330}
331
332static void testLine25() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000333 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000334 path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
335 path.addRect(12, 0, 21, 21, (SkPath::Direction) 0);
336 testSimplifyx(path);
337}
338
339static void testLine26() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000340 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000341 path.addRect(0, 18, 12, 12, (SkPath::Direction) 0);
342 path.addRect(0, 12, 9, 9, (SkPath::Direction) 0);
343 testSimplifyx(path);
344}
345
346static void testLine27() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000347 SkPath path;
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000348 path.addRect(0, 18, 12, 12, (SkPath::Direction) 0);
349 path.addRect(12, 8, 21, 21, (SkPath::Direction) 0);
350 testSimplifyx(path);
351}
352
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000353static void testLine28() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000354 SkPath path;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000355 path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
356 path.addRect(0, 0, 9, 9, (SkPath::Direction) 0);
357 testSimplifyx(path);
358}
359
360static void testLine29() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000361 SkPath path;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000362 path.addRect(0, 18, 12, 12, (SkPath::Direction) 0);
363 path.addRect(12, 12, 21, 21, (SkPath::Direction) 0);
364 testSimplifyx(path);
365}
366
367static void testLine30() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000368 SkPath path;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000369 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
370 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
371 path.addRect(4, 4, 13, 13, (SkPath::Direction) 0);
372 testSimplifyx(path);
373}
374
375static void testLine31() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000376 SkPath path;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000377 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
378 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
379 path.addRect(0, 4, 9, 9, (SkPath::Direction) 0);
380 testSimplifyx(path);
381}
382
383static void testLine32() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000384 SkPath path;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000385 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
386 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
387 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
388 testSimplifyx(path);
389}
390
caryclark@google.com210acaf2012-07-12 21:05:13 +0000391static void testLine33() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000392 SkPath path;
caryclark@google.com210acaf2012-07-12 21:05:13 +0000393 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
394 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
395 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
396 testSimplifyx(path);
397}
398
399static void testLine34() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000400 SkPath path;
caryclark@google.com210acaf2012-07-12 21:05:13 +0000401 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
402 path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
403 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
404 testSimplifyx(path);
405}
406
407static void testLine35() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000408 SkPath path;
caryclark@google.com210acaf2012-07-12 21:05:13 +0000409 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
410 path.addRect(6, 0, 18, 18, (SkPath::Direction) 0);
411 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
412 testSimplifyx(path);
413}
414
caryclark@google.com0e08a192012-07-13 21:07:52 +0000415static void testLine36() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000416 SkPath path;
caryclark@google.com0e08a192012-07-13 21:07:52 +0000417 path.addRect(0, 10, 20, 20, (SkPath::Direction) 0);
418 path.addRect(6, 12, 18, 18, (SkPath::Direction) 0);
419 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
420 testSimplifyx(path);
421}
422
caryclark@google.com47580692012-07-23 12:14:49 +0000423static void testLine37() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000424 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000425 path.addRect(0, 20, 20, 20, (SkPath::Direction) 0);
426 path.addRect(18, 24, 30, 30, (SkPath::Direction) 0);
427 path.addRect(0, 0, 9, 9, (SkPath::Direction) 0);
428 testSimplifyx(path);
429}
430
431static void testLine38() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000432 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000433 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
434 path.addRect(6, 12, 18, 18, (SkPath::Direction) 0);
435 path.addRect(12, 12, 21, 21, (SkPath::Direction) 0);
436 testSimplifyx(path);
437}
438
439static void testLine40() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000440 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000441 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
442 path.addRect(12, 18, 24, 24, (SkPath::Direction) 0);
443 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
444 testSimplifyx(path);
445}
446
447static void testLine41() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000448 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000449 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
450 path.addRect(18, 24, 30, 30, (SkPath::Direction) 0);
451 path.addRect(12, 0, 21, 21, (SkPath::Direction) 0);
452 testSimplifyx(path);
453}
454
455static void testLine42() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000456 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000457 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
458 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
459 path.addRect(8, 16, 17, 17, (SkPath::Direction) 0);
460 testSimplifyx(path);
461}
462
463static void testLine43() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000464 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000465 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
466 path.addRect(6, 24, 18, 18, (SkPath::Direction) 0);
467 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
468 testSimplifyx(path);
469}
470
471static void testLine44() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000472 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000473 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
474 path.addRect(18, 0, 30, 30, (SkPath::Direction) 0);
475 path.addRect(18, 32, 27, 36, (SkPath::Direction) 1);
476 testSimplifyx(path);
477}
478
479static void testLine45() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000480 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000481 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
482 path.addRect(18, 0, 30, 30, (SkPath::Direction) 0);
483 path.addRect(24, 32, 33, 36, (SkPath::Direction) 0);
484 testSimplifyx(path);
485}
486
487static void testLine46() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000488 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000489 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
490 path.addRect(24, 0, 36, 36, (SkPath::Direction) 0);
491 path.addRect(24, 32, 33, 36, (SkPath::Direction) 0);
492 testSimplifyx(path);
493}
494
495static void testLine47() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000496 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000497 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
498 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
499 path.addRect(0, 0, 9, 9, (SkPath::Direction) 1);
500 testSimplifyx(path);
501}
502
503static void testLine48() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000504 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000505 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
506 path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
507 path.addRect(0, 0, 9, 9, (SkPath::Direction) 1);
508 testSimplifyx(path);
509}
510
511static void testLine49() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000512 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000513 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
514 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
515 path.addRect(0, 0, 9, 9, (SkPath::Direction) 0);
516 testSimplifyx(path);
517}
518
519static void testLine50() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000520 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000521 path.addRect(10, 30, 30, 30, (SkPath::Direction) 0);
522 path.addRect(24, 20, 36, 30, (SkPath::Direction) 0);
523 testSimplifyx(path);
524}
525
526
527static void testLine51() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000528 SkPath path;
caryclark@google.com47580692012-07-23 12:14:49 +0000529 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
530 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
531 path.addRect(4, 12, 13, 13, (SkPath::Direction) 1);
532 testSimplifyx(path);
533}
534
caryclark@google.come21cb182012-07-23 21:26:31 +0000535static void testLine52() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000536 SkPath path;
caryclark@google.come21cb182012-07-23 21:26:31 +0000537 path.addRect(0, 30, 20, 20, (SkPath::Direction) 0);
538 path.addRect(6, 20, 18, 30, (SkPath::Direction) 0);
539 path.addRect(32, 0, 36, 41, (SkPath::Direction) 0);
540 testSimplifyx(path);
541}
542
543static void testLine53() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000544 SkPath path;
caryclark@google.come21cb182012-07-23 21:26:31 +0000545 path.addRect(10, 30, 30, 30, (SkPath::Direction) 0);
546 path.addRect(12, 20, 24, 30, (SkPath::Direction) 0);
547 path.addRect(12, 32, 21, 36, (SkPath::Direction) 1);
548 testSimplifyx(path);
549}
550
551static void testLine54() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000552 SkPath path;
caryclark@google.come21cb182012-07-23 21:26:31 +0000553 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
554 path.addRect(6, 0, 18, 18, (SkPath::Direction) 0);
555 path.addRect(8, 4, 17, 17, (SkPath::Direction) 1);
556 testSimplifyx(path);
557}
558
559static void testLine55() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000560 SkPath path;
caryclark@google.come21cb182012-07-23 21:26:31 +0000561 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
562 path.addRect(6, 6, 18, 18, (SkPath::Direction) 0);
563 path.addRect(4, 4, 13, 13, (SkPath::Direction) 1);
564 testSimplifyx(path);
565}
566
caryclark@google.com18063442012-07-25 12:05:18 +0000567static void testLine56() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000568 SkPath path;
caryclark@google.com18063442012-07-25 12:05:18 +0000569 path.addRect(0, 20, 20, 20, (SkPath::Direction) 0);
570 path.addRect(18, 20, 30, 30, (SkPath::Direction) 0);
571 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
572 testSimplifyx(path);
573}
574
575static void testLine57() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000576 SkPath path;
caryclark@google.com18063442012-07-25 12:05:18 +0000577 path.addRect(20, 0, 40, 40, (SkPath::Direction) 0);
578 path.addRect(20, 0, 30, 40, (SkPath::Direction) 0);
579 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
580 testSimplifyx(path);
581}
582
caryclark@google.comcc905052012-07-25 20:59:42 +0000583static void testLine58() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000584 SkPath path;
caryclark@google.comcc905052012-07-25 20:59:42 +0000585 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
586 path.addRect(0, 0, 12, 12, (SkPath::Direction) 1);
587 path.addRect(0, 12, 9, 9, (SkPath::Direction) 1);
588 testSimplifyx(path);
589}
590
591static void testLine59() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000592 SkPath path;
caryclark@google.comcc905052012-07-25 20:59:42 +0000593 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
594 path.addRect(6, 6, 18, 18, (SkPath::Direction) 1);
595 path.addRect(4, 4, 13, 13, (SkPath::Direction) 1);
596 testSimplifyx(path);
597}
598
caryclark@google.com27c449a2012-07-27 18:26:38 +0000599static void testLine60() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000600 SkPath path;
caryclark@google.com27c449a2012-07-27 18:26:38 +0000601 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
602 path.addRect(6, 12, 18, 18, (SkPath::Direction) 1);
603 path.addRect(4, 12, 13, 13, (SkPath::Direction) 1);
604 testSimplifyx(path);
605}
606
607static void testLine61() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000608 SkPath path;
caryclark@google.com27c449a2012-07-27 18:26:38 +0000609 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
610 path.addRect(12, 0, 24, 24, (SkPath::Direction) 1);
611 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
612 testSimplifyx(path);
613}
614
615static void testLine62() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000616 SkPath path;
caryclark@google.com27c449a2012-07-27 18:26:38 +0000617 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
618 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
619 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
620 path.addRect(4, 12, 13, 13, (SkPath::Direction) 1);
621 testSimplifyx(path);
622}
623
624static void testLine63() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000625 SkPath path;
caryclark@google.com27c449a2012-07-27 18:26:38 +0000626 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
627 path.addRect(0, 10, 20, 20, (SkPath::Direction) 0);
628 path.addRect(0, 6, 12, 12, (SkPath::Direction) 1);
629 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
630 testSimplifyx(path);
631}
632
633static void testLine64() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000634 SkPath path;
caryclark@google.com27c449a2012-07-27 18:26:38 +0000635 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
636 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
637 path.addRect(18, 6, 30, 30, (SkPath::Direction) 0);
638 testSimplifyx(path);
639}
640
641static void testLine65() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000642 SkPath path;
caryclark@google.com27c449a2012-07-27 18:26:38 +0000643 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
644 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
645 path.addRect(24, 0, 36, 36, (SkPath::Direction) 0);
646 path.addRect(32, 6, 36, 41, (SkPath::Direction) 1);
647 testSimplifyx(path);
648}
649
650static void testLine66() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000651 SkPath path;
caryclark@google.com27c449a2012-07-27 18:26:38 +0000652 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
653 path.addRect(0, 30, 20, 20, (SkPath::Direction) 0);
654 path.addRect(12, 20, 24, 30, (SkPath::Direction) 0);
655 testSimplifyx(path);
656}
657
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000658static void testLine67() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000659 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000660 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
661 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
662 path.addRect(24, 20, 36, 30, (SkPath::Direction) 0);
663 path.addRect(32, 0, 36, 41, (SkPath::Direction) 0);
664 testSimplifyx(path);
665}
666
667static void testLine68a() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000668 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000669 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
670 path.addRect(2, 2, 6, 6, (SkPath::Direction) 0);
671 path.addRect(1, 2, 4, 2, (SkPath::Direction) 0);
672 testSimplifyx(path);
673}
674
675static void testLine68b() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000676 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000677 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
678 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
679 path.addRect(1, 2, 2, 2, (SkPath::Direction) 0);
680 testSimplifyx(path);
681}
682
683static void testLine68c() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000684 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000685 path.addRect(0, 0, 8, 8, (SkPath::Direction) 1);
686 path.addRect(2, 2, 6, 6, (SkPath::Direction) 0);
687 path.addRect(1, 2, 4, 2, (SkPath::Direction) 0);
688 testSimplifyx(path);
689}
690
691static void testLine68d() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000692 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000693 path.addRect(0, 0, 8, 8, (SkPath::Direction) 1);
694 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
695 path.addRect(1, 2, 4, 2, (SkPath::Direction) 0);
696 testSimplifyx(path);
697}
698
699static void testLine68e() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000700 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000701 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
702 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
703 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
704 path.addRect(1, 2, 2, 2, (SkPath::Direction) 0);
705 testSimplifyx(path);
706}
707
708static void testLine68f() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000709 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000710 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
711 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
712 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
713 path.addRect(1, 2, 2, 2, (SkPath::Direction) 0);
714 testSimplifyx(path);
715}
716
717static void testLine68g() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000718 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000719 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
720 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
721 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
722 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
723 path.addRect(1, 2, 2, 2, (SkPath::Direction) 0);
724 testSimplifyx(path);
725}
726
727static void testLine68h() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000728 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000729 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
730 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
731 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
732 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
733 path.addRect(1, 2, 2, 2, (SkPath::Direction) 0);
734 testSimplifyx(path);
735}
736
737static void testLine69() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000738 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000739 path.addRect(0, 20, 20, 20, (SkPath::Direction) 0);
740 path.addRect(0, 20, 12, 30, (SkPath::Direction) 0);
741 path.addRect(12, 32, 21, 36, (SkPath::Direction) 0);
742 testSimplifyx(path);
743}
744
745static void testLine70() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000746 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000747 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
748 path.addRect(0, 24, 12, 12, (SkPath::Direction) 0);
749 path.addRect(12, 32, 21, 36, (SkPath::Direction) 1);
750 testSimplifyx(path);
751}
752
753static void testLine71() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000754 SkPath path;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000755 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
756 path.addRect(12, 0, 24, 24, (SkPath::Direction) 0);
757 path.addRect(12, 32, 21, 36, (SkPath::Direction) 0);
758 testSimplifyx(path);
759}
760
caryclark@google.com200c2112012-08-03 15:05:04 +0000761static void testLine72() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000762 SkPath path;
caryclark@google.com200c2112012-08-03 15:05:04 +0000763 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
764 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
765 path.addRect(6, 20, 18, 30, (SkPath::Direction) 0);
766 testSimplifyx(path);
767}
768
769static void testLine73() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000770 SkPath path;
caryclark@google.com200c2112012-08-03 15:05:04 +0000771 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
772 path.addRect(0, 40, 20, 20, (SkPath::Direction) 0);
773 path.addRect(0, 20, 12, 30, (SkPath::Direction) 0);
774 path.addRect(0, 0, 9, 9, (SkPath::Direction) 1);
775 testSimplifyx(path);
776}
777
caryclark@google.com0c803d02012-08-06 11:15:47 +0000778static void testLine74() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000779 SkPath path;
caryclark@google.com0c803d02012-08-06 11:15:47 +0000780 path.addRect(20, 30, 40, 40, (SkPath::Direction) 0);
781 path.addRect(24, 20, 36, 30, (SkPath::Direction) 1);
782 path.addRect(32, 24, 36, 41, (SkPath::Direction) 1);
783 testSimplifyx(path);
784}
785
caryclark@google.com2ddff932012-08-07 21:25:27 +0000786static void testLine75() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000787 SkPath path;
caryclark@google.com2ddff932012-08-07 21:25:27 +0000788 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
789 path.addRect(10, 0, 30, 30, (SkPath::Direction) 1);
790 path.addRect(18, 0, 30, 30, (SkPath::Direction) 1);
791 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
792 testSimplifyx(path);
793}
794
795static void testLine76() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000796 SkPath path;
caryclark@google.com2ddff932012-08-07 21:25:27 +0000797 path.addRect(36, 0, 66, 60, (SkPath::Direction) 0);
798 path.addRect(10, 20, 40, 30, (SkPath::Direction) 0);
799 path.addRect(24, 20, 36, 30, (SkPath::Direction) 1);
800 path.addRect(32, 6, 36, 41, (SkPath::Direction) 1);
801 testSimplifyx(path);
802}
803
804static void testLine77() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000805 SkPath path;
caryclark@google.com2ddff932012-08-07 21:25:27 +0000806 path.addRect(20, 0, 40, 40, (SkPath::Direction) 0);
807 path.addRect(24, 6, 36, 36, (SkPath::Direction) 1);
808 path.addRect(24, 32, 33, 36, (SkPath::Direction) 1);
809 testSimplifyx(path);
810}
811
812static void testLine78() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000813 SkPath path;
caryclark@google.com2ddff932012-08-07 21:25:27 +0000814 path.addRect(0, 0, 30, 60, (SkPath::Direction) 0);
815 path.addRect(10, 20, 30, 30, (SkPath::Direction) 1);
816 path.addRect(18, 20, 30, 30, (SkPath::Direction) 1);
817 path.addRect(32, 0, 36, 41, (SkPath::Direction) 1);
818 testSimplifyx(path);
819}
820
821static void testLine79() {
caryclark@google.com59823f72012-08-09 18:17:47 +0000822 SkPath path;
caryclark@google.com2ddff932012-08-07 21:25:27 +0000823 path.addRect(0, 36, 60, 30, (SkPath::Direction) 0);
824 path.addRect(10, 30, 40, 30, (SkPath::Direction) 0);
825 path.addRect(0, 20, 12, 30, (SkPath::Direction) 1);
826 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
827 testSimplifyx(path);
828}
829
caryclark@google.com59823f72012-08-09 18:17:47 +0000830static void testDegenerate1() {
831 SkPath path;
832 path.moveTo(0, 0);
833 path.lineTo(0, 0);
834 path.lineTo(2, 0);
835 path.close();
836 path.moveTo(0, 0);
837 path.lineTo(1, 0);
838 path.lineTo(2, 0);
839 path.close();
840 testSimplifyx(path);
841}
842
843static void testDegenerate2() {
844 SkPath path;
845 path.moveTo(0, 0);
846 path.lineTo(0, 0);
847 path.lineTo(0, 0);
848 path.close();
849 path.moveTo(0, 0);
850 path.lineTo(1, 0);
851 path.lineTo(0, 1);
852 path.close();
853 testSimplifyx(path);
854}
855
856static void testDegenerate3() {
857 SkPath path;
858 path.moveTo(0, 0);
859 path.lineTo(2, 0);
860 path.lineTo(1, 0);
861 path.close();
862 path.moveTo(0, 0);
863 path.lineTo(0, 0);
864 path.lineTo(3, 0);
865 path.close();
866 testSimplifyx(path);
867}
868
869static void testDegenerate4() {
870 SkPath path;
871 path.moveTo(0, 0);
872 path.lineTo(1, 0);
873 path.lineTo(1, 3);
874 path.close();
875 path.moveTo(1, 0);
876 path.lineTo(1, 1);
877 path.lineTo(1, 2);
878 path.close();
879 testSimplifyx(path);
880}
881
882static void testNondegenerate1() {
883 SkPath path;
884 path.moveTo(0, 0);
885 path.lineTo(3, 0);
886 path.lineTo(1, 3);
887 path.close();
888 path.moveTo(1, 1);
889 path.lineTo(2, 1);
890 path.lineTo(1, 2);
891 path.close();
892 testSimplifyx(path);
893}
894
895static void testNondegenerate2() {
896 SkPath path;
897 path.moveTo(1, 0);
898 path.lineTo(0, 1);
899 path.lineTo(1, 1);
900 path.close();
901 path.moveTo(0, 2);
902 path.lineTo(0, 3);
903 path.lineTo(1, 2);
904 path.close();
905 testSimplifyx(path);
906}
907
908static void testNondegenerate3() {
909 SkPath path;
910 path.moveTo(0, 0);
911 path.lineTo(1, 0);
912 path.lineTo(2, 1);
913 path.close();
914 path.moveTo(0, 1);
915 path.lineTo(1, 1);
916 path.lineTo(0, 2);
917 path.close();
918 testSimplifyx(path);
919}
920
921static void testNondegenerate4() {
922 SkPath path;
923 path.moveTo(1, 0);
924 path.lineTo(0, 1);
925 path.lineTo(1, 2);
926 path.close();
927 path.moveTo(0, 2);
928 path.lineTo(0, 3);
929 path.lineTo(1, 3);
930 path.close();
931 testSimplifyx(path);
932}
933
934static void testQuadralateral5() {
935 SkPath path;
936 path.moveTo(0, 0);
937 path.lineTo(0, 0);
938 path.lineTo(1, 0);
939 path.lineTo(1, 1);
940 path.close();
941 path.moveTo(0, 0);
942 path.lineTo(2, 2);
943 path.lineTo(3, 2);
944 path.lineTo(3, 3);
945 path.close();
946 testSimplifyx(path);
947}
948
949static void testQuadralateral6() {
950 SkPath path;
951 path.moveTo(0, 0);
952 path.lineTo(0, 0);
953 path.lineTo(1, 0);
954 path.lineTo(1, 1);
955 path.close();
956 path.moveTo(1, 0);
957 path.lineTo(2, 0);
958 path.lineTo(0, 2);
959 path.lineTo(2, 2);
960 path.close();
961 testSimplifyx(path);
962}
963
caryclark@google.com24bec792012-08-20 12:43:57 +0000964static void testFauxQuadralateral6() {
965 SkPath path;
966 path.moveTo(0, 0);
967 path.lineTo(1, 0);
968 path.lineTo(1, 1);
969 path.close();
970 path.moveTo(1, 0);
971 path.lineTo(2, 0);
972 path.lineTo(1 + 1.0f/3, 2.0f/3);
973 path.close();
974 path.moveTo(1 + 1.0f/3, 2.0f/3);
975 path.lineTo(0, 2);
976 path.lineTo(2, 2);
977 path.close();
978 testSimplifyx(path);
979}
980
981static void testFauxQuadralateral6a() {
982 SkPath path;
983 path.moveTo(0, 0);
984 path.lineTo(3, 0);
985 path.lineTo(3, 3);
986 path.close();
987 path.moveTo(3, 0);
988 path.lineTo(6, 0);
989 path.lineTo(4, 2);
990 path.close();
991 path.moveTo(4, 2);
992 path.lineTo(0, 6);
993 path.lineTo(6, 6);
994 path.close();
995 testSimplifyx(path);
996}
997
998static void testFauxQuadralateral6b() {
999 SkPath path;
1000 path.moveTo(0, 0);
1001 path.lineTo(3, 0);
1002 path.lineTo(3, 3);
1003 path.close();
1004 path.moveTo(3, 0);
1005 path.lineTo(6, 0);
1006 path.lineTo(4, 2);
1007 path.close();
1008 path.moveTo(4, 2);
1009 path.lineTo(6, 6);
1010 path.lineTo(0, 6);
1011 path.close();
1012 testSimplifyx(path);
1013}
1014
1015static void testFauxQuadralateral6c() {
1016 SkPath path;
1017 path.moveTo(0, 0);
1018 path.lineTo(3, 3);
1019 path.lineTo(3, 0);
1020 path.close();
1021 path.moveTo(3, 0);
1022 path.lineTo(6, 0);
1023 path.lineTo(4, 2);
1024 path.close();
1025 path.moveTo(4, 2);
1026 path.lineTo(0, 6);
1027 path.lineTo(6, 6);
1028 path.close();
1029 testSimplifyx(path);
1030}
1031
1032static void testFauxQuadralateral6d() {
1033 SkPath path;
1034 path.moveTo(0, 0);
1035 path.lineTo(3, 3);
1036 path.lineTo(3, 0);
1037 path.close();
1038 path.moveTo(3, 0);
1039 path.lineTo(6, 0);
1040 path.lineTo(4, 2);
1041 path.close();
1042 path.moveTo(4, 2);
1043 path.lineTo(6, 6);
1044 path.lineTo(0, 6);
1045 path.close();
1046 testSimplifyx(path);
1047}
1048
1049static void testQuadralateral6a() {
1050 SkPath path;
1051 path.moveTo(0, 0);
1052 path.lineTo(0, 0);
1053 path.lineTo(3, 0);
1054 path.lineTo(3, 3);
1055 path.close();
1056 path.moveTo(3, 0);
1057 path.lineTo(6, 0);
1058 path.lineTo(0, 6);
1059 path.lineTo(6, 6);
1060 path.close();
1061 testSimplifyx(path);
1062}
1063
1064static void testQuadralateral7() {
1065 SkPath path;
1066 path.moveTo(0, 0);
1067 path.lineTo(0, 0);
1068 path.lineTo(1, 0);
1069 path.lineTo(2, 1);
1070 path.close();
1071 path.moveTo(1, 0);
1072 path.lineTo(1, 1);
1073 path.lineTo(2, 2);
1074 path.lineTo(1, 3);
1075 path.close();
1076 testSimplifyx(path);
1077}
1078
1079static void testQuadralateral8() {
1080 SkPath path;
1081 path.moveTo(0, 0);
1082 path.lineTo(3, 1);
1083 path.lineTo(1, 3);
1084 path.lineTo(3, 3);
1085 path.close();
1086 path.moveTo(2, 1);
1087 path.lineTo(0, 2);
1088 path.lineTo(3, 2);
1089 path.lineTo(2, 3);
1090 path.close();
1091 testSimplifyx(path);
1092}
1093
1094static void testQuadralateral9() {
1095 SkPath path;
1096 path.moveTo(0, 0);
1097 path.lineTo(1, 0);
1098 path.lineTo(1, 2);
1099 path.lineTo(2, 2);
1100 path.close();
1101 path.moveTo(1, 1);
1102 path.lineTo(2, 1);
1103 path.lineTo(1, 3);
1104 path.lineTo(2, 3);
1105 path.close();
1106 testSimplifyx(path);
1107}
1108
1109static void testLine1x() {
1110 SkPath path;
1111 path.setFillType(SkPath::kEvenOdd_FillType);
1112 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
1113 path.addRect(4, 0, 13, 13, (SkPath::Direction) 0);
1114 testSimplifyx(path);
1115}
1116
1117static void testLine2x() {
1118 SkPath path;
1119 path.setFillType(SkPath::kEvenOdd_FillType);
1120 path.addRect(0, 20, 20, 20, (SkPath::Direction) 0);
1121 path.addRect(0, 20, 12, 30, (SkPath::Direction) 0);
1122 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
1123 testSimplifyx(path);
1124}
1125
1126static void testLine3x() {
1127 SkPath path;
1128 path.setFillType(SkPath::kEvenOdd_FillType);
1129 path.addRect(10, 30, 30, 30, (SkPath::Direction) 0);
1130 path.addRect(18, 20, 30, 30, (SkPath::Direction) 1);
1131 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
1132 testSimplifyx(path);
1133}
1134
1135static void testLine4x() {
1136 SkPath path;
1137 path.setFillType(SkPath::kEvenOdd_FillType);
1138 path.addRect(10, 30, 30, 30, (SkPath::Direction) 0);
1139 path.addRect(24, 20, 36, 30, (SkPath::Direction) 1);
1140 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
1141 testSimplifyx(path);
1142}
1143
1144static void testQuadratic1() {
1145 SkPath path;
1146 path.moveTo(0, 0);
1147 path.quadTo(0, 0, 0, 0);
1148 path.lineTo(1, 0);
1149 path.close();
1150 path.moveTo(0, 0);
1151 path.lineTo(0, 0);
1152 path.quadTo(0, 0, 0, 0);
1153 path.close();
1154 testSimplifyx(path);
1155}
1156
1157static void testQuadratic2() {
1158 SkPath path;
1159 path.moveTo(0, 0);
1160 path.quadTo(0, 0, 0, 0);
1161 path.lineTo(3, 0);
1162 path.close();
1163 path.moveTo(0, 0);
1164 path.lineTo(0, 0);
1165 path.quadTo(1, 0, 0, 1);
1166 path.close();
1167 testSimplifyx(path);
1168}
1169
1170static void (*firstTest)() = testQuadratic2;
caryclark@google.com8dcf1142012-07-02 20:27:02 +00001171
1172static struct {
1173 void (*fun)();
1174 const char* str;
1175} tests[] = {
caryclark@google.com24bec792012-08-20 12:43:57 +00001176 TEST(testQuadratic2),
1177 TEST(testQuadratic1),
1178 TEST(testLine4x),
1179 TEST(testLine3x),
1180 TEST(testLine2x),
1181 TEST(testLine1x),
1182 TEST(testQuadralateral9),
1183 TEST(testQuadralateral8),
1184 TEST(testQuadralateral7),
caryclark@google.com59823f72012-08-09 18:17:47 +00001185 TEST(testQuadralateral6),
caryclark@google.com24bec792012-08-20 12:43:57 +00001186 TEST(testQuadralateral6a),
1187 TEST(testFauxQuadralateral6d),
1188 TEST(testFauxQuadralateral6c),
1189 TEST(testFauxQuadralateral6b),
1190 TEST(testFauxQuadralateral6a),
1191 TEST(testFauxQuadralateral6),
caryclark@google.com59823f72012-08-09 18:17:47 +00001192 TEST(testQuadralateral5),
1193 TEST(testNondegenerate4),
1194 TEST(testNondegenerate3),
1195 TEST(testNondegenerate2),
1196 TEST(testNondegenerate1),
1197 TEST(testDegenerate4),
1198 TEST(testDegenerate3),
1199 TEST(testDegenerate2),
1200 TEST(testDegenerate1),
caryclark@google.com2ddff932012-08-07 21:25:27 +00001201 TEST(testLine79),
1202 TEST(testLine78),
1203 TEST(testLine77),
1204 TEST(testLine76),
1205 TEST(testLine75),
caryclark@google.com0c803d02012-08-06 11:15:47 +00001206 TEST(testLine74),
caryclark@google.com200c2112012-08-03 15:05:04 +00001207 TEST(testLine73),
1208 TEST(testLine72),
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001209 TEST(testLine71),
1210 TEST(testLine70),
1211 TEST(testLine69),
1212 TEST(testLine68h),
1213 TEST(testLine68g),
1214 TEST(testLine68f),
1215 TEST(testLine68e),
1216 TEST(testLine68d),
1217 TEST(testLine68c),
1218 TEST(testLine68b),
1219 TEST(testLine68a),
1220 TEST(testLine67),
caryclark@google.com27c449a2012-07-27 18:26:38 +00001221 TEST(testLine66),
1222 TEST(testLine65),
1223 TEST(testLine64),
1224 TEST(testLine63),
1225 TEST(testLine62),
1226 TEST(testLine61),
1227 TEST(testLine60),
caryclark@google.comcc905052012-07-25 20:59:42 +00001228 TEST(testLine59),
1229 TEST(testLine58),
caryclark@google.com18063442012-07-25 12:05:18 +00001230 TEST(testLine57),
1231 TEST(testLine56),
caryclark@google.come21cb182012-07-23 21:26:31 +00001232 TEST(testLine55),
1233 TEST(testLine54),
1234 TEST(testLine53),
1235 TEST(testLine52),
caryclark@google.com47580692012-07-23 12:14:49 +00001236 TEST(testLine51),
1237 TEST(testLine50),
1238 TEST(testLine49),
1239 TEST(testLine48),
1240 TEST(testLine47),
1241 TEST(testLine46),
1242 TEST(testLine45),
1243 TEST(testLine44),
1244 TEST(testLine43),
1245 TEST(testLine42),
1246 TEST(testLine41),
1247 TEST(testLine40),
1248 TEST(testLine38),
1249 TEST(testLine37),
1250 TEST(testLine36),
1251 TEST(testLine35),
1252 TEST(testLine34),
1253 TEST(testLine33),
1254 TEST(testLine32),
1255 TEST(testLine31),
1256 TEST(testLine30),
1257 TEST(testLine29),
1258 TEST(testLine28),
1259 TEST(testLine27),
1260 TEST(testLine26),
1261 TEST(testLine25),
caryclark@google.com8dcf1142012-07-02 20:27:02 +00001262 TEST(testLine24a),
1263 TEST(testLine24),
caryclark@google.com47580692012-07-23 12:14:49 +00001264 TEST(testLine23),
1265 TEST(testLine22),
1266 TEST(testLine21),
1267 TEST(testLine20),
1268 TEST(testLine19),
1269 TEST(testLine18),
1270 TEST(testLine17),
1271 TEST(testLine16),
1272 TEST(testLine15),
1273 TEST(testLine14),
1274 TEST(testLine13),
1275 TEST(testLine12),
1276 TEST(testLine11),
1277 TEST(testLine10a),
1278 TEST(testLine10),
1279 TEST(testLine9),
1280 TEST(testLine8),
1281 TEST(testLine7b),
1282 TEST(testLine7a),
1283 TEST(testLine7),
1284 TEST(testLine6),
1285 TEST(testLine5),
1286 TEST(testLine4),
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001287 TEST(testLine3b),
1288 TEST(testLine3a),
caryclark@google.com47580692012-07-23 12:14:49 +00001289 TEST(testLine3),
1290 TEST(testLine2),
1291 TEST(testLine1),
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001292};
1293
1294static const size_t testCount = sizeof(tests) / sizeof(tests[0]);
1295
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001296static struct {
1297 void (*fun)();
1298 const char* str;
1299} subTests[] = {
caryclark@google.com24bec792012-08-20 12:43:57 +00001300 TEST(testQuadralateral6),
1301 TEST(testQuadralateral6a),
1302 TEST(testFauxQuadralateral6d),
1303 TEST(testFauxQuadralateral6c),
1304 TEST(testFauxQuadralateral6b),
1305 TEST(testFauxQuadralateral6a),
1306 TEST(testFauxQuadralateral6),
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001307};
1308
1309static const size_t subTestCount = sizeof(subTests) / sizeof(subTests[0]);
1310
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001311static bool skipAll = false;
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001312static bool runSubTests = false;
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001313
1314void SimplifyNew_Test() {
1315 if (skipAll) {
1316 return;
1317 }
caryclark@google.com47580692012-07-23 12:14:49 +00001318#ifdef SK_DEBUG
caryclark@google.com27c449a2012-07-27 18:26:38 +00001319 gDebugMaxWindSum = 4;
1320 gDebugMaxWindValue = 4;
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001321 size_t index;
caryclark@google.com47580692012-07-23 12:14:49 +00001322#endif
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001323 if (runSubTests) {
1324 index = subTestCount - 1;
1325 do {
1326 SkDebugf(" %s [%s]\n", __FUNCTION__, subTests[index].str);
1327 (*subTests[index].fun)();
1328 } while (index--);
1329 }
1330 index = testCount - 1;
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001331 if (firstTest) {
caryclark@google.come21cb182012-07-23 21:26:31 +00001332 while (index > 0 && tests[index].fun != firstTest) {
1333 --index;
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001334 }
caryclark@google.com24bec792012-08-20 12:43:57 +00001335 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str);
caryclark@google.com59823f72012-08-09 18:17:47 +00001336 (*tests[index].fun)();
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001337 }
caryclark@google.com59823f72012-08-09 18:17:47 +00001338 index = testCount - 1;
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001339 bool firstTestComplete = false;
caryclark@google.come21cb182012-07-23 21:26:31 +00001340 do {
1341 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str);
caryclark@google.com8dcf1142012-07-02 20:27:02 +00001342 (*tests[index].fun)();
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001343 firstTestComplete = true;
caryclark@google.come21cb182012-07-23 21:26:31 +00001344 } while (index--);
caryclark@google.com47580692012-07-23 12:14:49 +00001345#ifdef SK_DEBUG
1346 gDebugMaxWindSum = SK_MaxS32;
1347 gDebugMaxWindValue = SK_MaxS32;
1348#endif
caryclark@google.comaf46cff2012-05-22 21:12:00 +00001349}