| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 path.setFillType(fillType); | 418 path.setFillType(fillType); |
| 419 state.fReporter->bumpTestCount(); | 419 state.fReporter->bumpTestCount(); |
| 420 if (!Simplify(path, &out)) { | 420 if (!Simplify(path, &out)) { |
| 421 SkDebugf("%s did not expect failure\n", __FUNCTION__); | 421 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
| 422 REPORTER_ASSERT(state.fReporter, 0); | 422 REPORTER_ASSERT(state.fReporter, 0); |
| 423 return false; | 423 return false; |
| 424 } | 424 } |
| 425 if (!state.fReporter->verbose()) { | 425 if (!state.fReporter->verbose()) { |
| 426 return true; | 426 return true; |
| 427 } | 427 } |
| 428 int result = comparePaths(state.fReporter, NULL, path, out, *state.fBitmap); | 428 int result = comparePaths(state.fReporter, nullptr, path, out, *state.fBitma
p); |
| 429 if (result) { | 429 if (result) { |
| 430 SkAutoMutexAcquire autoM(simplifyDebugOut); | 430 SkAutoMutexAcquire autoM(simplifyDebugOut); |
| 431 char temp[8192]; | 431 char temp[8192]; |
| 432 sk_bzero(temp, sizeof(temp)); | 432 sk_bzero(temp, sizeof(temp)); |
| 433 SkMemoryWStream stream(temp, sizeof(temp)); | 433 SkMemoryWStream stream(temp, sizeof(temp)); |
| 434 const char* pathPrefix = NULL; | 434 const char* pathPrefix = nullptr; |
| 435 const char* nameSuffix = NULL; | 435 const char* nameSuffix = nullptr; |
| 436 if (fillType == SkPath::kEvenOdd_FillType) { | 436 if (fillType == SkPath::kEvenOdd_FillType) { |
| 437 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; | 437 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; |
| 438 nameSuffix = "x"; | 438 nameSuffix = "x"; |
| 439 } | 439 } |
| 440 const char testFunction[] = "testSimplify(reporter, path);"; | 440 const char testFunction[] = "testSimplify(reporter, path);"; |
| 441 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str
eam); | 441 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str
eam); |
| 442 SkDebugf("%s", temp); | 442 SkDebugf("%s", temp); |
| 443 REPORTER_ASSERT(state.fReporter, 0); | 443 REPORTER_ASSERT(state.fReporter, 0); |
| 444 } | 444 } |
| 445 state.fReporter->bumpTestCount(); | 445 state.fReporter->bumpTestCount(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 if (reporter->verbose()) { | 579 if (reporter->verbose()) { |
| 580 SkAutoMutexAcquire lock(gMutex); | 580 SkAutoMutexAcquire lock(gMutex); |
| 581 testName = test; | 581 testName = test; |
| 582 size_t testNameSize = strlen(test); | 582 size_t testNameSize = strlen(test); |
| 583 SkFILEStream inFile("../../experimental/Intersection/op.htm"); | 583 SkFILEStream inFile("../../experimental/Intersection/op.htm"); |
| 584 if (inFile.isValid()) { | 584 if (inFile.isValid()) { |
| 585 SkTDArray<char> inData; | 585 SkTDArray<char> inData; |
| 586 inData.setCount((int) inFile.getLength()); | 586 inData.setCount((int) inFile.getLength()); |
| 587 size_t inLen = inData.count(); | 587 size_t inLen = inData.count(); |
| 588 inFile.read(inData.begin(), inLen); | 588 inFile.read(inData.begin(), inLen); |
| 589 inFile.setPath(NULL); | 589 inFile.setPath(nullptr); |
| 590 char* insert = strstr(inData.begin(), marker); | 590 char* insert = strstr(inData.begin(), marker); |
| 591 if (insert) { | 591 if (insert) { |
| 592 insert += sizeof(marker) - 1; | 592 insert += sizeof(marker) - 1; |
| 593 const char* numLoc = insert + 4 /* indent spaces */ + testNameSi
ze - 1; | 593 const char* numLoc = insert + 4 /* indent spaces */ + testNameSi
ze - 1; |
| 594 testNumber = atoi(numLoc) + 1; | 594 testNumber = atoi(numLoc) + 1; |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 } | 598 } |
| 599 | 599 |
| 600 void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFill
Type) { | 600 void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFill
Type) { |
| 601 const char testFunction[] = "testSimplify(path);"; | 601 const char testFunction[] = "testSimplify(path);"; |
| 602 const char* pathPrefix = NULL; | 602 const char* pathPrefix = nullptr; |
| 603 const char* nameSuffix = NULL; | 603 const char* nameSuffix = nullptr; |
| 604 if (pathFillType == SkPath::kEvenOdd_FillType) { | 604 if (pathFillType == SkPath::kEvenOdd_FillType) { |
| 605 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; | 605 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; |
| 606 nameSuffix = "x"; | 606 nameSuffix = "x"; |
| 607 } | 607 } |
| 608 SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE); | 608 SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE); |
| 609 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, rRamStr
eam); | 609 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, rRamStr
eam); |
| 610 } | 610 } |
| 611 | 611 |
| 612 void outputProgress(char* ramStr, const char* pathStr, SkPathOp op) { | 612 void outputProgress(char* ramStr, const char* pathStr, SkPathOp op) { |
| 613 const char testFunction[] = "testOp(path);"; | 613 const char testFunction[] = "testOp(path);"; |
| 614 SkASSERT((size_t) op < SK_ARRAY_COUNT(opSuffixes)); | 614 SkASSERT((size_t) op < SK_ARRAY_COUNT(opSuffixes)); |
| 615 const char* nameSuffix = opSuffixes[op]; | 615 const char* nameSuffix = opSuffixes[op]; |
| 616 SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE); | 616 SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE); |
| 617 outputToStream(pathStr, NULL, nameSuffix, testFunction, true, rRamStream); | 617 outputToStream(pathStr, nullptr, nameSuffix, testFunction, true, rRamStream)
; |
| 618 } | 618 } |
| 619 | 619 |
| 620 void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count, | 620 void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count, |
| 621 void (*firstTest)(skiatest::Reporter* , const char* filename), | 621 void (*firstTest)(skiatest::Reporter* , const char* filename), |
| 622 void (*skipTest)(skiatest::Reporter* , const char* filename), | 622 void (*skipTest)(skiatest::Reporter* , const char* filename), |
| 623 void (*stopTest)(skiatest::Reporter* , const char* filename), bo
ol reverse) { | 623 void (*stopTest)(skiatest::Reporter* , const char* filename), bo
ol reverse) { |
| 624 size_t index; | 624 size_t index; |
| 625 if (firstTest) { | 625 if (firstTest) { |
| 626 index = count - 1; | 626 index = count - 1; |
| 627 while (index > 0 && tests[index].fun != firstTest) { | 627 while (index > 0 && tests[index].fun != firstTest) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 if (foundSkip && tests[index].fun != firstTest) { | 672 if (foundSkip && tests[index].fun != firstTest) { |
| 673 SkDebugf(" %s,\n", tests[index].str); | 673 SkDebugf(" %s,\n", tests[index].str); |
| 674 } | 674 } |
| 675 if (tests[index].fun == stopTest || index == last) { | 675 if (tests[index].fun == stopTest || index == last) { |
| 676 break; | 676 break; |
| 677 } | 677 } |
| 678 index += reverse ? -1 : 1; | 678 index += reverse ? -1 : 1; |
| 679 } while (true); | 679 } while (true); |
| 680 #endif | 680 #endif |
| 681 } | 681 } |
| OLD | NEW |