| OLD | NEW |
| 1 #ifndef DMTask_DEFINED | 1 #ifndef DMTask_DEFINED |
| 2 #define DMTask_DEFINED | 2 #define DMTask_DEFINED |
| 3 | 3 |
| 4 #include "DMReporter.h" |
| 4 #include "DMGpuSupport.h" | 5 #include "DMGpuSupport.h" |
| 5 #include "DMReporter.h" | |
| 6 #include "SkRunnable.h" | 6 #include "SkRunnable.h" |
| 7 #include "SkTaskGroup.h" | |
| 8 #include "SkTime.h" | 7 #include "SkTime.h" |
| 9 | 8 |
| 10 // DM will run() these tasks on one of two threadpools. | 9 // DM will run() these tasks on one of two threadpools. |
| 11 // Subclasses can call fail() to mark this task as failed, or make any number of
spawnChild() calls | 10 // Subclasses can call fail() to mark this task as failed, or make any number of
spawnChild() calls |
| 12 // to kick off dependent tasks. | 11 // to kick off dependent tasks. |
| 13 // | 12 // |
| 14 // Tasks delete themselves when run. | 13 // Tasks delete themselves when run. |
| 15 | 14 |
| 16 namespace DM { | 15 namespace DM { |
| 17 | 16 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 | 29 |
| 31 protected: | 30 protected: |
| 32 Task(Reporter* reporter, TaskRunner* taskRunner); | 31 Task(Reporter* reporter, TaskRunner* taskRunner); |
| 33 Task(const Task& parent); | 32 Task(const Task& parent); |
| 34 virtual ~Task(); | 33 virtual ~Task(); |
| 35 | 34 |
| 36 void start(); | 35 void start(); |
| 37 void fail(const char* msg = NULL); | 36 void fail(const char* msg = NULL); |
| 38 void finish(); | 37 void finish(); |
| 39 | 38 |
| 40 void reallySpawnChild(CpuTask* task); // For now we don't allow GPU child t
asks. | 39 void spawnChildNext(CpuTask* task); // For now we don't allow GPU child tas
ks. |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 Reporter* fReporter; // Unowned. | 42 Reporter* fReporter; // Unowned. |
| 44 TaskRunner* fTaskRunner; // Unowned. | 43 TaskRunner* fTaskRunner; // Unowned. |
| 45 int fDepth; | 44 int fDepth; |
| 46 SkMSec fStart; | 45 SkMSec fStart; |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 class CpuTask : public Task, public SkRunnable { | 48 class CpuTask : public Task, public SkRunnable { |
| 50 public: | 49 public: |
| 51 CpuTask(Reporter* reporter, TaskRunner* taskRunner); | 50 CpuTask(Reporter* reporter, TaskRunner* taskRunner); |
| 52 CpuTask(const Task& parent); | 51 CpuTask(const Task& parent); |
| 53 virtual ~CpuTask() {} | 52 virtual ~CpuTask() {} |
| 54 | 53 |
| 55 void run() SK_OVERRIDE; | 54 void run() SK_OVERRIDE; |
| 56 virtual void draw() = 0; | 55 virtual void draw() = 0; |
| 57 | 56 |
| 58 void spawnChild(CpuTask* task); | 57 void spawnChild(CpuTask* task); |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 class GpuTask : public Task { | 60 class GpuTask : public Task, public SkTRunnable<GrContextFactory> { |
| 62 public: | 61 public: |
| 63 GpuTask(Reporter* reporter, TaskRunner* taskRunner); | 62 GpuTask(Reporter* reporter, TaskRunner* taskRunner); |
| 64 virtual ~GpuTask() {} | 63 virtual ~GpuTask() {} |
| 65 | 64 |
| 66 void run(GrContextFactory*); | 65 void run(GrContextFactory&) SK_OVERRIDE; |
| 67 virtual void draw(GrContextFactory*) = 0; | 66 virtual void draw(GrContextFactory*) = 0; |
| 68 | 67 |
| 69 void spawnChild(CpuTask* task); | 68 void spawnChild(CpuTask* task); |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 } // namespace DM | 71 } // namespace DM |
| 73 | 72 |
| 74 #endif // DMTask_DEFINED | 73 #endif // DMTask_DEFINED |
| OLD | NEW |