mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #ifndef DMTaskRunner_DEFINED |
| 2 | #define DMTaskRunner_DEFINED |
| 3 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 4 | #include "DMGpuSupport.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 5 | #include "SkThreadPool.h" |
| 6 | #include "SkTypes.h" |
| 7 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 8 | // TaskRunner runs Tasks on one of two threadpools depending on the need for a GrContextFactory. |
| 9 | // It's typically a good idea to run fewer GPU threads than CPU threads (go nuts with those). |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 10 | |
| 11 | namespace DM { |
| 12 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 13 | class CpuTask; |
| 14 | class GpuTask; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 15 | |
| 16 | class TaskRunner : SkNoncopyable { |
| 17 | public: |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 18 | explicit TaskRunner(int cpuThreads, int gpuThreads); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 19 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 20 | void add(CpuTask* task); |
commit-bot@chromium.org | 3f03215 | 2014-05-01 17:41:32 +0000 | [diff] [blame] | 21 | void addNext(CpuTask* task); |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 22 | void add(GpuTask* task); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 23 | void wait(); |
| 24 | |
| 25 | private: |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 26 | SkTThreadPool<void> fCpu; |
| 27 | SkTThreadPool<GrContextFactory> fGpu; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | } // namespace DM |
| 31 | |
| 32 | #endif // DMTaskRunner_DEFINED |