OLD | NEW |
1 #ifndef DMTaskRunner_DEFINED | 1 #ifndef DMTaskRunner_DEFINED |
2 #define DMTaskRunner_DEFINED | 2 #define DMTaskRunner_DEFINED |
3 | 3 |
4 #include "GrContextFactory.h" | 4 #include "GrContextFactory.h" |
5 #include "SkThreadPool.h" | 5 #include "SkThreadPool.h" |
6 #include "SkTypes.h" | 6 #include "SkTypes.h" |
7 | 7 |
8 // TaskRunner runs Tasks on one of two threadpools depending on the Task's usesG
pu() method. This | 8 // TaskRunner runs Tasks on one of two threadpools depending on the need for a G
rContextFactory. |
9 // lets us drive the GPU from a single thread while parallelizing CPU-bound work
. | 9 // It's typically a good idea to run fewer GPU threads than CPU threads (go nuts
with those). |
10 | 10 |
11 namespace DM { | 11 namespace DM { |
12 | 12 |
13 class Task; | 13 class CpuTask; |
| 14 class GpuTask; |
14 | 15 |
15 class TaskRunner : SkNoncopyable { | 16 class TaskRunner : SkNoncopyable { |
16 public: | 17 public: |
17 explicit TaskRunner(int cputhreads); | 18 explicit TaskRunner(int cpuThreads, int gpuThreads); |
18 | 19 |
19 void add(Task* task); | 20 void add(CpuTask* task); |
| 21 void add(GpuTask* task); |
20 void wait(); | 22 void wait(); |
21 | 23 |
22 // This can only be safely called from a GPU task's draw() method. | |
23 GrContextFactory* getGrContextFactory() const { return fGrContextFactory; } | |
24 | |
25 private: | 24 private: |
26 SkThreadPool fMain, fGpu; | 25 SkTThreadPool<void> fCpu; |
27 GrContextFactory* fGrContextFactory; // Created and destroyed on fGpu threa
dpool. | 26 SkTThreadPool<GrContextFactory> fGpu; |
28 }; | 27 }; |
29 | 28 |
30 } // namespace DM | 29 } // namespace DM |
31 | 30 |
32 #endif // DMTaskRunner_DEFINED | 31 #endif // DMTaskRunner_DEFINED |
OLD | NEW |