OLD | NEW |
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 DECLARE_bool(dryRun); |
| 9 |
8 namespace DM { | 10 namespace DM { |
9 | 11 |
10 Task::Task(Reporter* reporter, TaskRunner* taskRunner) | 12 Task::Task(Reporter* reporter, TaskRunner* taskRunner) |
11 : fReporter(reporter) | 13 : fReporter(reporter) |
12 , fTaskRunner(taskRunner) | 14 , fTaskRunner(taskRunner) |
13 , fDepth(0) { | 15 , fDepth(0) { |
14 fReporter->taskCreated(); | 16 fReporter->taskCreated(); |
15 } | 17 } |
16 | 18 |
17 Task::Task(const Task& parent) | 19 Task::Task(const Task& parent) |
(...skipping 26 matching lines...) Expand all Loading... |
44 void Task::spawnChildNext(CpuTask* task) { | 46 void Task::spawnChildNext(CpuTask* task) { |
45 fTaskRunner->addNext(task); | 47 fTaskRunner->addNext(task); |
46 } | 48 } |
47 | 49 |
48 CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} | 50 CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} |
49 CpuTask::CpuTask(const Task& parent) : Task(parent) {} | 51 CpuTask::CpuTask(const Task& parent) : Task(parent) {} |
50 | 52 |
51 void CpuTask::run() { | 53 void CpuTask::run() { |
52 if (FLAGS_cpu && !this->shouldSkip()) { | 54 if (FLAGS_cpu && !this->shouldSkip()) { |
53 this->start(); | 55 this->start(); |
54 this->draw(); | 56 if (!FLAGS_dryRun) this->draw(); |
55 this->finish(); | 57 this->finish(); |
56 } | 58 } |
57 SkDELETE(this); | 59 SkDELETE(this); |
58 } | 60 } |
59 | 61 |
60 void CpuTask::spawnChild(CpuTask* task) { | 62 void CpuTask::spawnChild(CpuTask* task) { |
61 // Run children serially on this (CPU) thread. This tends to save RAM and i
s usually no slower. | 63 // Run children serially on this (CPU) thread. This tends to save RAM and i
s usually no slower. |
62 // Calling spawnChildNext() is nearly equivalent, but it'd pointlessly conte
nd on the | 64 // Calling spawnChildNext() is nearly equivalent, but it'd pointlessly conte
nd on the |
63 // threadpool; spawnChildNext() is most useful when you want to change threa
dpools. | 65 // threadpool; spawnChildNext() is most useful when you want to change threa
dpools. |
64 task->run(); | 66 task->run(); |
65 } | 67 } |
66 | 68 |
67 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} | 69 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} |
68 | 70 |
69 void GpuTask::run(GrContextFactory& factory) { | 71 void GpuTask::run(GrContextFactory& factory) { |
70 if (FLAGS_gpu && !this->shouldSkip()) { | 72 if (FLAGS_gpu && !this->shouldSkip()) { |
71 this->start(); | 73 this->start(); |
72 this->draw(&factory); | 74 if (!FLAGS_dryRun) this->draw(&factory); |
73 this->finish(); | 75 this->finish(); |
74 } | 76 } |
75 SkDELETE(this); | 77 SkDELETE(this); |
76 } | 78 } |
77 | 79 |
78 void GpuTask::spawnChild(CpuTask* task) { | 80 void GpuTask::spawnChild(CpuTask* task) { |
79 // Really spawn a new task so it runs on the CPU threadpool instead of the G
PU one we're on now. | 81 // Really spawn a new task so it runs on the CPU threadpool instead of the G
PU one we're on now. |
80 // It goes on the front of the queue to minimize the time we must hold refer
ence bitmaps in RAM. | 82 // It goes on the front of the queue to minimize the time we must hold refer
ence bitmaps in RAM. |
81 this->spawnChildNext(task); | 83 this->spawnChildNext(task); |
82 } | 84 } |
83 | 85 |
84 } // namespace DM | 86 } // namespace DM |
OLD | NEW |