2013-10-16 13:02:15 +00:00
|
|
|
#include "DMTask.h"
|
|
|
|
|
|
|
|
#include "DMTaskRunner.h"
|
|
|
|
#include "DMUtil.h"
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCommandLineFlags.h"
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
Task::Task(Reporter* reporter, TaskRunner* taskRunner)
|
2013-12-02 13:50:38 +00:00
|
|
|
: fReporter(reporter), fTaskRunner(taskRunner), fDepth(0) {
|
2013-10-16 13:02:15 +00:00
|
|
|
fReporter->start();
|
|
|
|
}
|
|
|
|
|
2013-12-02 13:50:38 +00:00
|
|
|
Task::Task(const Task& parent)
|
|
|
|
: INHERITED(parent)
|
|
|
|
, fReporter(parent.fReporter)
|
|
|
|
, fTaskRunner(parent.fTaskRunner)
|
|
|
|
, fDepth(parent.depth()+1) {
|
2013-10-16 13:02:15 +00:00
|
|
|
fReporter->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
Task::~Task() {}
|
|
|
|
|
|
|
|
void Task::run() {
|
|
|
|
if (!this->shouldSkip()) {
|
|
|
|
this->draw();
|
|
|
|
}
|
2014-02-26 16:31:22 +00:00
|
|
|
fReporter->finish(this->name());
|
2013-10-16 13:02:15 +00:00
|
|
|
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().");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-26 16:31:22 +00:00
|
|
|
void Task::fail(const char* msg) {
|
|
|
|
SkString failure(this->name());
|
|
|
|
if (msg) {
|
|
|
|
failure.appendf(": %s", msg);
|
|
|
|
}
|
|
|
|
fReporter->fail(failure);
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|