blob: 744fd6bb9c0634fcee000e09960ea1eadfa91e71 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#ifndef DMTask_DEFINED
2#define DMTask_DEFINED
3
4#include "DMReporter.h"
5#include "SkRunnable.h"
6#include "SkThreadPool.h"
7
8// DM will run() these tasks on one of two threadpools, depending on the result
9// of usesGpu(). The subclasses can call fail() to mark this task as failed,
10// or make any number of spawnChild() calls to kick off dependent tasks.
11//
12// Task deletes itself when run.
13
14namespace DM {
15
16class TaskRunner;
17
18class Task : public SkRunnable {
19public:
20 Task(Reporter* reporter, TaskRunner* taskRunner);
21 Task(const Task& that);
22 virtual ~Task();
23
24 void run();
25
26 virtual void draw() = 0;
27 virtual bool usesGpu() const = 0;
28 virtual bool shouldSkip() const = 0;
29 virtual SkString name() const = 0;
30
31protected:
32 void spawnChild(Task* task);
33 void fail();
34
35private:
36 // Both unowned.
37 Reporter* fReporter;
38 TaskRunner* fTaskRunner;
39};
40
41} // namespace DM
42
43#endif // DMTask_DEFINED