| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 290 } |
| 291 | 291 |
| 292 const int gTestFirst = 4; | 292 const int gTestFirst = 4; |
| 293 static int gTestNo = gTestFirst; | 293 static int gTestNo = gTestFirst; |
| 294 static SkTDArray<SkPathOp> gTestOp; | 294 static SkTDArray<SkPathOp> gTestOp; |
| 295 | 295 |
| 296 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath
& two, | 296 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath
& two, |
| 297 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath&
scaledTwo, | 297 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath&
scaledTwo, |
| 298 const SkPathOp shapeOp, const SkMatrix& scale) { | 298 const SkPathOp shapeOp, const SkMatrix& scale) { |
| 299 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); | 299 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); |
| 300 SkString defaultTestName; | |
| 301 if (!testName) { | 300 if (!testName) { |
| 302 defaultTestName.printf("xOp%d%s", gTestNo, opSuffixes[shapeOp]); | 301 testName = "xOp"; |
| 303 testName = defaultTestName.c_str(); | |
| 304 } | 302 } |
| 305 SkDebugf("static void %s(skiatest::Reporter* reporter, const char* filename)
{\n", testName); | 303 SkDebugf("static void %s%d%s(skiatest::Reporter* reporter, const char* filen
ame) {\n", |
| 304 testName, gTestNo, opSuffixes[shapeOp]); |
| 306 *gTestOp.append() = shapeOp; | 305 *gTestOp.append() = shapeOp; |
| 307 ++gTestNo; | 306 ++gTestNo; |
| 308 SkDebugf(" SkPath path, pathB;\n"); | 307 SkDebugf(" SkPath path, pathB;\n"); |
| 309 #if 0 && DEBUG_SHOW_TEST_NAME | |
| 310 SkPathOpsDebug::ShowOnePath(a, "path", false); | 308 SkPathOpsDebug::ShowOnePath(a, "path", false); |
| 311 SkPathOpsDebug::ShowOnePath(b, "pathB", false); | 309 SkPathOpsDebug::ShowOnePath(b, "pathB", false); |
| 312 #endif | |
| 313 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); | 310 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); |
| 314 SkDebugf("}\n"); | 311 SkDebugf("}\n"); |
| 315 drawAsciiPaths(scaledOne, scaledTwo, true); | 312 drawAsciiPaths(scaledOne, scaledTwo, true); |
| 316 } | 313 } |
| 317 | 314 |
| 318 void ShowTestArray() { | 315 void ShowTestArray(const char* testName) { |
| 316 if (!testName) { |
| 317 testName = "xOp"; |
| 318 } |
| 319 for (int x = gTestFirst; x < gTestNo; ++x) { | 319 for (int x = gTestFirst; x < gTestNo; ++x) { |
| 320 SkDebugf(" TEST(xOp%d%s),\n", x, opSuffixes[gTestOp[x - gTestFirst]])
; | 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) { |
| 330 int errors2x2; | 330 int errors2x2; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, | 541 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
| 542 const SkPathOp shapeOp, const char* testName) { | 542 const SkPathOp shapeOp, const char* testName) { |
| 543 return innerPathOp(reporter, a, b, shapeOp, testName, false, true); | 543 return innerPathOp(reporter, a, b, shapeOp, testName, false, true); |
| 544 } | 544 } |
| 545 | 545 |
| 546 bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath
& b, | 546 bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath
& b, |
| 547 const SkPathOp shapeOp, const char* testName, bool checkFail) { | 547 const SkPathOp shapeOp, const char* testName, bool checkFail) { |
| 548 return innerPathOp(reporter, a, b, shapeOp, testName, false, checkFail); | 548 return innerPathOp(reporter, a, b, shapeOp, testName, false, checkFail); |
| 549 } | 549 } |
| 550 | 550 |
| 551 bool testPathOpFailCheck(skiatest::Reporter* reporter, const SkPath& a, const Sk
Path& b, |
| 552 const SkPathOp shapeOp, const char* testName) { |
| 553 return innerPathOp(reporter, a, b, shapeOp, testName, false, false); |
| 554 } |
| 555 |
| 551 bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath&
b, | 556 bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath&
b, |
| 552 const SkPathOp shapeOp, const char* testName) { | 557 const SkPathOp shapeOp, const char* testName) { |
| 553 #if DEBUG_SHOW_TEST_NAME | 558 #if DEBUG_SHOW_TEST_NAME |
| 554 showName(a, b, shapeOp); | 559 showName(a, b, shapeOp); |
| 555 #endif | 560 #endif |
| 556 SkPath out; | 561 SkPath orig; |
| 562 orig.lineTo(54, 43); |
| 563 SkPath out = orig; |
| 557 if (Op(a, b, shapeOp, &out) ) { | 564 if (Op(a, b, shapeOp, &out) ) { |
| 558 SkDebugf("%s test is expected to fail\n", __FUNCTION__); | 565 SkDebugf("%s test is expected to fail\n", __FUNCTION__); |
| 559 REPORTER_ASSERT(reporter, 0); | 566 REPORTER_ASSERT(reporter, 0); |
| 560 return false; | 567 return false; |
| 561 } | 568 } |
| 569 SkASSERT(out == orig); |
| 562 return true; | 570 return true; |
| 563 } | 571 } |
| 564 | 572 |
| 565 bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, | 573 bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, |
| 566 const SkPathOp shapeOp, const char* testName) { | 574 const SkPathOp shapeOp, const char* testName) { |
| 567 return innerPathOp(reporter, a, b, shapeOp, testName, true, true); | 575 return innerPathOp(reporter, a, b, shapeOp, testName, true, true); |
| 568 } | 576 } |
| 569 | 577 |
| 570 SK_DECLARE_STATIC_MUTEX(gMutex); | 578 SK_DECLARE_STATIC_MUTEX(gMutex); |
| 571 | 579 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 if (tests[index].fun == stopTest) { | 657 if (tests[index].fun == stopTest) { |
| 650 SkDebugf("lastTest\n"); | 658 SkDebugf("lastTest\n"); |
| 651 break; | 659 break; |
| 652 } | 660 } |
| 653 if (index == last) { | 661 if (index == last) { |
| 654 break; | 662 break; |
| 655 } | 663 } |
| 656 index += reverse ? -1 : 1; | 664 index += reverse ? -1 : 1; |
| 657 } while (true); | 665 } while (true); |
| 658 } | 666 } |
| OLD | NEW |