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) |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 11 | : fReporter(reporter), fTaskRunner(taskRunner), fDepth(0) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 12 | fReporter->start(); |
| 13 | } |
| 14 | |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 15 | Task::Task(const Task& parent) |
| 16 | : INHERITED(parent) |
| 17 | , fReporter(parent.fReporter) |
| 18 | , fTaskRunner(parent.fTaskRunner) |
| 19 | , fDepth(parent.depth()+1) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 20 | fReporter->start(); |
| 21 | } |
| 22 | |
| 23 | Task::~Task() {} |
| 24 | |
| 25 | void Task::run() { |
| 26 | if (!this->shouldSkip()) { |
| 27 | this->draw(); |
| 28 | } |
| 29 | fReporter->finish(); |
| 30 | fReporter->updateStatusLine(); |
| 31 | delete this; |
| 32 | } |
| 33 | |
| 34 | void Task::spawnChild(Task* task) { |
| 35 | if (!task->usesGpu()) { |
| 36 | fTaskRunner->add(task); |
| 37 | } else { |
| 38 | SkDEBUGFAIL("Sorry, we can't spawn GPU tasks. :( See comment in TaskRunner::wait()."); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | void Task::fail() { |
| 43 | fReporter->fail(this->name()); |
| 44 | } |
| 45 | |
| 46 | } // namespace DM |