Chromium Code Reviews| Index: dm/DMTask.h |
| diff --git a/dm/DMTask.h b/dm/DMTask.h |
| index e8598df85e00ee6001b3f2571f356a4ae91d7daa..cad8234c05b5047c3c31ddff642d2ab7c210c9cf 100644 |
| --- a/dm/DMTask.h |
| +++ b/dm/DMTask.h |
| @@ -4,28 +4,21 @@ |
| #include "DMReporter.h" |
| #include "GrContextFactory.h" |
| #include "SkRunnable.h" |
| -#include "SkThreadPool.h" |
| -// DM will run() these tasks on one of two threadpools, depending on the result |
| -// of usesGpu(). The subclasses can call fail() to mark this task as failed, |
| -// or make any number of spawnChild() calls to kick off dependent tasks. |
| +// DM will run() these tasks on one of two threadpools. |
| +// Subclasses can call fail() to mark this task as failed, or make any number of spawnChild() calls |
| +// to kick off dependent tasks. |
| // |
| -// Task deletes itself when run. |
| +// Tasks delete themselves when run. |
| namespace DM { |
| class TaskRunner; |
| -class Task : public SkRunnable { |
| -public: |
| - Task(Reporter* reporter, TaskRunner* taskRunner); |
| - Task(const Task& parent); |
| - virtual ~Task(); |
| - |
| - void run() SK_OVERRIDE; |
| +class CpuTask; |
| - virtual void draw() = 0; |
| - virtual bool usesGpu() const = 0; |
| +class Task { |
| +public: |
| virtual bool shouldSkip() const = 0; |
| virtual SkString name() const = 0; |
| @@ -34,19 +27,37 @@ public: |
| int depth() const { return fDepth; } |
| protected: |
| - void spawnChild(Task* task); |
| - void fail(const char* msg = NULL); |
| + Task(Reporter* reporter, TaskRunner* taskRunner); |
| + Task(const Task& parent); |
| + virtual ~Task() {} |
| - // This can only be safely called from a GPU task's draw() method. |
| - GrContextFactory* getGrContextFactory() const; |
| + void fail(const char* msg = NULL); |
| + void finish(); |
| + void spawnChild(CpuTask* task); // For now we don't allow GPU child tasks. |
| private: |
| - // Both unowned. |
| - Reporter* fReporter; |
| - TaskRunner* fTaskRunner; |
| + Reporter* fReporter; // Unowned. |
| + TaskRunner* fTaskRunner; // Unowned. |
| int fDepth; |
| +}; |
| + |
| +class CpuTask : public Task, public SkRunnable { |
| +public: |
| + CpuTask(Reporter* reporter, TaskRunner* taskRunner); |
| + CpuTask(const Task& parent); |
| + virtual ~CpuTask() {} |
| + |
| + void run() SK_OVERRIDE; |
| + virtual void draw() = 0; |
| +}; |
| + |
| +class GpuTask : public Task, public SkTRunnable<GrContextFactory> { |
|
bsalomon
2014/02/28 16:40:49
AFAIK we have a policy against multiple inheritanc
mtklein
2014/02/28 17:18:13
If we do, this should be an exemption. There's on
bsalomon
2014/02/28 18:45:38
Forwarding your appeal to the supreme court for ju
|
| + public: |
| + GpuTask(Reporter* reporter, TaskRunner* taskRunner); |
| + virtual ~GpuTask() {} |
| - typedef SkRunnable INHERITED; |
| + void run(GrContextFactory&) SK_OVERRIDE; |
| + virtual void draw(GrContextFactory*) = 0; |
| }; |
| } // namespace DM |