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" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkForceLinking.h" |
12 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
13 #include "SkPaint.h" | 14 #include "SkPaint.h" |
14 #include "SkStream.h" | 15 #include "SkStream.h" |
15 #include "SkThreadPool.h" | 16 #include "SkThreadPool.h" |
16 | 17 |
17 #ifdef SK_BUILD_FOR_MAC | 18 #ifdef SK_BUILD_FOR_MAC |
18 #include <sys/sysctl.h> | 19 #include <sys/sysctl.h> |
19 #endif | 20 #endif |
20 | 21 |
| 22 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 23 |
21 static const char marker[] = | 24 static const char marker[] = |
22 "</div>\n" | 25 "</div>\n" |
23 "\n" | 26 "\n" |
24 "<script type=\"text/javascript\">\n" | 27 "<script type=\"text/javascript\">\n" |
25 "\n" | 28 "\n" |
26 "var testDivs = [\n"; | 29 "var testDivs = [\n"; |
27 | 30 |
28 static const char* opStrs[] = { | 31 static const char* opStrs[] = { |
29 "kDifference_PathOp", | 32 "kDifference_PathOp", |
30 "kIntersect_PathOp", | 33 "kIntersect_PathOp", |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, | 623 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
621 const SkPathOp shapeOp, const char* testName) { | 624 const SkPathOp shapeOp, const char* testName) { |
622 return innerPathOp(reporter, a, b, shapeOp, testName, false); | 625 return innerPathOp(reporter, a, b, shapeOp, testName, false); |
623 } | 626 } |
624 | 627 |
625 bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, | 628 bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
ath& b, |
626 const SkPathOp shapeOp, const char* testName) { | 629 const SkPathOp shapeOp, const char* testName) { |
627 return innerPathOp(reporter, a, b, shapeOp, testName, true); | 630 return innerPathOp(reporter, a, b, shapeOp, testName, true); |
628 } | 631 } |
629 | 632 |
| 633 SK_DECLARE_STATIC_MUTEX(gMutex); |
| 634 |
630 int initializeTests(skiatest::Reporter* reporter, const char* test) { | 635 int initializeTests(skiatest::Reporter* reporter, const char* test) { |
631 #ifdef SK_DEBUG | 636 #ifdef SK_DEBUG |
632 SkPathOpsDebug::gMaxWindSum = 4; | 637 SkPathOpsDebug::gMaxWindSum = 4; |
633 SkPathOpsDebug::gMaxWindValue = 4; | 638 SkPathOpsDebug::gMaxWindValue = 4; |
634 #endif | 639 #endif |
635 #if DEBUG_SHOW_TEST_NAME | 640 if (reporter->verbose()) { |
636 testName = test; | 641 SkAutoMutexAcquire lock(gMutex); |
637 size_t testNameSize = strlen(test); | 642 testName = test; |
638 SkFILEStream inFile("../../experimental/Intersection/op.htm"); | 643 size_t testNameSize = strlen(test); |
639 if (inFile.isValid()) { | 644 SkFILEStream inFile("../../experimental/Intersection/op.htm"); |
640 SkTDArray<char> inData; | 645 if (inFile.isValid()) { |
641 inData.setCount(inFile.getLength()); | 646 SkTDArray<char> inData; |
642 size_t inLen = inData.count(); | 647 inData.setCount(inFile.getLength()); |
643 inFile.read(inData.begin(), inLen); | 648 size_t inLen = inData.count(); |
644 inFile.setPath(NULL); | 649 inFile.read(inData.begin(), inLen); |
645 char* insert = strstr(inData.begin(), marker); | 650 inFile.setPath(NULL); |
646 if (insert) { | 651 char* insert = strstr(inData.begin(), marker); |
647 insert += sizeof(marker) - 1; | 652 if (insert) { |
648 const char* numLoc = insert + 4 /* indent spaces */ + testNameSize -
1; | 653 insert += sizeof(marker) - 1; |
649 testNumber = atoi(numLoc) + 1; | 654 const char* numLoc = insert + 4 /* indent spaces */ + testNameSi
ze - 1; |
| 655 testNumber = atoi(numLoc) + 1; |
| 656 } |
650 } | 657 } |
| 658 } else { |
| 659 testName = "pathOpTest"; |
| 660 testNumber = 1; |
651 } | 661 } |
652 #endif | |
653 return reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1; | 662 return reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1; |
654 } | 663 } |
655 | 664 |
656 void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFill
Type) { | 665 void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFill
Type) { |
657 const char testFunction[] = "testSimplify(path);"; | 666 const char testFunction[] = "testSimplify(path);"; |
658 const char* pathPrefix = NULL; | 667 const char* pathPrefix = NULL; |
659 const char* nameSuffix = NULL; | 668 const char* nameSuffix = NULL; |
660 if (pathFillType == SkPath::kEvenOdd_FillType) { | 669 if (pathFillType == SkPath::kEvenOdd_FillType) { |
661 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; | 670 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; |
662 nameSuffix = "x"; | 671 nameSuffix = "x"; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 } | 709 } |
701 if (tests[index].fun == stopTest) { | 710 if (tests[index].fun == stopTest) { |
702 SkDebugf("lastTest\n"); | 711 SkDebugf("lastTest\n"); |
703 } | 712 } |
704 if (index == last) { | 713 if (index == last) { |
705 break; | 714 break; |
706 } | 715 } |
707 index += reverse ? -1 : 1; | 716 index += reverse ? -1 : 1; |
708 } while (true); | 717 } while (true); |
709 } | 718 } |
OLD | NEW |