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