| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrContext.h" | 8 #include "GrContext.h" |
| 9 #include "GrContextFactory.h" | 9 #include "GrContextFactory.h" |
| 10 #include "GrRenderTarget.h" | 10 #include "GrRenderTarget.h" |
| 11 #include "SkGpuDevice.h" | 11 #include "SkGpuDevice.h" |
| 12 #include "gl/GrGLDefines.h" | 12 #include "gl/GrGLDefines.h" |
| 13 | 13 |
| 14 #include "SkBitmap.h" | 14 #include "SkBitmap.h" |
| 15 #include "SkCanvas.h" | 15 #include "SkCanvas.h" |
| 16 #include "SkColor.h" | 16 #include "SkColor.h" |
| 17 #include "SkDevice.h" | 17 #include "SkDevice.h" |
| 18 #include "SkGraphics.h" | 18 #include "SkGraphics.h" |
| 19 #include "SkImageDecoder.h" | 19 #include "SkImageDecoder.h" |
| 20 #include "SkImageEncoder.h" | 20 #include "SkImageEncoder.h" |
| 21 #include "SkOSFile.h" | 21 #include "SkOSFile.h" |
| 22 #include "SkPicture.h" | 22 #include "SkPicture.h" |
| 23 #include "SkRTConf.h" | 23 #include "SkRTConf.h" |
| 24 #include "SkRunnable.h" | |
| 25 #include "SkStream.h" | 24 #include "SkStream.h" |
| 26 #include "SkString.h" | 25 #include "SkString.h" |
| 27 #include "SkTArray.h" | 26 #include "SkTArray.h" |
| 28 #include "SkTDArray.h" | 27 #include "SkTDArray.h" |
| 29 #include "SkTaskGroup.h" | 28 #include "SkTaskGroup.h" |
| 30 #include "SkTime.h" | 29 #include "SkTime.h" |
| 31 #include "Test.h" | 30 #include "Test.h" |
| 32 | 31 |
| 33 #if !SK_SUPPORT_GPU | 32 #if !SK_SUPPORT_GPU |
| 34 #error "GPU support required" | 33 #error "GPU support required" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 SkpSkGrThreadedTestRunner(skiatest::Reporter* reporter) | 134 SkpSkGrThreadedTestRunner(skiatest::Reporter* reporter) |
| 136 : fReporter(reporter) { | 135 : fReporter(reporter) { |
| 137 } | 136 } |
| 138 | 137 |
| 139 ~SkpSkGrThreadedTestRunner(); | 138 ~SkpSkGrThreadedTestRunner(); |
| 140 void render(); | 139 void render(); |
| 141 SkTDArray<SkpSkGrThreadedRunnable*> fRunnables; | 140 SkTDArray<SkpSkGrThreadedRunnable*> fRunnables; |
| 142 skiatest::Reporter* fReporter; | 141 skiatest::Reporter* fReporter; |
| 143 }; | 142 }; |
| 144 | 143 |
| 145 class SkpSkGrThreadedRunnable : public SkRunnable { | 144 class SkpSkGrThreadedRunnable { |
| 146 public: | 145 public: |
| 147 SkpSkGrThreadedRunnable(void (*testFun)(SkpSkGrThreadState*), int dirNo, con
st char* str, | 146 SkpSkGrThreadedRunnable(void (*testFun)(SkpSkGrThreadState*), int dirNo, con
st char* str, |
| 148 SkpSkGrThreadedTestRunner* runner) { | 147 SkpSkGrThreadedTestRunner* runner) { |
| 149 SkASSERT(strlen(str) < sizeof(fState.fResult.fFilename) - 1); | 148 SkASSERT(strlen(str) < sizeof(fState.fResult.fFilename) - 1); |
| 150 fState.init(dirNo); | 149 fState.init(dirNo); |
| 151 strcpy(fState.fResult.fFilename, str); | 150 strcpy(fState.fResult.fFilename, str); |
| 152 fState.fReporter = runner->fReporter; | 151 fState.fReporter = runner->fReporter; |
| 153 fTestFun = testFun; | 152 fTestFun = testFun; |
| 154 } | 153 } |
| 155 | 154 |
| 156 void run() override { | 155 void operator()() { |
| 157 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); | 156 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); |
| 158 (*fTestFun)(&fState); | 157 (*fTestFun)(&fState); |
| 159 } | 158 } |
| 160 | 159 |
| 161 SkpSkGrThreadState fState; | 160 SkpSkGrThreadState fState; |
| 162 void (*fTestFun)(SkpSkGrThreadState*); | 161 void (*fTestFun)(SkpSkGrThreadState*); |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() { | 164 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() { |
| 166 for (int index = 0; index < fRunnables.count(); index++) { | 165 for (int index = 0; index < fRunnables.count(); index++) { |
| 167 delete fRunnables[index]; | 166 delete fRunnables[index]; |
| 168 } | 167 } |
| 169 } | 168 } |
| 170 | 169 |
| 171 void SkpSkGrThreadedTestRunner::render() { | 170 void SkpSkGrThreadedTestRunner::render() { |
| 172 // TODO: we don't really need to be using SkRunnables here anymore. | |
| 173 // We can just write the code we'd run right in the for loop. | |
| 174 SkTaskGroup().batch(fRunnables.count(), [&](int i) { | 171 SkTaskGroup().batch(fRunnables.count(), [&](int i) { |
| 175 fRunnables[i]->run(); | 172 fRunnables[i](); |
| 176 }); | 173 }); |
| 177 } | 174 } |
| 178 | 175 |
| 179 //////////////////////////////////////////////// | 176 //////////////////////////////////////////////// |
| 180 | 177 |
| 181 static const char outGrDir[] = OUT_DIR "grTest"; | 178 static const char outGrDir[] = OUT_DIR "grTest"; |
| 182 static const char outSkDir[] = OUT_DIR "skTest"; | 179 static const char outSkDir[] = OUT_DIR "skTest"; |
| 183 static const char outSkpDir[] = OUT_DIR "skpTest"; | 180 static const char outSkpDir[] = OUT_DIR "skpTest"; |
| 184 static const char outDiffDir[] = OUT_DIR "outTest"; | 181 static const char outDiffDir[] = OUT_DIR "outTest"; |
| 185 static const char outStatusDir[] = OUT_DIR "statusTest"; | 182 static const char outStatusDir[] = OUT_DIR "statusTest"; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 int testIndex = 166; | 748 int testIndex = 166; |
| 752 int dirIndex = skipOverSkGr[testIndex - 166].directory; | 749 int dirIndex = skipOverSkGr[testIndex - 166].directory; |
| 753 SkString pictDir = make_in_dir_name(dirIndex); | 750 SkString pictDir = make_in_dir_name(dirIndex); |
| 754 if (pictDir.size() == 0) { | 751 if (pictDir.size() == 0) { |
| 755 return; | 752 return; |
| 756 } | 753 } |
| 757 SkString filename(skipOverSkGr[testIndex - 166].filename); | 754 SkString filename(skipOverSkGr[testIndex - 166].filename); |
| 758 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose
()); | 755 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose
()); |
| 759 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose
()); | 756 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose
()); |
| 760 } | 757 } |
| OLD | NEW |