blob: 9b463f90031b555c27f5470c0c7fb1a33c11baa8 [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
15Task::Task(const Task& that) : fReporter(that.fReporter), fTaskRunner(that.fTaskRunner) {
16 fReporter->start();
17}
18
19Task::~Task() {}
20
21void Task::run() {
22 if (!this->shouldSkip()) {
23 this->draw();
24 }
25 fReporter->finish();
26 fReporter->updateStatusLine();
27 delete this;
28}
29
30void 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
38void Task::fail() {
39 fReporter->fail(this->name());
40}
41
42} // namespace DM