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);
|
|
|
|
}
|
|
|
|
|
2014-03-03 15:44:56 +00:00
|
|
|
void Task::start() {
|
|
|
|
fStart = SkTime::GetMSecs();
|
|
|
|
}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
void Task::finish() {
|
2014-03-03 15:44:56 +00:00
|
|
|
fReporter->finish(this->name(), SkTime::GetMSecs() - fStart);
|
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() {
|
2014-03-03 15:44:56 +00:00
|
|
|
this->start();
|
2014-02-28 20:31:31 +00:00
|
|
|
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) {
|
2014-03-03 15:44:56 +00:00
|
|
|
this->start();
|
2014-02-28 20:31:31 +00:00
|
|
|
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
|