Index: dm/DMTask.cpp |
diff --git a/dm/DMTask.cpp b/dm/DMTask.cpp |
index d26971c8903c9ec8363a8f56c130c497487e2dc9..1c4cc25693be54962990808caade6e7cdb84f60a 100644 |
--- a/dm/DMTask.cpp |
+++ b/dm/DMTask.cpp |
@@ -1,53 +1,59 @@ |
#include "DMTask.h" |
- |
#include "DMTaskRunner.h" |
-#include "DMUtil.h" |
-#include "SkBitmap.h" |
-#include "SkCommandLineFlags.h" |
namespace DM { |
Task::Task(Reporter* reporter, TaskRunner* taskRunner) |
- : fReporter(reporter), fTaskRunner(taskRunner), fDepth(0) { |
+ : fReporter(reporter) |
+ , fTaskRunner(taskRunner) |
+ , fDepth(0) { |
fReporter->start(); |
} |
Task::Task(const Task& parent) |
- : INHERITED(parent) |
- , fReporter(parent.fReporter) |
+ : fReporter(parent.fReporter) |
, fTaskRunner(parent.fTaskRunner) |
- , fDepth(parent.depth()+1) { |
+ , fDepth(parent.depth() + 1) { |
fReporter->start(); |
} |
-Task::~Task() {} |
- |
-void Task::run() { |
- if (!this->shouldSkip()) { |
- this->draw(); |
+void Task::fail(const char* msg) { |
+ SkString failure(this->name()); |
+ if (msg) { |
+ failure.appendf(": %s", msg); |
} |
+ fReporter->fail(failure); |
+} |
+ |
+void Task::finish() { |
fReporter->finish(this->name()); |
- delete this; |
} |
-void Task::spawnChild(Task* task) { |
- if (!task->usesGpu()) { |
- fTaskRunner->add(task); |
- } else { |
- SkDEBUGFAIL("Sorry, we can't spawn GPU tasks. :( See comment in TaskRunner::wait()."); |
- } |
+void Task::spawnChild(CpuTask* task) { |
+ fTaskRunner->add(task); |
} |
-void Task::fail(const char* msg) { |
- SkString failure(this->name()); |
- if (msg) { |
- failure.appendf(": %s", msg); |
+CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {} |
+CpuTask::CpuTask(const Task& parent) : Task(parent) {} |
+ |
+void CpuTask::run() { |
+ if (!this->shouldSkip()) { |
+ this->draw(); |
} |
- fReporter->fail(failure); |
+ this->finish(); |
+ SkDELETE(this); |
} |
-GrContextFactory* Task::getGrContextFactory() const { |
- return fTaskRunner->getGrContextFactory(); |
+GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {} |
+ |
+void GpuTask::run(GrContextFactory& factory) { |
+ if (!this->shouldSkip()) { |
+ this->draw(&factory); |
+ } |
+ this->finish(); |
+ SkDELETE(this); |
} |
+ |
+ |
} // namespace DM |