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