Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: dm/DMTask.cpp

Issue 179233005: DM: make GPU tasks multithreaded again. Big refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: default 1 GPU thread Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dm/DMTask.h ('k') | dm/DMTaskRunner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMTask.cpp
diff --git a/dm/DMTask.cpp b/dm/DMTask.cpp
index d26971c8903c9ec8363a8f56c130c497487e2dc9..1c4cc25693be54962990808caade6e7cdb84f60a 100644
--- a/dm/DMTask.cpp
+++ b/dm/DMTask.cpp
@@ -1,53 +1,59 @@
#include "DMTask.h"
-
#include "DMTaskRunner.h"
-#include "DMUtil.h"
-#include "SkBitmap.h"
-#include "SkCommandLineFlags.h"
namespace DM {
Task::Task(Reporter* reporter, TaskRunner* taskRunner)
- : fReporter(reporter), fTaskRunner(taskRunner), fDepth(0) {
+ : fReporter(reporter)
+ , fTaskRunner(taskRunner)
+ , fDepth(0) {
fReporter->start();
}
Task::Task(const Task& parent)
- : INHERITED(parent)
- , fReporter(parent.fReporter)
+ : fReporter(parent.fReporter)
, fTaskRunner(parent.fTaskRunner)
- , fDepth(parent.depth()+1) {
+ , fDepth(parent.depth() + 1) {
fReporter->start();
}
-Task::~Task() {}
-
-void Task::run() {
- if (!this->shouldSkip()) {
- this->draw();
+void Task::fail(const char* msg) {
+ SkString failure(this->name());
+ if (msg) {
+ failure.appendf(": %s", msg);
}
+ fReporter->fail(failure);
+}
+
+void Task::finish() {
fReporter->finish(this->name());
- 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().");
- }
+void Task::spawnChild(CpuTask* task) {
+ fTaskRunner->add(task);
}
-void Task::fail(const char* msg) {
- SkString failure(this->name());
- if (msg) {
- failure.appendf(": %s", msg);
+CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {}
+CpuTask::CpuTask(const Task& parent) : Task(parent) {}
+
+void CpuTask::run() {
+ if (!this->shouldSkip()) {
+ this->draw();
}
- fReporter->fail(failure);
+ this->finish();
+ SkDELETE(this);
}
-GrContextFactory* Task::getGrContextFactory() const {
- return fTaskRunner->getGrContextFactory();
+GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, taskRunner) {}
+
+void GpuTask::run(GrContextFactory& factory) {
+ if (!this->shouldSkip()) {
+ this->draw(&factory);
+ }
+ this->finish();
+ SkDELETE(this);
}
+
+
} // namespace DM
« no previous file with comments | « dm/DMTask.h ('k') | dm/DMTaskRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698