Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tests/SkpSkGrTest.cpp

Issue 540013002: Revert of SkThreadPool ~~> SkTaskGroup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/PathOpsTightBoundsTest.cpp ('k') | tests/Test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkTaskGroup.h" 26 #include "SkThreadPool.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
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) 128 SkpSkGrThreadedTestRunner(skiatest::Reporter* reporter, int threadCount)
129 : fReporter(reporter) { 129 : fNumThreads(threadCount)
130 , fReporter(reporter) {
130 } 131 }
131 132
132 ~SkpSkGrThreadedTestRunner(); 133 ~SkpSkGrThreadedTestRunner();
133 void render(); 134 void render();
135 int fNumThreads;
134 SkTDArray<SkpSkGrThreadedRunnable*> fRunnables; 136 SkTDArray<SkpSkGrThreadedRunnable*> fRunnables;
135 skiatest::Reporter* fReporter; 137 skiatest::Reporter* fReporter;
136 }; 138 };
137 139
138 class SkpSkGrThreadedRunnable : public SkRunnable { 140 class SkpSkGrThreadedRunnable : public SkRunnable {
139 public: 141 public:
140 SkpSkGrThreadedRunnable(void (*testFun)(SkpSkGrThreadState*), int dirNo, con st char* str, 142 SkpSkGrThreadedRunnable(void (*testFun)(SkpSkGrThreadState*), int dirNo, con st char* str,
141 SkpSkGrThreadedTestRunner* runner) { 143 SkpSkGrThreadedTestRunner* runner) {
142 SkASSERT(strlen(str) < sizeof(fState.fResult.fFilename) - 1); 144 SkASSERT(strlen(str) < sizeof(fState.fResult.fFilename) - 1);
143 fState.init(dirNo); 145 fState.init(dirNo);
(...skipping 11 matching lines...) Expand all
155 void (*fTestFun)(SkpSkGrThreadState*); 157 void (*fTestFun)(SkpSkGrThreadState*);
156 }; 158 };
157 159
158 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() { 160 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() {
159 for (int index = 0; index < fRunnables.count(); index++) { 161 for (int index = 0; index < fRunnables.count(); index++) {
160 SkDELETE(fRunnables[index]); 162 SkDELETE(fRunnables[index]);
161 } 163 }
162 } 164 }
163 165
164 void SkpSkGrThreadedTestRunner::render() { 166 void SkpSkGrThreadedTestRunner::render() {
165 SkTaskGroup tg; 167 SkThreadPool pool(fNumThreads);
166 for (int index = 0; index < fRunnables.count(); ++ index) { 168 for (int index = 0; index < fRunnables.count(); ++ index) {
167 tg.add(fRunnables[index]); 169 pool.add(fRunnables[index]);
168 } 170 }
169 } 171 }
170 172
171 //////////////////////////////////////////////// 173 ////////////////////////////////////////////////
172 174
173 static const char outGrDir[] = OUT_DIR "grTest"; 175 static const char outGrDir[] = OUT_DIR "grTest";
174 static const char outSkDir[] = OUT_DIR "skTest"; 176 static const char outSkDir[] = OUT_DIR "skTest";
175 static const char outSkpDir[] = OUT_DIR "skpTest"; 177 static const char outSkpDir[] = OUT_DIR "skpTest";
176 static const char outDiffDir[] = OUT_DIR "outTest"; 178 static const char outDiffDir[] = OUT_DIR "outTest";
177 static const char outStatusDir[] = OUT_DIR "statusTest"; 179 static const char outStatusDir[] = OUT_DIR "statusTest";
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 static void testSkGrMain(SkpSkGrThreadState* data) { 669 static void testSkGrMain(SkpSkGrThreadState* data) {
668 data->fResult.testOne(); 670 data->fResult.testOne();
669 bumpCount(data->fReporter, false); 671 bumpCount(data->fReporter, false);
670 data->fReporter->bumpTestCount(); 672 data->fReporter->bumpTestCount();
671 } 673 }
672 674
673 DEF_TEST(SkpSkGrThreaded, reporter) { 675 DEF_TEST(SkpSkGrThreaded, reporter) {
674 if (!initTest()) { 676 if (!initTest()) {
675 return; 677 return;
676 } 678 }
677 SkpSkGrThreadedTestRunner testRunner(reporter); 679 int threadCount = reporter->allowThreaded() ? 3 : 1;
680 SkpSkGrThreadedTestRunner testRunner(reporter, threadCount);
678 for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) { 681 for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) {
679 SkString pictDir = make_in_dir_name(dirIndex); 682 SkString pictDir = make_in_dir_name(dirIndex);
680 if (pictDir.size() == 0) { 683 if (pictDir.size() == 0) {
681 continue; 684 continue;
682 } 685 }
683 SkOSFile::Iter iter(pictDir.c_str(), "skp"); 686 SkOSFile::Iter iter(pictDir.c_str(), "skp");
684 SkString filename; 687 SkString filename;
685 while (iter.next(&filename)) { 688 while (iter.next(&filename)) {
686 SkString pngName = make_png_name(filename.c_str()); 689 SkString pngName = make_png_name(filename.c_str());
687 SkString oldPng = make_filepath(dirIndex, outSkDir, pngName.c_str()) ; 690 SkString oldPng = make_filepath(dirIndex, outSkDir, pngName.c_str()) ;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 int testIndex = 166; 746 int testIndex = 166;
744 int dirIndex = skipOverSkGr[testIndex - 166].directory; 747 int dirIndex = skipOverSkGr[testIndex - 166].directory;
745 SkString pictDir = make_in_dir_name(dirIndex); 748 SkString pictDir = make_in_dir_name(dirIndex);
746 if (pictDir.size() == 0) { 749 if (pictDir.size() == 0) {
747 return; 750 return;
748 } 751 }
749 SkString filename(skipOverSkGr[testIndex - 166].filename); 752 SkString filename(skipOverSkGr[testIndex - 166].filename);
750 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ()); 753 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ());
751 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ()); 754 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ());
752 } 755 }
OLDNEW
« no previous file with comments | « tests/PathOpsTightBoundsTest.cpp ('k') | tests/Test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698