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

Side by Side Diff: tests/SkpSkGrTest.cpp

Issue 1184373003: Add sk_parallel_for() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 5 years, 6 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/PathOpsThreadedCommon.cpp ('k') | tools/skpdiff/SkDiffContext.cpp » ('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 /*
2 #error "GPU support required" 2 * Copyright 2013 Google Inc.
3 #endif 3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
4 7
5 #include "GrContext.h" 8 #include "GrContext.h"
6 #include "GrContextFactory.h" 9 #include "GrContextFactory.h"
7 #include "GrRenderTarget.h" 10 #include "GrRenderTarget.h"
8 #include "SkGpuDevice.h" 11 #include "SkGpuDevice.h"
9 #include "gl/GrGLDefines.h" 12 #include "gl/GrGLDefines.h"
10 13
11 #include "SkBitmap.h" 14 #include "SkBitmap.h"
12 #include "SkCanvas.h" 15 #include "SkCanvas.h"
13 #include "SkColor.h" 16 #include "SkColor.h"
14 #include "SkDevice.h" 17 #include "SkDevice.h"
15 #include "SkGraphics.h" 18 #include "SkGraphics.h"
16 #include "SkImageDecoder.h" 19 #include "SkImageDecoder.h"
17 #include "SkImageEncoder.h" 20 #include "SkImageEncoder.h"
18 #include "SkOSFile.h" 21 #include "SkOSFile.h"
19 #include "SkPicture.h" 22 #include "SkPicture.h"
20 #include "SkRTConf.h" 23 #include "SkRTConf.h"
21 #include "SkRunnable.h" 24 #include "SkRunnable.h"
22 #include "SkStream.h" 25 #include "SkStream.h"
23 #include "SkString.h" 26 #include "SkString.h"
24 #include "SkTArray.h" 27 #include "SkTArray.h"
25 #include "SkTDArray.h" 28 #include "SkTDArray.h"
26 #include "SkTaskGroup.h" 29 #include "SkTaskGroup.h"
27 #include "SkTime.h" 30 #include "SkTime.h"
28 #include "Test.h" 31 #include "Test.h"
29 32
33 #if !SK_SUPPORT_GPU
34 #error "GPU support required"
35 #endif
36
30 #ifdef SK_BUILD_FOR_WIN 37 #ifdef SK_BUILD_FOR_WIN
31 #define PATH_SLASH "\\" 38 #define PATH_SLASH "\\"
32 #define IN_DIR "D:\\9-30-13\\" 39 #define IN_DIR "D:\\9-30-13\\"
33 #define OUT_DIR "D:\\skpSkGr\\11\\" 40 #define OUT_DIR "D:\\skpSkGr\\11\\"
34 #define LINE_FEED "\r\n" 41 #define LINE_FEED "\r\n"
35 #else 42 #else
36 #define PATH_SLASH "/" 43 #define PATH_SLASH "/"
37 #define IN_DIR "/usr/local/google/home/caryclark" PATH_SLASH "9-30-13-skp" 44 #define IN_DIR "/usr/local/google/home/caryclark" PATH_SLASH "9-30-13-skp"
38 #define OUT_DIR "/media/01CD75512A7F9EE0/4" PATH_SLASH 45 #define OUT_DIR "/media/01CD75512A7F9EE0/4" PATH_SLASH
39 #define LINE_FEED "\n" 46 #define LINE_FEED "\n"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 void (*fTestFun)(SkpSkGrThreadState*); 162 void (*fTestFun)(SkpSkGrThreadState*);
156 }; 163 };
157 164
158 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() { 165 SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() {
159 for (int index = 0; index < fRunnables.count(); index++) { 166 for (int index = 0; index < fRunnables.count(); index++) {
160 SkDELETE(fRunnables[index]); 167 SkDELETE(fRunnables[index]);
161 } 168 }
162 } 169 }
163 170
164 void SkpSkGrThreadedTestRunner::render() { 171 void SkpSkGrThreadedTestRunner::render() {
165 SkTaskGroup tg; 172 // TODO: we don't really need to be using SkRunnables here anymore.
166 for (int index = 0; index < fRunnables.count(); ++ index) { 173 // We can just write the code we'd run right in the for loop.
167 tg.add(fRunnables[index]); 174 sk_parallel_for(fRunnables.count(), [&](int i) {
168 } 175 fRunnables[i]->run();
176 });
169 } 177 }
170 178
171 //////////////////////////////////////////////// 179 ////////////////////////////////////////////////
172 180
173 static const char outGrDir[] = OUT_DIR "grTest"; 181 static const char outGrDir[] = OUT_DIR "grTest";
174 static const char outSkDir[] = OUT_DIR "skTest"; 182 static const char outSkDir[] = OUT_DIR "skTest";
175 static const char outSkpDir[] = OUT_DIR "skpTest"; 183 static const char outSkpDir[] = OUT_DIR "skpTest";
176 static const char outDiffDir[] = OUT_DIR "outTest"; 184 static const char outDiffDir[] = OUT_DIR "outTest";
177 static const char outStatusDir[] = OUT_DIR "statusTest"; 185 static const char outStatusDir[] = OUT_DIR "statusTest";
178 186
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 int testIndex = 166; 751 int testIndex = 166;
744 int dirIndex = skipOverSkGr[testIndex - 166].directory; 752 int dirIndex = skipOverSkGr[testIndex - 166].directory;
745 SkString pictDir = make_in_dir_name(dirIndex); 753 SkString pictDir = make_in_dir_name(dirIndex);
746 if (pictDir.size() == 0) { 754 if (pictDir.size() == 0) {
747 return; 755 return;
748 } 756 }
749 SkString filename(skipOverSkGr[testIndex - 166].filename); 757 SkString filename(skipOverSkGr[testIndex - 166].filename);
750 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ()); 758 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ());
751 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ()); 759 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ());
752 } 760 }
OLDNEW
« no previous file with comments | « tests/PathOpsThreadedCommon.cpp ('k') | tools/skpdiff/SkDiffContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698