Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: tests/PathOpsOpTest.cpp

Issue 239563004: fix minor skp-found bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix mac-detected errors Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/PathOpsOpLoopThreadedTest.cpp ('k') | tests/PathOpsSimplifyTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 path.moveTo(0,1); 3250 path.moveTo(0,1);
3251 path.cubicTo(1,6, 5,0, 2,1); 3251 path.cubicTo(1,6, 5,0, 2,1);
3252 path.close(); 3252 path.close();
3253 pathB.setFillType(SkPath::kWinding_FillType); 3253 pathB.setFillType(SkPath::kWinding_FillType);
3254 pathB.moveTo(0,5); 3254 pathB.moveTo(0,5);
3255 pathB.cubicTo(1,2, 1,0, 6,1); 3255 pathB.cubicTo(1,2, 1,0, 6,1);
3256 pathB.close(); 3256 pathB.close();
3257 testPathOp(reporter, path, pathB, kDifference_PathOp, filename); 3257 testPathOp(reporter, path, pathB, kDifference_PathOp, filename);
3258 } 3258 }
3259 3259
3260 // triggers addSimpleAngle with non-zero argument
3261 static void cubicOp112(skiatest::Reporter* reporter, const char* filename) {
3262 SkPath path, pathB;
3263 path.setFillType(SkPath::kWinding_FillType);
3264 path.moveTo(2,4);
3265 path.cubicTo(2,3, 6,4, 1,0);
3266 path.close();
3267 pathB.setFillType(SkPath::kWinding_FillType);
3268 pathB.moveTo(4,6);
3269 pathB.cubicTo(0,1, 4,2, 3,2);
3270 pathB.close();
3271 testPathOp(reporter, path, pathB, kDifference_PathOp, filename);
3272 }
3273
3274 // triggers untested calcLoopSpanCount code path
3275 #if 0
3276 static void cubicOp113(skiatest::Reporter* reporter, const char* filename) {
3277 SkPath path, pathB;
3278 path.moveTo(2,4);
3279 path.cubicTo(3,5, 2.33333325f,4.33333349f, 3.83333325f,3.83333349f);
3280 path.close();
3281 pathB.moveTo(3,5);
3282 pathB.cubicTo(2.33333325f,4.33333349f, 3.83333325f,3.83333349f, 2,4);
3283 pathB.close();
3284 testPathOp(reporter, path, pathB, kDifference_PathOp, filename);
3285 }
3286 #endif
3287
3288 static void cubicOp114(skiatest::Reporter* reporter, const char* filename) {
3289 SkPath path, pathB;
3290 path.setFillType(SkPath::kWinding_FillType);
3291 path.moveTo(0, 1);
3292 path.cubicTo(1, 3, -1, 2, 3.5f, 1.33333337f);
3293 path.close();
3294 pathB.setFillType(SkPath::kWinding_FillType);
3295 pathB.moveTo(1, 3);
3296 pathB.cubicTo(-1, 2, 3.5f, 1.33333337f, 0, 1);
3297 pathB.close();
3298 testPathOp(reporter, path, pathB, kIntersect_PathOp, filename);
3299 }
3300
3301 static void quadOp10i(skiatest::Reporter* reporter, const char* filename) {
3302 SkPath path, pathB;
3303 path.moveTo(0, 0);
3304 path.quadTo(1, 8, 3, 5);
3305 path.lineTo(8, 1);
3306 path.close();
3307 pathB.moveTo(0, 0);
3308 pathB.quadTo(8, 1, 4, 8);
3309 pathB.close();
3310 testPathOp(reporter, path, pathB, kIntersect_PathOp, filename);
3311 }
3312
3260 static void (*firstTest)(skiatest::Reporter* , const char* filename) = 0; 3313 static void (*firstTest)(skiatest::Reporter* , const char* filename) = 0;
3261 static void (*stopTest)(skiatest::Reporter* , const char* filename) = 0; 3314 static void (*stopTest)(skiatest::Reporter* , const char* filename) = 0;
3262 3315
3263 static struct TestDesc tests[] = { 3316 static struct TestDesc tests[] = {
3317 TEST(quadOp10i),
3318 #if 0 // FIXME: serpentine curve is ordered the wrong way
3319 TEST(cubicOp114),
3320 #endif
3321 #if 0 // FIXME: currently failing
3322 TEST(cubicOp113),
3323 #endif
3264 #if SKPS_WORKING 3324 #if SKPS_WORKING
3265 // fails because a cubic/quadratic intersection is missed 3325 // fails because a cubic/quadratic intersection is missed
3266 // the internal quad/quad is far enough away from the real cubic/quad that i t is rejected 3326 // the internal quad/quad is far enough away from the real cubic/quad that i t is rejected
3267 TEST(skpcarrot_is24), 3327 TEST(skpcarrot_is24),
3268 #endif 3328 #endif
3269 #if ISSUE_1417_WORKING_ON_LINUX_32 3329 #if ISSUE_1417_WORKING_ON_LINUX_32
3270 TEST(issue1417), 3330 TEST(issue1417),
3271 #endif 3331 #endif
3332 TEST(cubicOp112),
3272 TEST(skpadspert_net23), 3333 TEST(skpadspert_net23),
3273 TEST(skpadspert_de11), 3334 TEST(skpadspert_de11),
3274 TEST(findFirst1), 3335 TEST(findFirst1),
3275 TEST(xOp2i), 3336 TEST(xOp2i),
3276 TEST(xOp3i), 3337 TEST(xOp3i),
3277 TEST(xOp1u), 3338 TEST(xOp1u),
3278 TEST(xOp1i), 3339 TEST(xOp1i),
3279 TEST(cubicOp111), 3340 TEST(cubicOp111),
3280 TEST(cubicOp110), 3341 TEST(cubicOp110),
3281 TEST(cubicOp109), 3342 TEST(cubicOp109),
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
3460 TEST(cubicOp6d), 3521 TEST(cubicOp6d),
3461 TEST(cubicOp5d), 3522 TEST(cubicOp5d),
3462 TEST(cubicOp3d), 3523 TEST(cubicOp3d),
3463 TEST(cubicOp2d), 3524 TEST(cubicOp2d),
3464 TEST(cubicOp1d), 3525 TEST(cubicOp1d),
3465 }; 3526 };
3466 3527
3467 static const size_t testCount = SK_ARRAY_COUNT(tests); 3528 static const size_t testCount = SK_ARRAY_COUNT(tests);
3468 3529
3469 static struct TestDesc subTests[] = { 3530 static struct TestDesc subTests[] = {
3470 TEST(cubicOp6d), 3531 TEST(cubicOp114),
3471 TEST(cubicOp8d), 3532 TEST(cubicOp58d),
3472 TEST(cubicOp70d), 3533 TEST(cubicOp53d),
3473 TEST(cubicOp16d),
3474 TEST(skp5),
3475 }; 3534 };
3476 3535
3477 static const size_t subTestCount = SK_ARRAY_COUNT(subTests); 3536 static const size_t subTestCount = SK_ARRAY_COUNT(subTests);
3478 3537
3479 static void (*firstSubTest)(skiatest::Reporter* , const char* filename) = 0; 3538 static void (*firstSubTest)(skiatest::Reporter* , const char* filename) = 0;
3480 3539
3481 static bool runSubTests = false; 3540 static bool runSubTests = false;
3482 static bool runSubTestsFirst = false; 3541 static bool runSubTestsFirst = false;
3483 static bool runReverse = false; 3542 static bool runReverse = false;
3484 3543
3485 DEF_TEST(PathOpsOp, reporter) { 3544 DEF_TEST(PathOpsOp, reporter) {
3486 #ifdef SK_DEBUG
3487 SkPathOpsDebug::gMaxWindSum = 4;
3488 SkPathOpsDebug::gMaxWindValue = 4;
3489 #endif
3490 #if DEBUG_SHOW_TEST_NAME 3545 #if DEBUG_SHOW_TEST_NAME
3491 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); 3546 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
3492 #endif 3547 #endif
3493 if (runSubTests && runSubTestsFirst) { 3548 if (runSubTests && runSubTestsFirst) {
3494 RunTestSet(reporter, subTests, subTestCount, firstSubTest, stopTest, run Reverse); 3549 RunTestSet(reporter, subTests, subTestCount, firstSubTest, stopTest, run Reverse);
3495 } 3550 }
3496 RunTestSet(reporter, tests, testCount, firstTest, stopTest, runReverse); 3551 RunTestSet(reporter, tests, testCount, firstTest, stopTest, runReverse);
3497 if (runSubTests && !runSubTestsFirst) { 3552 if (runSubTests && !runSubTestsFirst) {
3498 RunTestSet(reporter, subTests, subTestCount, firstSubTest, stopTest, run Reverse); 3553 RunTestSet(reporter, subTests, subTestCount, firstSubTest, stopTest, run Reverse);
3499 } 3554 }
3500 #ifdef SK_DEBUG
3501 SkPathOpsDebug::gMaxWindSum = SK_MaxS32;
3502 SkPathOpsDebug::gMaxWindValue = SK_MaxS32;
3503 #endif
3504 } 3555 }
3505 3556
3506 static void bufferOverflow(skiatest::Reporter* reporter, const char* filename) { 3557 static void bufferOverflow(skiatest::Reporter* reporter, const char* filename) {
3507 SkPath path; 3558 SkPath path;
3508 path.addRect(0,0, 300,170141183460469231731687303715884105728.f); 3559 path.addRect(0,0, 300,170141183460469231731687303715884105728.f);
3509 SkPath pathB; 3560 SkPath pathB;
3510 pathB.addRect(0,0, 300,16); 3561 pathB.addRect(0,0, 300,16);
3511 testPathFailOp(reporter, path, pathB, kUnion_PathOp, filename); 3562 testPathFailOp(reporter, path, pathB, kUnion_PathOp, filename);
3512 } 3563 }
3513 3564
3514 static struct TestDesc failTests[] = { 3565 static struct TestDesc failTests[] = {
3515 TEST(bufferOverflow), 3566 TEST(bufferOverflow),
3516 }; 3567 };
3517 3568
3518 static const size_t failTestCount = SK_ARRAY_COUNT(failTests); 3569 static const size_t failTestCount = SK_ARRAY_COUNT(failTests);
3519 3570
3520 DEF_TEST(PathOpsFailOp, reporter) { 3571 DEF_TEST(PathOpsFailOp, reporter) {
3521 #ifdef SK_DEBUG
3522 SkPathOpsDebug::gMaxWindSum = 4;
3523 SkPathOpsDebug::gMaxWindValue = 4;
3524 #endif
3525 #if DEBUG_SHOW_TEST_NAME 3572 #if DEBUG_SHOW_TEST_NAME
3526 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); 3573 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
3527 #endif 3574 #endif
3528 RunTestSet(reporter, failTests, failTestCount, 0, 0, false); 3575 RunTestSet(reporter, failTests, failTestCount, 0, 0, false);
3529 } 3576 }
OLDNEW
« no previous file with comments | « tests/PathOpsOpLoopThreadedTest.cpp ('k') | tests/PathOpsSimplifyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698