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 | 7 |
8 #include "PathOpsExtendedTest.h" | 8 #include "PathOpsExtendedTest.h" |
9 #include "PathOpsThreadedCommon.h" | 9 #include "PathOpsThreadedCommon.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 for (int x = gTestFirst; x < gTestNo; ++x) { | 319 for (int x = gTestFirst; x < gTestNo; ++x) { |
320 SkDebugf(" TEST(%s%d%s),\n", testName, x, opSuffixes[gTestOp[x - gTes
tFirst]]); | 320 SkDebugf(" TEST(%s%d%s),\n", testName, x, opSuffixes[gTestOp[x - gTes
tFirst]]); |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 SK_DECLARE_STATIC_MUTEX(compareDebugOut3); | 324 SK_DECLARE_STATIC_MUTEX(compareDebugOut3); |
325 SK_DECLARE_STATIC_MUTEX(compareDebugOut4); | 325 SK_DECLARE_STATIC_MUTEX(compareDebugOut4); |
326 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons
t SkPath& one, | 326 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons
t SkPath& one, |
327 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB
itmap& bitmap, | 327 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB
itmap& bitmap, |
328 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix
& scale, | 328 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix
& scale, |
329 bool expectSuccess) { | 329 bool expectSuccess, bool flaky) { |
330 int errors2x2; | 330 int errors2x2; |
331 const int MAX_ERRORS = 8; | 331 const int MAX_ERRORS = 8; |
332 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); | 332 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); |
333 if (!expectSuccess) { | 333 if (!expectSuccess) { |
334 if (errors2x2 <= MAX_ERRORS) { | 334 if (errors2x2 <= MAX_ERRORS) { |
335 REPORTER_ASSERT(reporter, 0); | 335 REPORTER_ASSERT(reporter, 0); |
336 } | 336 } |
337 return 0; | 337 return 0; |
338 } | 338 } |
339 if (errors2x2 == 0) { | 339 if (errors2x2 == 0) { |
340 return 0; | 340 return 0; |
341 } | 341 } |
| 342 if (flaky) { |
| 343 return 0; |
| 344 } |
342 if (errors2x2 > MAX_ERRORS) { | 345 if (errors2x2 > MAX_ERRORS) { |
343 SkAutoMutexAcquire autoM(compareDebugOut3); | 346 SkAutoMutexAcquire autoM(compareDebugOut3); |
344 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); | 347 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); |
345 SkDebugf("\n/*"); | 348 SkDebugf("\n/*"); |
346 REPORTER_ASSERT(reporter, 0); | 349 REPORTER_ASSERT(reporter, 0); |
347 SkDebugf(" */\n"); | 350 SkDebugf(" */\n"); |
348 } else if (errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) { | 351 } else if (errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) { |
349 SkAutoMutexAcquire autoM(compareDebugOut4); | 352 SkAutoMutexAcquire autoM(compareDebugOut4); |
350 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); | 353 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); |
351 } | 354 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 488 |
486 #if DEBUG_SHOW_TEST_NAME | 489 #if DEBUG_SHOW_TEST_NAME |
487 static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) { | 490 static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) { |
488 SkDebugf("\n"); | 491 SkDebugf("\n"); |
489 showPathData(a); | 492 showPathData(a); |
490 showOp(shapeOp); | 493 showOp(shapeOp); |
491 showPathData(b); | 494 showPathData(b); |
492 } | 495 } |
493 #endif | 496 #endif |
494 | 497 |
| 498 bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result,
bool expectSuccess); |
| 499 |
495 static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, | 500 static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, |
496 const SkPathOp shapeOp, const char* testName, bool threaded, bool expect
Success) { | 501 const SkPathOp shapeOp, const char* testName, bool threaded, bool expect
Success, |
| 502 bool flaky) { |
497 #if 0 && DEBUG_SHOW_TEST_NAME | 503 #if 0 && DEBUG_SHOW_TEST_NAME |
498 showName(a, b, shapeOp); | 504 showName(a, b, shapeOp); |
499 #endif | 505 #endif |
500 SkPath out; | 506 SkPath out; |
501 if (!Op(a, b, shapeOp, &out) ) { | 507 if (!OpDebug(a, b, shapeOp, &out, expectSuccess)) { |
502 SkDebugf("%s did not expect failure\n", __FUNCTION__); | 508 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
503 REPORTER_ASSERT(reporter, 0); | 509 REPORTER_ASSERT(reporter, 0); |
504 return false; | 510 return false; |
505 } | 511 } |
506 if (!reporter->verbose()) { | 512 if (!reporter->verbose()) { |
507 return true; | 513 return true; |
508 } | 514 } |
509 SkPath pathOut, scaledPathOut; | 515 SkPath pathOut, scaledPathOut; |
510 SkRegion rgnA, rgnB, openClip, rgnOut; | 516 SkRegion rgnA, rgnB, openClip, rgnOut; |
511 openClip.setRect(-16000, -16000, 16000, 16000); | 517 openClip.setRect(-16000, -16000, 16000, 16000); |
(...skipping 12 matching lines...) Expand all Loading... |
524 scaledB.setFillType(b.getFillType()); | 530 scaledB.setFillType(b.getFillType()); |
525 scaledRgnA.setPath(scaledA, openClip); | 531 scaledRgnA.setPath(scaledA, openClip); |
526 scaledRgnB.setPath(scaledB, openClip); | 532 scaledRgnB.setPath(scaledB, openClip); |
527 scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp); | 533 scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp); |
528 scaledRgnOut.getBoundaryPath(&scaledPathOut); | 534 scaledRgnOut.getBoundaryPath(&scaledPathOut); |
529 SkBitmap bitmap; | 535 SkBitmap bitmap; |
530 SkPath scaledOut; | 536 SkPath scaledOut; |
531 scaledOut.addPath(out, scale); | 537 scaledOut.addPath(out, scale); |
532 scaledOut.setFillType(out.getFillType()); | 538 scaledOut.setFillType(out.getFillType()); |
533 int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, s
caledOut, bitmap, | 539 int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, s
caledOut, bitmap, |
534 a, b, shapeOp, scale, expectSuccess); | 540 a, b, shapeOp, scale, expectSuccess, flaky); |
535 reporter->bumpTestCount(); | 541 reporter->bumpTestCount(); |
536 return result == 0; | 542 return result == 0; |
537 } | 543 } |
538 | 544 |
539 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, | 545 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
540 const SkPathOp shapeOp, const char* testName) { | 546 const SkPathOp shapeOp, const char* testName) { |
541 return innerPathOp(reporter, a, b, shapeOp, testName, false, true); | 547 return innerPathOp(reporter, a, b, shapeOp, testName, false, true, false); |
| 548 } |
| 549 |
| 550 bool testPathOpFlaky(skiatest::Reporter* reporter, const SkPath& a, const SkPath
& b, |
| 551 const SkPathOp shapeOp, const char* testName) { |
| 552 return innerPathOp(reporter, a, b, shapeOp, testName, false, true, true); |
542 } | 553 } |
543 | 554 |
544 bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath
& b, | 555 bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath
& b, |
545 const SkPathOp shapeOp, const char* testName, bool checkFail) { | 556 const SkPathOp shapeOp, const char* testName, bool checkFail) { |
546 return innerPathOp(reporter, a, b, shapeOp, testName, false, checkFail); | 557 return innerPathOp(reporter, a, b, shapeOp, testName, false, checkFail, fals
e); |
547 } | 558 } |
548 | 559 |
549 bool testPathOpFailCheck(skiatest::Reporter* reporter, const SkPath& a, const Sk
Path& b, | 560 bool testPathOpFailCheck(skiatest::Reporter* reporter, const SkPath& a, const Sk
Path& b, |
550 const SkPathOp shapeOp, const char* testName) { | 561 const SkPathOp shapeOp, const char* testName) { |
551 return innerPathOp(reporter, a, b, shapeOp, testName, false, false); | 562 return innerPathOp(reporter, a, b, shapeOp, testName, false, false, false); |
552 } | 563 } |
553 | 564 |
554 bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath&
b, | 565 bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath&
b, |
555 const SkPathOp shapeOp, const char* testName) { | 566 const SkPathOp shapeOp, const char* testName) { |
556 #if DEBUG_SHOW_TEST_NAME | 567 #if DEBUG_SHOW_TEST_NAME |
557 showName(a, b, shapeOp); | 568 showName(a, b, shapeOp); |
558 #endif | 569 #endif |
559 SkPath orig; | 570 SkPath orig; |
560 orig.lineTo(54, 43); | 571 orig.lineTo(54, 43); |
561 SkPath out = orig; | 572 SkPath out = orig; |
562 if (Op(a, b, shapeOp, &out) ) { | 573 if (Op(a, b, shapeOp, &out) ) { |
563 SkDebugf("%s test is expected to fail\n", __FUNCTION__); | 574 SkDebugf("%s test is expected to fail\n", __FUNCTION__); |
564 REPORTER_ASSERT(reporter, 0); | 575 REPORTER_ASSERT(reporter, 0); |
565 return false; | 576 return false; |
566 } | 577 } |
567 SkASSERT(out == orig); | 578 SkASSERT(out == orig); |
568 return true; | 579 return true; |
569 } | 580 } |
570 | 581 |
571 bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, | 582 bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, |
572 const SkPathOp shapeOp, const char* testName) { | 583 const SkPathOp shapeOp, const char* testName) { |
573 return innerPathOp(reporter, a, b, shapeOp, testName, true, true); | 584 return innerPathOp(reporter, a, b, shapeOp, testName, true, true, false); |
574 } | 585 } |
575 | 586 |
576 SK_DECLARE_STATIC_MUTEX(gMutex); | 587 SK_DECLARE_STATIC_MUTEX(gMutex); |
577 | 588 |
578 void initializeTests(skiatest::Reporter* reporter, const char* test) { | 589 void initializeTests(skiatest::Reporter* reporter, const char* test) { |
579 #if 0 // doesn't work yet | 590 #if 0 // doesn't work yet |
580 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); | 591 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); |
581 SK_CONF_SET("images.png.suppressDecoderWarnings", true); | 592 SK_CONF_SET("images.png.suppressDecoderWarnings", true); |
582 #endif | 593 #endif |
583 if (reporter->verbose()) { | 594 if (reporter->verbose()) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 if (foundSkip && tests[index].fun != firstTest) { | 687 if (foundSkip && tests[index].fun != firstTest) { |
677 SkDebugf(" %s,\n", tests[index].str); | 688 SkDebugf(" %s,\n", tests[index].str); |
678 } | 689 } |
679 if (tests[index].fun == stopTest || index == last) { | 690 if (tests[index].fun == stopTest || index == last) { |
680 break; | 691 break; |
681 } | 692 } |
682 index += reverse ? -1 : 1; | 693 index += reverse ? -1 : 1; |
683 } while (true); | 694 } while (true); |
684 #endif | 695 #endif |
685 } | 696 } |
OLD | NEW |