| 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 outFile.flush(); | 442 outFile.flush(); |
| 443 } | 443 } |
| 444 | 444 |
| 445 bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st
ate, | 445 bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st
ate, |
| 446 const char* pathStr) { | 446 const char* pathStr) { |
| 447 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi
nding_FillType; | 447 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi
nding_FillType; |
| 448 path.setFillType(fillType); | 448 path.setFillType(fillType); |
| 449 if (gShowPath) { | 449 if (gShowPath) { |
| 450 showPath(path); | 450 showPath(path); |
| 451 } | 451 } |
| 452 Simplify(path, &out); | 452 if (!Simplify(path, &out)) { |
| 453 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
| 454 REPORTER_ASSERT(state.fReporter, 0); |
| 455 return false; |
| 456 } |
| 453 if (!gComparePaths) { | 457 if (!gComparePaths) { |
| 454 return true; | 458 return true; |
| 455 } | 459 } |
| 456 int result = comparePaths(state.fReporter, path, out, *state.fBitmap); | 460 int result = comparePaths(state.fReporter, path, out, *state.fBitmap); |
| 457 if (result && gPathStrAssert) { | 461 if (result && gPathStrAssert) { |
| 458 char temp[8192]; | 462 char temp[8192]; |
| 459 sk_bzero(temp, sizeof(temp)); | 463 sk_bzero(temp, sizeof(temp)); |
| 460 SkMemoryWStream stream(temp, sizeof(temp)); | 464 SkMemoryWStream stream(temp, sizeof(temp)); |
| 461 const char* pathPrefix = NULL; | 465 const char* pathPrefix = NULL; |
| 462 const char* nameSuffix = NULL; | 466 const char* nameSuffix = NULL; |
| 463 if (fillType == SkPath::kEvenOdd_FillType) { | 467 if (fillType == SkPath::kEvenOdd_FillType) { |
| 464 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; | 468 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; |
| 465 nameSuffix = "x"; | 469 nameSuffix = "x"; |
| 466 } | 470 } |
| 467 const char testFunction[] = "testSimplifyx(path);"; | 471 const char testFunction[] = "testSimplifyx(path);"; |
| 468 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str
eam); | 472 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str
eam); |
| 469 SkDebugf(temp); | 473 SkDebugf(temp); |
| 470 REPORTER_ASSERT(state.fReporter, 0); | 474 REPORTER_ASSERT(state.fReporter, 0); |
| 471 } | 475 } |
| 472 state.fReporter->bumpTestCount(); | 476 state.fReporter->bumpTestCount(); |
| 473 return result == 0; | 477 return result == 0; |
| 474 } | 478 } |
| 475 | 479 |
| 476 bool testSimplify(skiatest::Reporter* reporter, const SkPath& path) { | 480 bool testSimplify(skiatest::Reporter* reporter, const SkPath& path) { |
| 477 #if FORCE_RELEASE == 0 | 481 #if FORCE_RELEASE == 0 |
| 478 showPathData(path); | 482 showPathData(path); |
| 479 #endif | 483 #endif |
| 480 SkPath out; | 484 SkPath out; |
| 481 Simplify(path, &out); | 485 if (!Simplify(path, &out)) { |
| 486 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
| 487 REPORTER_ASSERT(reporter, 0); |
| 488 return false; |
| 489 } |
| 482 SkBitmap bitmap; | 490 SkBitmap bitmap; |
| 483 int result = comparePaths(reporter, path, out, bitmap); | 491 int result = comparePaths(reporter, path, out, bitmap); |
| 484 if (result && gPathStrAssert) { | 492 if (result && gPathStrAssert) { |
| 485 REPORTER_ASSERT(reporter, 0); | 493 REPORTER_ASSERT(reporter, 0); |
| 486 } | 494 } |
| 487 reporter->bumpTestCount(); | 495 reporter->bumpTestCount(); |
| 488 return result == 0; | 496 return result == 0; |
| 489 } | 497 } |
| 490 | 498 |
| 491 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, | 499 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
| 492 const SkPathOp shapeOp) { | 500 const SkPathOp shapeOp) { |
| 493 #if FORCE_RELEASE == 0 | 501 #if FORCE_RELEASE == 0 |
| 494 showPathData(a); | 502 showPathData(a); |
| 495 showOp(shapeOp); | 503 showOp(shapeOp); |
| 496 showPathData(b); | 504 showPathData(b); |
| 497 #endif | 505 #endif |
| 498 SkPath out; | 506 SkPath out; |
| 499 Op(a, b, shapeOp, &out); | 507 if (!Op(a, b, shapeOp, &out) ) { |
| 508 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
| 509 REPORTER_ASSERT(reporter, 0); |
| 510 return false; |
| 511 } |
| 500 SkPath pathOut, scaledPathOut; | 512 SkPath pathOut, scaledPathOut; |
| 501 SkRegion rgnA, rgnB, openClip, rgnOut; | 513 SkRegion rgnA, rgnB, openClip, rgnOut; |
| 502 openClip.setRect(-16000, -16000, 16000, 16000); | 514 openClip.setRect(-16000, -16000, 16000, 16000); |
| 503 rgnA.setPath(a, openClip); | 515 rgnA.setPath(a, openClip); |
| 504 rgnB.setPath(b, openClip); | 516 rgnB.setPath(b, openClip); |
| 505 rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp); | 517 rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp); |
| 506 rgnOut.getBoundaryPath(&pathOut); | 518 rgnOut.getBoundaryPath(&pathOut); |
| 507 | 519 |
| 508 SkMatrix scale; | 520 SkMatrix scale; |
| 509 scaleMatrix(a, b, scale); | 521 scaleMatrix(a, b, scale); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 613 } |
| 602 if (tests[index].fun == stopTest) { | 614 if (tests[index].fun == stopTest) { |
| 603 SkDebugf("lastTest\n"); | 615 SkDebugf("lastTest\n"); |
| 604 } | 616 } |
| 605 if (index == last) { | 617 if (index == last) { |
| 606 break; | 618 break; |
| 607 } | 619 } |
| 608 index += reverse ? -1 : 1; | 620 index += reverse ? -1 : 1; |
| 609 } while (true); | 621 } while (true); |
| 610 } | 622 } |
| OLD | NEW |