OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "PathOpsExtendedTest.h" | 7 #include "PathOpsExtendedTest.h" |
8 | 8 |
9 #define TEST(name) { name, #name } | 9 #define TEST(name) { name, #name } |
10 | 10 |
(...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 pathB.lineTo(1, 3); | 2058 pathB.lineTo(1, 3); |
2059 pathB.close(); | 2059 pathB.close(); |
2060 pathB.moveTo(2, 2); | 2060 pathB.moveTo(2, 2); |
2061 pathB.lineTo(3, 2); | 2061 pathB.lineTo(3, 2); |
2062 pathB.lineTo(3, 3); | 2062 pathB.lineTo(3, 3); |
2063 pathB.lineTo(2, 3); | 2063 pathB.lineTo(2, 3); |
2064 pathB.close(); | 2064 pathB.close(); |
2065 testPathOp(reporter, path, pathB, kXOR_PathOp, filename); | 2065 testPathOp(reporter, path, pathB, kXOR_PathOp, filename); |
2066 } | 2066 } |
2067 | 2067 |
| 2068 #define ISSUE_1435_FIXED 0 |
| 2069 #if ISSUE_1435_FIXED |
| 2070 // this fails to generate two interior line segments |
| 2071 // an earlier pathops succeeded, but still failed to generate one interior line
segment |
| 2072 // (but was saved by assemble, which works around a single line missing segment) |
2068 static void issue1435(skiatest::Reporter* reporter, const char* filename) { | 2073 static void issue1435(skiatest::Reporter* reporter, const char* filename) { |
2069 SkPath path1; | 2074 SkPath path1; |
2070 path1.moveTo(160, 60); | 2075 path1.moveTo(160, 60); |
2071 path1.lineTo(220, 230); | 2076 path1.lineTo(220, 230); |
2072 path1.lineTo(60, 120); | 2077 path1.lineTo(60, 120); |
2073 path1.lineTo(260, 120); | 2078 path1.lineTo(260, 120); |
2074 path1.lineTo(90, 230); | 2079 path1.lineTo(90, 230); |
2075 path1.lineTo(160, 60); | 2080 path1.lineTo(160, 60); |
2076 path1.close(); | 2081 path1.close(); |
2077 path1.setFillType(SkPath::kEvenOdd_FillType); | 2082 path1.setFillType(SkPath::kEvenOdd_FillType); |
(...skipping 30 matching lines...) Expand all Loading... |
2108 path2.moveTo(195.830978f, 161.521133f); | 2113 path2.moveTo(195.830978f, 161.521133f); |
2109 path2.lineTo(207.878281f, 153.725815f); | 2114 path2.lineTo(207.878281f, 153.725815f); |
2110 path2.quadTo(208, 151.888062f, 208, 150); | 2115 path2.quadTo(208, 151.888062f, 208, 150); |
2111 path2.quadTo(208, 132.942657f, 198.066238f, 120); | 2116 path2.quadTo(208, 132.942657f, 198.066238f, 120); |
2112 path2.lineTo(181.176468f, 120); | 2117 path2.lineTo(181.176468f, 120); |
2113 path2.lineTo(195.830978f, 161.521133f); | 2118 path2.lineTo(195.830978f, 161.521133f); |
2114 path2.close(); | 2119 path2.close(); |
2115 path2.setFillType(SkPath::kEvenOdd_FillType); | 2120 path2.setFillType(SkPath::kEvenOdd_FillType); |
2116 testPathOp(reporter, path1, path2, kIntersect_PathOp, filename); | 2121 testPathOp(reporter, path1, path2, kIntersect_PathOp, filename); |
2117 } | 2122 } |
| 2123 #endif |
2118 | 2124 |
2119 static void skpkkiste_to716(skiatest::Reporter* reporter, const char* filename)
{ | 2125 static void skpkkiste_to716(skiatest::Reporter* reporter, const char* filename)
{ |
2120 SkPath path; | 2126 SkPath path; |
2121 path.setFillType(SkPath::kEvenOdd_FillType); | 2127 path.setFillType(SkPath::kEvenOdd_FillType); |
2122 path.moveTo(1173, 284); | 2128 path.moveTo(1173, 284); |
2123 path.cubicTo(1173, 285.125824f, 1173.37207f, 286.164734f, 1174, 287.000488f)
; | 2129 path.cubicTo(1173, 285.125824f, 1173.37207f, 286.164734f, 1174, 287.000488f)
; |
2124 path.lineTo(1174, 123.999496f); | 2130 path.lineTo(1174, 123.999496f); |
2125 path.cubicTo(1173.37207f, 124.835243f, 1173, 125.874168f, 1173, 127); | 2131 path.cubicTo(1173.37207f, 124.835243f, 1173, 125.874168f, 1173, 127); |
2126 path.lineTo(1173, 284); | 2132 path.lineTo(1173, 284); |
2127 path.close(); | 2133 path.close(); |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3341 path2.cubicTo(36.71843719482421875, 0.8886508941650390625, | 3347 path2.cubicTo(36.71843719482421875, 0.8886508941650390625, |
3342 35.123386383056640625, 0.554015457630157470703125, | 3348 35.123386383056640625, 0.554015457630157470703125, |
3343 34.511409759521484375, -0.1152553558349609375); | 3349 34.511409759521484375, -0.1152553558349609375); |
3344 path2.cubicTo(33.899425506591796875, -0.7845261096954345703125, | 3350 path2.cubicTo(33.899425506591796875, -0.7845261096954345703125, |
3345 34.53484344482421875, -5.6777553558349609375, | 3351 34.53484344482421875, -5.6777553558349609375, |
3346 34.53484344482421875, -5.6777553558349609375); | 3352 34.53484344482421875, -5.6777553558349609375); |
3347 path2.close(); | 3353 path2.close(); |
3348 testPathOp(reporter, path1, path2, kUnion_PathOp, filename); | 3354 testPathOp(reporter, path1, path2, kUnion_PathOp, filename); |
3349 } | 3355 } |
3350 | 3356 |
| 3357 #define TEST_2540 0 |
| 3358 #if TEST_2540 // FIXME: extends cubic arm for sorting, marks extension with wro
ng winding? |
| 3359 static void issue2540(skiatest::Reporter* reporter, const char* filename) { |
| 3360 SkPath path1; |
| 3361 path1.moveTo(26.5054988861083984375, 85.73960113525390625); |
| 3362 path1.cubicTo(84.19739532470703125, 17.77140045166015625, 16.939201354980468
75, 101.86199951171875, 12.631000518798828125, 105.24700164794921875); |
| 3363 path1.cubicTo(11.0819997787475585937500000, 106.46399688720703125, 11.526000
0228881835937500000, 104.464996337890625, 11.5260000228881835937500000, 104.4649
96337890625); |
| 3364 path1.lineTo(23.1654987335205078125, 89.72879791259765625); |
| 3365 path1.cubicTo(23.1654987335205078125, 89.72879791259765625, -10.171300888061
5234375, 119.9160003662109375, -17.1620006561279296875, 120.8249969482421875); |
| 3366 path1.cubicTo(-19.1149997711181640625, 121.07900238037109375, -18.0380001068
115234375, 119.79299163818359375, -18.0380001068115234375, 119.79299163818359375
); |
| 3367 path1.cubicTo(-18.0380001068115234375, 119.79299163818359375, 14.22100067138
671875, 90.60700225830078125, 26.5054988861083984375, 85.73960113525390625); |
| 3368 path1.close(); |
| 3369 |
| 3370 SkPath path2; |
| 3371 path2.moveTo(-25.077999114990234375, 124.9120025634765625); |
| 3372 path2.cubicTo(-25.077999114990234375, 124.9120025634765625, -25.950998306274
4140625, 125.95400238037109375, -24.368999481201171875, 125.7480010986328125); |
| 3373 path2.cubicTo(-16.06999969482421875, 124.66899871826171875, 1.26800000667572
02148437500, 91.23999786376953125, 37.264003753662109375, 95.35400390625); |
| 3374 path2.cubicTo(37.264003753662109375, 95.35400390625, 11.3710002899169921875,
83.7339935302734375, -25.077999114990234375, 124.9120025634765625); |
| 3375 path2.close(); |
| 3376 testPathOp(reporter, path1, path2, kUnion_PathOp, filename); |
| 3377 } |
| 3378 #endif |
| 3379 |
| 3380 static void rects1(skiatest::Reporter* reporter, const char* filename) { |
| 3381 SkPath path, pathB; |
| 3382 path.setFillType(SkPath::kEvenOdd_FillType); |
| 3383 path.moveTo(0, 0); |
| 3384 path.lineTo(1, 0); |
| 3385 path.lineTo(1, 1); |
| 3386 path.lineTo(0, 1); |
| 3387 path.close(); |
| 3388 path.moveTo(0, 0); |
| 3389 path.lineTo(6, 0); |
| 3390 path.lineTo(6, 6); |
| 3391 path.lineTo(0, 6); |
| 3392 path.close(); |
| 3393 pathB.setFillType(SkPath::kEvenOdd_FillType); |
| 3394 pathB.moveTo(0, 0); |
| 3395 pathB.lineTo(1, 0); |
| 3396 pathB.lineTo(1, 1); |
| 3397 pathB.lineTo(0, 1); |
| 3398 pathB.close(); |
| 3399 pathB.moveTo(0, 0); |
| 3400 pathB.lineTo(2, 0); |
| 3401 pathB.lineTo(2, 2); |
| 3402 pathB.lineTo(0, 2); |
| 3403 pathB.close(); |
| 3404 testPathOp(reporter, path, pathB, kUnion_PathOp, filename); |
| 3405 } |
| 3406 |
| 3407 static void rects2(skiatest::Reporter* reporter, const char* filename) { |
| 3408 SkPath path, pathB; |
| 3409 path.setFillType(SkPath::kEvenOdd_FillType); |
| 3410 path.moveTo(0, 0); |
| 3411 path.lineTo(4, 0); |
| 3412 path.lineTo(4, 4); |
| 3413 path.lineTo(0, 4); |
| 3414 path.close(); |
| 3415 path.moveTo(3, 3); |
| 3416 path.lineTo(4, 3); |
| 3417 path.lineTo(4, 4); |
| 3418 path.lineTo(3, 4); |
| 3419 path.close(); |
| 3420 pathB.setFillType(SkPath::kWinding_FillType); |
| 3421 pathB.moveTo(3, 3); |
| 3422 pathB.lineTo(6, 3); |
| 3423 pathB.lineTo(6, 6); |
| 3424 pathB.lineTo(3, 6); |
| 3425 pathB.close(); |
| 3426 pathB.moveTo(3, 3); |
| 3427 pathB.lineTo(4, 3); |
| 3428 pathB.lineTo(4, 4); |
| 3429 pathB.lineTo(3, 4); |
| 3430 pathB.close(); |
| 3431 testPathOp(reporter, path, pathB, kDifference_PathOp, filename); |
| 3432 } |
| 3433 |
| 3434 static void rects3(skiatest::Reporter* reporter, const char* filename) { |
| 3435 SkPath path, pathB; |
| 3436 path.setFillType(SkPath::kEvenOdd_FillType); |
| 3437 path.addRect(0, 0, 1, 1, SkPath::kCW_Direction); |
| 3438 path.addRect(0, 0, 4, 4, SkPath::kCW_Direction); |
| 3439 pathB.setFillType(SkPath::kWinding_FillType); |
| 3440 pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction); |
| 3441 pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction); |
| 3442 testPathOp(reporter, path, pathB, kDifference_PathOp, filename); |
| 3443 } |
| 3444 |
| 3445 static void rects4(skiatest::Reporter* reporter, const char* filename) { |
| 3446 SkPath path, pathB; |
| 3447 path.setFillType(SkPath::kEvenOdd_FillType); |
| 3448 path.addRect(0, 0, 1, 1, SkPath::kCW_Direction); |
| 3449 path.addRect(0, 0, 2, 2, SkPath::kCW_Direction); |
| 3450 pathB.setFillType(SkPath::kWinding_FillType); |
| 3451 pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction); |
| 3452 pathB.addRect(0, 0, 3, 3, SkPath::kCW_Direction); |
| 3453 testPathOp(reporter, path, pathB, kDifference_PathOp, filename); |
| 3454 } |
| 3455 |
3351 static void (*firstTest)(skiatest::Reporter* , const char* filename) = 0; | 3456 static void (*firstTest)(skiatest::Reporter* , const char* filename) = 0; |
3352 static void (*stopTest)(skiatest::Reporter* , const char* filename) = 0; | 3457 static void (*stopTest)(skiatest::Reporter* , const char* filename) = 0; |
3353 | 3458 |
3354 static struct TestDesc tests[] = { | 3459 static struct TestDesc tests[] = { |
| 3460 TEST(rects4), |
| 3461 TEST(rects3), |
| 3462 TEST(rects2), |
| 3463 TEST(rects1), |
| 3464 #if TEST_2540 // FIXME: extends cubic arm for sorting, marks extension with wro
ng winding? |
| 3465 TEST(issue2540), |
| 3466 #endif |
3355 TEST(issue2504), | 3467 TEST(issue2504), |
3356 TEST(kari1), | 3468 TEST(kari1), |
3357 TEST(quadOp10i), | 3469 TEST(quadOp10i), |
3358 #if 0 // FIXME: serpentine curve is ordered the wrong way | 3470 #if 0 // FIXME: serpentine curve is ordered the wrong way |
3359 TEST(cubicOp114), | 3471 TEST(cubicOp114), |
3360 #endif | 3472 #endif |
3361 #if 0 // FIXME: currently failing | 3473 #if 0 // FIXME: currently failing |
3362 TEST(cubicOp113), | 3474 TEST(cubicOp113), |
3363 #endif | 3475 #endif |
3364 #if SKPS_WORKING | 3476 #if SKPS_WORKING |
(...skipping 18 matching lines...) Expand all Loading... |
3383 TEST(cubicOp108), | 3495 TEST(cubicOp108), |
3384 TEST(cubicOp107), | 3496 TEST(cubicOp107), |
3385 TEST(cubicOp106), | 3497 TEST(cubicOp106), |
3386 TEST(cubicOp105), | 3498 TEST(cubicOp105), |
3387 TEST(cubicOp104), | 3499 TEST(cubicOp104), |
3388 TEST(cubicOp103), | 3500 TEST(cubicOp103), |
3389 TEST(cubicOp102), | 3501 TEST(cubicOp102), |
3390 TEST(cubicOp101), | 3502 TEST(cubicOp101), |
3391 TEST(cubicOp100), | 3503 TEST(cubicOp100), |
3392 TEST(cubicOp99), | 3504 TEST(cubicOp99), |
| 3505 #if ISSUE_1435_FIXED |
3393 TEST(issue1435), | 3506 TEST(issue1435), |
| 3507 #endif |
3394 TEST(cubicOp98x), | 3508 TEST(cubicOp98x), |
3395 TEST(cubicOp97x), | 3509 TEST(cubicOp97x), |
3396 TEST(skpcarpetplanet_ru22), // cubic/cubic intersect detects unwanted coinc
idence | 3510 TEST(skpcarpetplanet_ru22), // cubic/cubic intersect detects unwanted coinc
idence |
3397 TEST(cubicOp96d), | 3511 TEST(cubicOp96d), |
3398 TEST(cubicOp95u), | 3512 TEST(cubicOp95u), |
3399 TEST(skpadbox_lt15), | 3513 TEST(skpadbox_lt15), |
3400 TEST(skpagentxsites_com55), | 3514 TEST(skpagentxsites_com55), |
3401 TEST(skpadventistmission_org572), | 3515 TEST(skpadventistmission_org572), |
3402 TEST(skpadoption_org196), | 3516 TEST(skpadoption_org196), |
3403 TEST(skpbambootheme_com12), | 3517 TEST(skpbambootheme_com12), |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3607 }; | 3721 }; |
3608 | 3722 |
3609 static const size_t failTestCount = SK_ARRAY_COUNT(failTests); | 3723 static const size_t failTestCount = SK_ARRAY_COUNT(failTests); |
3610 | 3724 |
3611 DEF_TEST(PathOpsFailOp, reporter) { | 3725 DEF_TEST(PathOpsFailOp, reporter) { |
3612 #if DEBUG_SHOW_TEST_NAME | 3726 #if DEBUG_SHOW_TEST_NAME |
3613 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); | 3727 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); |
3614 #endif | 3728 #endif |
3615 RunTestSet(reporter, failTests, failTestCount, 0, 0, false); | 3729 RunTestSet(reporter, failTests, failTestCount, 0, 0, false); |
3616 } | 3730 } |
OLD | NEW |