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

Side by Side Diff: dm/DMTaskRunner.cpp

Issue 178273002: Let DM run unit tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 9 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 | « dm/DMTaskRunner.h ('k') | dm/DMTestTask.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 #include "DMTaskRunner.h" 1 #include "DMTaskRunner.h"
2 #include "DMTask.h" 2 #include "DMTask.h"
3 3
4 namespace DM { 4 namespace DM {
5 5
6 TaskRunner::TaskRunner(int cputhreads, int gpuThreads) 6
7 TaskRunner::TaskRunner(int cputhreads)
7 : fMain(cputhreads) 8 : fMain(cputhreads)
8 , fGpu(gpuThreads) 9 , fGpu(1) {
9 {} 10 // Enqueue a task on the GPU thread to create a GrContextFactory.
11 struct Create : public SkRunnable {
12 Create(GrContextFactory** ptr) : fPtr(ptr) {}
13 void run() SK_OVERRIDE {
14 *fPtr = SkNEW(GrContextFactory);
15 delete this;
16 }
17 GrContextFactory** fPtr;
18 };
19 fGpu.add(SkNEW_ARGS(Create, (&fGrContextFactory)));
20 }
10 21
11 void TaskRunner::add(Task* task) { 22 void TaskRunner::add(Task* task) {
12 if (task->usesGpu()) { 23 if (task->usesGpu()) {
13 fGpu.add(task); 24 fGpu.add(task);
14 } else { 25 } else {
15 fMain.add(task); 26 fMain.add(task);
16 } 27 }
17 } 28 }
18 29
19 void TaskRunner::wait() { 30 void TaskRunner::wait() {
31 // Enqueue a task on the GPU thread to destroy the GrContextFactory.
32 struct Delete : public SkRunnable {
33 Delete(GrContextFactory* ptr) : fPtr(ptr) {}
34 void run() SK_OVERRIDE {
35 delete fPtr;
36 delete this;
37 }
38 GrContextFactory* fPtr;
39 };
40 fGpu.add(SkNEW_ARGS(Delete, (fGrContextFactory)));
41
20 // These wait calls block until the threadpool is done. We don't allow 42 // These wait calls block until the threadpool is done. We don't allow
21 // children to spawn new GPU tasks so we can wait for that first knowing 43 // children to spawn new GPU tasks so we can wait for that first knowing
22 // we'll never try to add to it later. Same can't be said of fMain: fGpu 44 // we'll never try to add to it later. Same can't be said of fMain: fGpu
23 // and fMain can both add tasks to fMain, so we have to wait for that last. 45 // and fMain can both add tasks to fMain, so we have to wait for that last.
24 fGpu.wait(); 46 fGpu.wait();
25 fMain.wait(); 47 fMain.wait();
26 } 48 }
27 49
28 } // namespace DM 50 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMTaskRunner.h ('k') | dm/DMTestTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698