2013-10-16 13:02:15 +00:00
|
|
|
#include "DMTask.h"
|
|
|
|
#include "DMTaskRunner.h"
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
Task::Task(Reporter* reporter, TaskRunner* taskRunner)
|
2014-02-28 20:31:31 +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)
|
2014-02-28 20:31:31 +00:00
|
|
|
: fReporter(parent.fReporter)
|
2013-12-02 13:50:38 +00:00
|
|
|
, fTaskRunner(parent.fTaskRunner)
|
2014-02-28 20:31:31 +00:00
|
|
|
, fDepth(parent.depth() + 1) {
|
2013-10-16 13:02:15 +00:00
|
|
|
fReporter->start();
|
|
|
|
}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
void Task::fail(const char* msg) {
|
|
|
|
SkString failure(this->name());
|
|
|
|
if (msg) {
|
|
|
|
failure.appendf(": %s", msg);
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
2014-02-28 20:31:31 +00:00
|
|
|
fReporter->fail(failure);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Task::finish() {
|
2014-02-26 16:31:22 +00:00
|
|
|
fReporter->finish(this->name());
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
void Task::spawnChild(CpuTask* task) {
|
|
|
|
fTaskRunner->add(task);
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {}
|
|
|
|
CpuTask::CpuTask(const Task& parent) : Task(parent) {}
|
|
|
|
|
|
|
|
void CpuTask::run() {
|
|
|
|
if (!this->shouldSkip()) {
|
|
|
|
this->draw();
|
2014-02-26 16:31:22 +00:00
|
|
|
}
|
2014-02-28 20:31:31 +00:00
|
|
|
this->finish();
|
|
|
|
SkDELETE(this);
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {}
|
|
|
|
|
|
|
|
void GpuTask::run(GrContextFactory& factory) {
|
|
|
|
if (!this->shouldSkip()) {
|
|
|
|
this->draw(&factory);
|
|
|
|
}
|
|
|
|
this->finish();
|
|
|
|
SkDELETE(this);
|
2014-02-26 23:01:57 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
|
|
|
|
|
2013-10-16 13:02:15 +00:00
|
|
|
} // namespace DM
|