Index: dm/DMTask.cpp |
diff --git a/dm/DMTask.cpp b/dm/DMTask.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d665fe9e21bbe98dc2c9714e887333c6890a5027 |
--- /dev/null |
+++ b/dm/DMTask.cpp |
@@ -0,0 +1,42 @@ |
+#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) { |
+ fReporter->start(); |
+} |
+ |
+Task::Task(const Task& that) : fReporter(that.fReporter), fTaskRunner(that.fTaskRunner) { |
+ fReporter->start(); |
+} |
+ |
+Task::~Task() {} |
+ |
+void Task::run() { |
+ if (!this->shouldSkip()) { |
+ this->draw(); |
+ } |
+ fReporter->finish(); |
+ fReporter->UpdateStatusLine(); |
+ 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::fail() { |
+ fReporter->fail(this->name()); |
+} |
+ |
+} // namespace DM |