a39874b636
Show task name in verbose mode only, and add task runtime. BUG=skia: R=reed@google.com, bsalomon@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/185233004 git-svn-id: http://skia.googlecode.com/svn/trunk@13639 2bbb7eff-a529-9590-31e7-b0007b416f81
66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
#include "DMTask.h"
|
|
#include "DMTaskRunner.h"
|
|
|
|
namespace DM {
|
|
|
|
Task::Task(Reporter* reporter, TaskRunner* taskRunner)
|
|
: fReporter(reporter)
|
|
, fTaskRunner(taskRunner)
|
|
, fDepth(0) {
|
|
fReporter->start();
|
|
}
|
|
|
|
Task::Task(const Task& parent)
|
|
: fReporter(parent.fReporter)
|
|
, fTaskRunner(parent.fTaskRunner)
|
|
, fDepth(parent.depth() + 1) {
|
|
fReporter->start();
|
|
}
|
|
|
|
void Task::fail(const char* msg) {
|
|
SkString failure(this->name());
|
|
if (msg) {
|
|
failure.appendf(": %s", msg);
|
|
}
|
|
fReporter->fail(failure);
|
|
}
|
|
|
|
void Task::start() {
|
|
fStart = SkTime::GetMSecs();
|
|
}
|
|
|
|
void Task::finish() {
|
|
fReporter->finish(this->name(), SkTime::GetMSecs() - fStart);
|
|
}
|
|
|
|
void Task::spawnChild(CpuTask* task) {
|
|
fTaskRunner->add(task);
|
|
}
|
|
|
|
CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {}
|
|
CpuTask::CpuTask(const Task& parent) : Task(parent) {}
|
|
|
|
void CpuTask::run() {
|
|
this->start();
|
|
if (!this->shouldSkip()) {
|
|
this->draw();
|
|
}
|
|
this->finish();
|
|
SkDELETE(this);
|
|
}
|
|
|
|
GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {}
|
|
|
|
void GpuTask::run(GrContextFactory& factory) {
|
|
this->start();
|
|
if (!this->shouldSkip()) {
|
|
this->draw(&factory);
|
|
}
|
|
this->finish();
|
|
SkDELETE(this);
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|