OLD | NEW |
1 #if !SK_SUPPORT_GPU | 1 #if !SK_SUPPORT_GPU |
2 #error "GPU support required" | 2 #error "GPU support required" |
3 #endif | 3 #endif |
4 | 4 |
5 #include "GrContext.h" | 5 #include "GrContext.h" |
6 #include "GrContextFactory.h" | 6 #include "GrContextFactory.h" |
7 #include "GrRenderTarget.h" | 7 #include "GrRenderTarget.h" |
8 #include "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 #include "gl/GrGLDefines.h" | 9 #include "gl/GrGLDefines.h" |
10 | 10 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkColor.h" | 13 #include "SkColor.h" |
14 #include "SkDevice.h" | 14 #include "SkDevice.h" |
15 #include "SkGraphics.h" | 15 #include "SkGraphics.h" |
16 #include "SkImageDecoder.h" | 16 #include "SkImageDecoder.h" |
17 #include "SkImageEncoder.h" | 17 #include "SkImageEncoder.h" |
18 #include "SkOSFile.h" | 18 #include "SkOSFile.h" |
19 #include "SkPicture.h" | 19 #include "SkPicture.h" |
20 #include "SkRTConf.h" | 20 #include "SkRTConf.h" |
21 #include "SkRunnable.h" | 21 #include "SkRunnable.h" |
22 #include "SkStream.h" | 22 #include "SkStream.h" |
23 #include "SkString.h" | 23 #include "SkString.h" |
24 #include "SkTArray.h" | 24 #include "SkTArray.h" |
25 #include "SkTDArray.h" | 25 #include "SkTDArray.h" |
26 #include "SkThreadPool.h" | 26 #include "SkTaskGroup.h" |
27 #include "SkTime.h" | 27 #include "SkTime.h" |
28 #include "Test.h" | 28 #include "Test.h" |
29 | 29 |
30 #ifdef SK_BUILD_FOR_WIN | 30 #ifdef SK_BUILD_FOR_WIN |
31 #define PATH_SLASH "\\" | 31 #define PATH_SLASH "\\" |
32 #define IN_DIR "D:\\9-30-13\\" | 32 #define IN_DIR "D:\\9-30-13\\" |
33 #define OUT_DIR "D:\\skpSkGr\\11\\" | 33 #define OUT_DIR "D:\\skpSkGr\\11\\" |
34 #define LINE_FEED "\r\n" | 34 #define LINE_FEED "\r\n" |
35 #else | 35 #else |
36 #define PATH_SLASH "/" | 36 #define PATH_SLASH "/" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 char fFilesFound[kMaxFiles][kMaxLength]; | 118 char fFilesFound[kMaxFiles][kMaxLength]; |
119 int fDirsFound[kMaxFiles]; | 119 int fDirsFound[kMaxFiles]; |
120 int fError[kMaxFiles]; | 120 int fError[kMaxFiles]; |
121 int fFoundCount; | 121 int fFoundCount; |
122 int fSmallestError; | 122 int fSmallestError; |
123 skiatest::Reporter* fReporter; | 123 skiatest::Reporter* fReporter; |
124 TestResult fResult; | 124 TestResult fResult; |
125 }; | 125 }; |
126 | 126 |
127 struct SkpSkGrThreadedTestRunner { | 127 struct SkpSkGrThreadedTestRunner { |
128 SkpSkGrThreadedTestRunner(skiatest::Reporter* reporter, int threadCount) | 128 SkpSkGrThreadedTestRunner(skiatest::Reporter* reporter) |
129 : fNumThreads(threadCount) | 129 : fReporter(reporter) { |
130 , fReporter(reporter) { | |
131 } | 130 } |
132 | 131 |
133 ~SkpSkGrThreadedTestRunner(); | 132 ~SkpSkGrThreadedTestRunner(); |
134 void render(); | 133 void render(); |
135 int fNumThreads; | |
136 SkTDArray<SkpSkGrThreadedRunnable*> fRunnables; | 134 SkTDArray<SkpSkGrThreadedRunnable*> fRunnables; |
137 skiatest::Reporter* fReporter; | 135 skiatest::Reporter* fReporter; |
138 }; | 136 }; |
139 | 137 |
140 class SkpSkGrThreadedRunnable : public SkRunnable { | 138 class SkpSkGrThreadedRunnable : public SkRunnable { |
141 public: | 139 public: |
142 SkpSkGrThreadedRunnable(void (*testFun)(SkpSkGrThreadState*), int dirNo, con
st char* str, | 140 SkpSkGrThreadedRunnable(void (*testFun)(SkpSkGrThreadState*), int dirNo, con
st char* str, |
143 SkpSkGrThreadedTestRunner* runner) { | 141 SkpSkGrThreadedTestRunner* runner) { |
144 SkASSERT(strlen(str) < sizeof(fState.fResult.fFilename) - 1); | 142 SkASSERT(strlen(str) < sizeof(fState.fResult.fFilename) - 1); |
145 fState.init(dirNo); | 143 fState.init(dirNo); |
(...skipping 11 matching lines...) Expand all Loading... |
157 void (*fTestFun)(SkpSkGrThreadState*); | 155 void (*fTestFun)(SkpSkGrThreadState*); |
158 }; | 156 }; |
159 | 157 |
160 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() { | 158 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() { |
161 for (int index = 0; index < fRunnables.count(); index++) { | 159 for (int index = 0; index < fRunnables.count(); index++) { |
162 SkDELETE(fRunnables[index]); | 160 SkDELETE(fRunnables[index]); |
163 } | 161 } |
164 } | 162 } |
165 | 163 |
166 void SkpSkGrThreadedTestRunner::render() { | 164 void SkpSkGrThreadedTestRunner::render() { |
167 SkThreadPool pool(fNumThreads); | 165 SkTaskGroup tg; |
168 for (int index = 0; index < fRunnables.count(); ++ index) { | 166 for (int index = 0; index < fRunnables.count(); ++ index) { |
169 pool.add(fRunnables[index]); | 167 tg.add(fRunnables[index]); |
170 } | 168 } |
171 } | 169 } |
172 | 170 |
173 //////////////////////////////////////////////// | 171 //////////////////////////////////////////////// |
174 | 172 |
175 static const char outGrDir[] = OUT_DIR "grTest"; | 173 static const char outGrDir[] = OUT_DIR "grTest"; |
176 static const char outSkDir[] = OUT_DIR "skTest"; | 174 static const char outSkDir[] = OUT_DIR "skTest"; |
177 static const char outSkpDir[] = OUT_DIR "skpTest"; | 175 static const char outSkpDir[] = OUT_DIR "skpTest"; |
178 static const char outDiffDir[] = OUT_DIR "outTest"; | 176 static const char outDiffDir[] = OUT_DIR "outTest"; |
179 static const char outStatusDir[] = OUT_DIR "statusTest"; | 177 static const char outStatusDir[] = OUT_DIR "statusTest"; |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 static void testSkGrMain(SkpSkGrThreadState* data) { | 667 static void testSkGrMain(SkpSkGrThreadState* data) { |
670 data->fResult.testOne(); | 668 data->fResult.testOne(); |
671 bumpCount(data->fReporter, false); | 669 bumpCount(data->fReporter, false); |
672 data->fReporter->bumpTestCount(); | 670 data->fReporter->bumpTestCount(); |
673 } | 671 } |
674 | 672 |
675 DEF_TEST(SkpSkGrThreaded, reporter) { | 673 DEF_TEST(SkpSkGrThreaded, reporter) { |
676 if (!initTest()) { | 674 if (!initTest()) { |
677 return; | 675 return; |
678 } | 676 } |
679 int threadCount = reporter->allowThreaded() ? 3 : 1; | 677 SkpSkGrThreadedTestRunner testRunner(reporter); |
680 SkpSkGrThreadedTestRunner testRunner(reporter, threadCount); | |
681 for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) { | 678 for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) { |
682 SkString pictDir = make_in_dir_name(dirIndex); | 679 SkString pictDir = make_in_dir_name(dirIndex); |
683 if (pictDir.size() == 0) { | 680 if (pictDir.size() == 0) { |
684 continue; | 681 continue; |
685 } | 682 } |
686 SkOSFile::Iter iter(pictDir.c_str(), "skp"); | 683 SkOSFile::Iter iter(pictDir.c_str(), "skp"); |
687 SkString filename; | 684 SkString filename; |
688 while (iter.next(&filename)) { | 685 while (iter.next(&filename)) { |
689 SkString pngName = make_png_name(filename.c_str()); | 686 SkString pngName = make_png_name(filename.c_str()); |
690 SkString oldPng = make_filepath(dirIndex, outSkDir, pngName.c_str())
; | 687 SkString oldPng = make_filepath(dirIndex, outSkDir, pngName.c_str())
; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 int testIndex = 166; | 743 int testIndex = 166; |
747 int dirIndex = skipOverSkGr[testIndex - 166].directory; | 744 int dirIndex = skipOverSkGr[testIndex - 166].directory; |
748 SkString pictDir = make_in_dir_name(dirIndex); | 745 SkString pictDir = make_in_dir_name(dirIndex); |
749 if (pictDir.size() == 0) { | 746 if (pictDir.size() == 0) { |
750 return; | 747 return; |
751 } | 748 } |
752 SkString filename(skipOverSkGr[testIndex - 166].filename); | 749 SkString filename(skipOverSkGr[testIndex - 166].filename); |
753 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose
()); | 750 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose
()); |
754 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose
()); | 751 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose
()); |
755 } | 752 } |
OLD | NEW |