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

Side by Side Diff: dm/DMTask.cpp

Issue 309483003: DM tweaks (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: note Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « dm/DMTask.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "DMTask.h" 1 #include "DMTask.h"
2 #include "DMTaskRunner.h" 2 #include "DMTaskRunner.h"
3 #include "SkCommandLineFlags.h" 3 #include "SkCommandLineFlags.h"
4 4
5 DEFINE_bool(cpu, true, "Master switch for running CPU-bound work."); 5 DEFINE_bool(cpu, true, "Master switch for running CPU-bound work.");
6 DEFINE_bool(gpu, true, "Master switch for running GPU-bound work."); 6 DEFINE_bool(gpu, true, "Master switch for running GPU-bound work.");
7 7
8 namespace DM { 8 namespace DM {
9 9
10 Task::Task(Reporter* reporter, TaskRunner* taskRunner) 10 Task::Task(Reporter* reporter, TaskRunner* taskRunner)
11 : fReporter(reporter) 11 : fReporter(reporter)
12 , fTaskRunner(taskRunner) 12 , fTaskRunner(taskRunner)
13 , fDepth(0) { 13 , fDepth(0) {
14 fReporter->start(); 14 fReporter->taskCreated();
15 } 15 }
16 16
17 Task::Task(const Task& parent) 17 Task::Task(const Task& parent)
18 : fReporter(parent.fReporter) 18 : fReporter(parent.fReporter)
19 , fTaskRunner(parent.fTaskRunner) 19 , fTaskRunner(parent.fTaskRunner)
20 , fDepth(parent.depth() + 1) { 20 , fDepth(parent.depth() + 1) {
21 fReporter->start(); 21 fReporter->taskCreated();
22 }
23
24 Task::~Task() {
25 fReporter->taskDestroyed();
22 } 26 }
23 27
24 void Task::fail(const char* msg) { 28 void Task::fail(const char* msg) {
25 SkString failure(this->name()); 29 SkString failure(this->name());
26 if (msg) { 30 if (msg) {
27 failure.appendf(": %s", msg); 31 failure.appendf(": %s", msg);
28 } 32 }
29 fReporter->fail(failure); 33 fReporter->fail(failure);
30 } 34 }
31 35
32 void Task::start() { 36 void Task::start() {
33 fStart = SkTime::GetMSecs(); 37 fStart = SkTime::GetMSecs();
34 } 38 }
35 39
36 void Task::finish() { 40 void Task::finish() {
37 fReporter->finish(this->name(), SkTime::GetMSecs() - fStart); 41 fReporter->printStatus(this->name(), SkTime::GetMSecs() - fStart);
38 } 42 }
39 43
40 void Task::spawnChildNext(CpuTask* task) { 44 void Task::spawnChildNext(CpuTask* task) {
41 fTaskRunner->addNext(task); 45 fTaskRunner->addNext(task);
42 } 46 }
43 47
44 CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta skRunner) {} 48 CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta skRunner) {}
45 CpuTask::CpuTask(const Task& parent) : Task(parent) {} 49 CpuTask::CpuTask(const Task& parent) : Task(parent) {}
46 50
47 void CpuTask::run() { 51 void CpuTask::run() {
48 this->start();
49 if (FLAGS_cpu && !this->shouldSkip()) { 52 if (FLAGS_cpu && !this->shouldSkip()) {
53 this->start();
50 this->draw(); 54 this->draw();
55 this->finish();
51 } 56 }
52 this->finish();
53 SkDELETE(this); 57 SkDELETE(this);
54 } 58 }
55 59
56 void CpuTask::spawnChild(CpuTask* task) { 60 void CpuTask::spawnChild(CpuTask* task) {
57 // Run children serially on this (CPU) thread. This tends to save RAM and i s usually no slower. 61 // Run children serially on this (CPU) thread. This tends to save RAM and i s usually no slower.
58 // Calling spawnChildNext() is nearly equivalent, but it'd pointlessly conte nd on the 62 // Calling spawnChildNext() is nearly equivalent, but it'd pointlessly conte nd on the
59 // threadpool; spawnChildNext() is most useful when you want to change threa dpools. 63 // threadpool; spawnChildNext() is most useful when you want to change threa dpools.
60 task->run(); 64 task->run();
61 } 65 }
62 66
63 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta skRunner) {} 67 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta skRunner) {}
64 68
65 void GpuTask::run(GrContextFactory& factory) { 69 void GpuTask::run(GrContextFactory& factory) {
66 this->start();
67 if (FLAGS_gpu && !this->shouldSkip()) { 70 if (FLAGS_gpu && !this->shouldSkip()) {
71 this->start();
68 this->draw(&factory); 72 this->draw(&factory);
73 this->finish();
69 } 74 }
70 this->finish();
71 SkDELETE(this); 75 SkDELETE(this);
72 } 76 }
73 77
74 void GpuTask::spawnChild(CpuTask* task) { 78 void GpuTask::spawnChild(CpuTask* task) {
75 // Really spawn a new task so it runs on the CPU threadpool instead of the G PU one we're on now. 79 // Really spawn a new task so it runs on the CPU threadpool instead of the G PU one we're on now.
76 // It goes on the front of the queue to minimize the time we must hold refer ence bitmaps in RAM. 80 // It goes on the front of the queue to minimize the time we must hold refer ence bitmaps in RAM.
77 this->spawnChildNext(task); 81 this->spawnChildNext(task);
78 } 82 }
79 83
80 } // namespace DM 84 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMTask.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698