blob: dd1440ed9accb50740ae56193b5045da7bf8582f [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#ifndef DMTaskRunner_DEFINED
2#define DMTaskRunner_DEFINED
3
commit-bot@chromium.org787227d2014-03-26 21:26:15 +00004#include "DMGpuSupport.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00005#include "SkThreadPool.h"
6#include "SkTypes.h"
7
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +00008// 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.comd36522d2013-10-16 13:02:15 +000010
11namespace DM {
12
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000013class CpuTask;
14class GpuTask;
mtklein@google.comd36522d2013-10-16 13:02:15 +000015
16class TaskRunner : SkNoncopyable {
17public:
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000018 explicit TaskRunner(int cpuThreads, int gpuThreads);
mtklein@google.comd36522d2013-10-16 13:02:15 +000019
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000020 void add(CpuTask* task);
commit-bot@chromium.org3f032152014-05-01 17:41:32 +000021 void addNext(CpuTask* task);
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000022 void add(GpuTask* task);
mtklein@google.comd36522d2013-10-16 13:02:15 +000023 void wait();
24
25private:
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000026 SkTThreadPool<void> fCpu;
27 SkTThreadPool<GrContextFactory> fGpu;
mtklein@google.comd36522d2013-10-16 13:02:15 +000028};
29
30} // namespace DM
31
32#endif // DMTaskRunner_DEFINED