mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #include "DMTask.h" |
| 2 | |
| 3 | #include "DMTaskRunner.h" |
| 4 | #include "DMUtil.h" |
| 5 | #include "SkBitmap.h" |
| 6 | #include "SkCommandLineFlags.h" |
| 7 | |
| 8 | namespace DM { |
| 9 | |
| 10 | Task::Task(Reporter* reporter, TaskRunner* taskRunner) |
| 11 | : fReporter(reporter), fTaskRunner(taskRunner) { |
| 12 | fReporter->start(); |
| 13 | } |
| 14 | |
| 15 | Task::Task(const Task& that) : fReporter(that.fReporter), fTaskRunner(that.fTaskRunner) { |
| 16 | fReporter->start(); |
| 17 | } |
| 18 | |
| 19 | Task::~Task() {} |
| 20 | |
| 21 | void Task::run() { |
| 22 | if (!this->shouldSkip()) { |
| 23 | this->draw(); |
| 24 | } |
| 25 | fReporter->finish(); |
| 26 | fReporter->updateStatusLine(); |
| 27 | delete this; |
| 28 | } |
| 29 | |
| 30 | void Task::spawnChild(Task* task) { |
| 31 | if (!task->usesGpu()) { |
| 32 | fTaskRunner->add(task); |
| 33 | } else { |
| 34 | SkDEBUGFAIL("Sorry, we can't spawn GPU tasks. :( See comment in TaskRunner::wait()."); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | void Task::fail() { |
| 39 | fReporter->fail(this->name()); |
| 40 | } |
| 41 | |
| 42 | } // namespace DM |