| 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 23 matching lines...) Expand all Loading... |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 static const char* opSuffixes[] = { | 36 static const char* opSuffixes[] = { |
| 37 "d", | 37 "d", |
| 38 "i", | 38 "i", |
| 39 "u", | 39 "u", |
| 40 "o", | 40 "o", |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 static bool gShowPath = false; | 43 static bool gShowPath = false; |
| 44 static bool gComparePaths = true; | |
| 45 static bool gComparePathsAssert = true; | 44 static bool gComparePathsAssert = true; |
| 46 static bool gPathStrAssert = true; | 45 static bool gPathStrAssert = true; |
| 47 | 46 |
| 48 static const char* gFillTypeStr[] = { | 47 static const char* gFillTypeStr[] = { |
| 49 "kWinding_FillType", | 48 "kWinding_FillType", |
| 50 "kEvenOdd_FillType", | 49 "kEvenOdd_FillType", |
| 51 "kInverseWinding_FillType", | 50 "kInverseWinding_FillType", |
| 52 "kInverseEvenOdd_FillType" | 51 "kInverseEvenOdd_FillType" |
| 53 }; | 52 }; |
| 54 | 53 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi
nding_FillType; | 504 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi
nding_FillType; |
| 506 path.setFillType(fillType); | 505 path.setFillType(fillType); |
| 507 if (gShowPath) { | 506 if (gShowPath) { |
| 508 showPath(path, "path", false); | 507 showPath(path, "path", false); |
| 509 } | 508 } |
| 510 if (!Simplify(path, &out)) { | 509 if (!Simplify(path, &out)) { |
| 511 SkDebugf("%s did not expect failure\n", __FUNCTION__); | 510 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
| 512 REPORTER_ASSERT(state.fReporter, 0); | 511 REPORTER_ASSERT(state.fReporter, 0); |
| 513 return false; | 512 return false; |
| 514 } | 513 } |
| 515 if (!gComparePaths) { | 514 if (!state.fReporter->verbose()) { |
| 516 return true; | 515 return true; |
| 517 } | 516 } |
| 518 int result = comparePaths(state.fReporter, path, out, *state.fBitmap); | 517 int result = comparePaths(state.fReporter, path, out, *state.fBitmap); |
| 519 if (result && gPathStrAssert) { | 518 if (result && gPathStrAssert) { |
| 520 char temp[8192]; | 519 char temp[8192]; |
| 521 sk_bzero(temp, sizeof(temp)); | 520 sk_bzero(temp, sizeof(temp)); |
| 522 SkMemoryWStream stream(temp, sizeof(temp)); | 521 SkMemoryWStream stream(temp, sizeof(temp)); |
| 523 const char* pathPrefix = NULL; | 522 const char* pathPrefix = NULL; |
| 524 const char* nameSuffix = NULL; | 523 const char* nameSuffix = NULL; |
| 525 if (fillType == SkPath::kEvenOdd_FillType) { | 524 if (fillType == SkPath::kEvenOdd_FillType) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 556 | 555 |
| 557 #if DEBUG_SHOW_TEST_NAME | 556 #if DEBUG_SHOW_TEST_NAME |
| 558 void DebugShowPath(const SkPath& a, const SkPath& b, SkPathOp shapeOp, const cha
r* testName) { | 557 void DebugShowPath(const SkPath& a, const SkPath& b, SkPathOp shapeOp, const cha
r* testName) { |
| 559 ShowFunctionHeader(testName); | 558 ShowFunctionHeader(testName); |
| 560 showPath(a, "path", true); | 559 showPath(a, "path", true); |
| 561 showPath(b, "pathB", true); | 560 showPath(b, "pathB", true); |
| 562 ShowOp(shapeOp, "path", "pathB"); | 561 ShowOp(shapeOp, "path", "pathB"); |
| 563 } | 562 } |
| 564 #endif | 563 #endif |
| 565 | 564 |
| 566 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, | 565 static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, |
| 567 const SkPathOp shapeOp, const char* testName) { | 566 const SkPathOp shapeOp, const char* testName, bool threaded) { |
| 568 #if DEBUG_SHOW_TEST_NAME | 567 #if DEBUG_SHOW_TEST_NAME |
| 569 if (testName == NULL) { | 568 if (testName == NULL) { |
| 570 SkDebugf("\n"); | 569 SkDebugf("\n"); |
| 571 showPathData(a); | 570 showPathData(a); |
| 572 showOp(shapeOp); | 571 showOp(shapeOp); |
| 573 showPathData(b); | 572 showPathData(b); |
| 574 } else { | 573 } else { |
| 575 DebugShowPath(a, b, shapeOp, testName); | 574 DebugShowPath(a, b, shapeOp, testName); |
| 576 } | 575 } |
| 577 #endif | 576 #endif |
| 578 SkPath out; | 577 SkPath out; |
| 579 if (!Op(a, b, shapeOp, &out) ) { | 578 if (!Op(a, b, shapeOp, &out) ) { |
| 580 SkDebugf("%s did not expect failure\n", __FUNCTION__); | 579 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
| 581 REPORTER_ASSERT(reporter, 0); | 580 REPORTER_ASSERT(reporter, 0); |
| 582 return false; | 581 return false; |
| 583 } | 582 } |
| 583 if (threaded && !reporter->verbose()) { |
| 584 return true; |
| 585 } |
| 584 SkPath pathOut, scaledPathOut; | 586 SkPath pathOut, scaledPathOut; |
| 585 SkRegion rgnA, rgnB, openClip, rgnOut; | 587 SkRegion rgnA, rgnB, openClip, rgnOut; |
| 586 openClip.setRect(-16000, -16000, 16000, 16000); | 588 openClip.setRect(-16000, -16000, 16000, 16000); |
| 587 rgnA.setPath(a, openClip); | 589 rgnA.setPath(a, openClip); |
| 588 rgnB.setPath(b, openClip); | 590 rgnB.setPath(b, openClip); |
| 589 rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp); | 591 rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp); |
| 590 rgnOut.getBoundaryPath(&pathOut); | 592 rgnOut.getBoundaryPath(&pathOut); |
| 591 | 593 |
| 592 SkMatrix scale; | 594 SkMatrix scale; |
| 593 scaleMatrix(a, b, scale); | 595 scaleMatrix(a, b, scale); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 607 scaledOut.setFillType(out.getFillType()); | 609 scaledOut.setFillType(out.getFillType()); |
| 608 int result = comparePaths(reporter, pathOut, scaledPathOut, out, scaledOut,
bitmap, a, b, | 610 int result = comparePaths(reporter, pathOut, scaledPathOut, out, scaledOut,
bitmap, a, b, |
| 609 shapeOp, scale); | 611 shapeOp, scale); |
| 610 if (result && gPathStrAssert) { | 612 if (result && gPathStrAssert) { |
| 611 REPORTER_ASSERT(reporter, 0); | 613 REPORTER_ASSERT(reporter, 0); |
| 612 } | 614 } |
| 613 reporter->bumpTestCount(); | 615 reporter->bumpTestCount(); |
| 614 return result == 0; | 616 return result == 0; |
| 615 } | 617 } |
| 616 | 618 |
| 619 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
| 620 const SkPathOp shapeOp, const char* testName) { |
| 621 return innerPathOp(reporter, a, b, shapeOp, testName, false); |
| 622 } |
| 623 |
| 624 bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, |
| 625 const SkPathOp shapeOp, const char* testName) { |
| 626 return innerPathOp(reporter, a, b, shapeOp, testName, true); |
| 627 } |
| 628 |
| 617 int initializeTests(skiatest::Reporter* reporter, const char* test) { | 629 int initializeTests(skiatest::Reporter* reporter, const char* test) { |
| 618 #ifdef SK_DEBUG | 630 #ifdef SK_DEBUG |
| 619 gDebugMaxWindSum = 4; | 631 gDebugMaxWindSum = 4; |
| 620 gDebugMaxWindValue = 4; | 632 gDebugMaxWindValue = 4; |
| 621 #endif | 633 #endif |
| 622 testName = test; | 634 testName = test; |
| 623 size_t testNameSize = strlen(test); | 635 size_t testNameSize = strlen(test); |
| 624 SkFILEStream inFile("../../experimental/Intersection/op.htm"); | 636 SkFILEStream inFile("../../experimental/Intersection/op.htm"); |
| 625 if (inFile.isValid()) { | 637 if (inFile.isValid()) { |
| 626 SkTDArray<char> inData; | 638 SkTDArray<char> inData; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 } | 697 } |
| 686 if (tests[index].fun == stopTest) { | 698 if (tests[index].fun == stopTest) { |
| 687 SkDebugf("lastTest\n"); | 699 SkDebugf("lastTest\n"); |
| 688 } | 700 } |
| 689 if (index == last) { | 701 if (index == last) { |
| 690 break; | 702 break; |
| 691 } | 703 } |
| 692 index += reverse ? -1 : 1; | 704 index += reverse ? -1 : 1; |
| 693 } while (true); | 705 } while (true); |
| 694 } | 706 } |
| OLD | NEW |