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 namespace DM { | 8 namespace DM { |
9 | 9 |
10 Task::Task(Reporter* reporter, TaskRunner* taskRunner) | 10 Task::Task(Reporter* reporter, TaskRunner* taskRunner) |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 void Task::start() { | 32 void Task::start() { |
33 fStart = SkTime::GetMSecs(); | 33 fStart = SkTime::GetMSecs(); |
34 } | 34 } |
35 | 35 |
36 void Task::finish() { | 36 void Task::finish() { |
37 fReporter->finish(this->name(), SkTime::GetMSecs() - fStart); | 37 fReporter->finish(this->name(), SkTime::GetMSecs() - fStart); |
38 } | 38 } |
39 | 39 |
40 void Task::spawnChild(CpuTask* task) { | 40 void Task::reallySpawnChild(CpuTask* task) { |
41 fTaskRunner->add(task); | 41 fTaskRunner->add(task); |
42 } | 42 } |
43 | 43 |
44 CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} | 44 CpuTask::CpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} |
45 CpuTask::CpuTask(const Task& parent) : Task(parent) {} | 45 CpuTask::CpuTask(const Task& parent) : Task(parent) {} |
46 | 46 |
47 void CpuTask::run() { | 47 void CpuTask::run() { |
48 this->start(); | 48 this->start(); |
49 if (FLAGS_cpu && !this->shouldSkip()) { | 49 if (FLAGS_cpu && !this->shouldSkip()) { |
50 this->draw(); | 50 this->draw(); |
51 } | 51 } |
52 this->finish(); | 52 this->finish(); |
53 SkDELETE(this); | 53 SkDELETE(this); |
54 } | 54 } |
55 | 55 |
| 56 void CpuTask::spawnChild(CpuTask* task) { |
| 57 // Run children serially on this (CPU) thread. This tends to save RAM and i
s usually no slower. |
| 58 task->run(); |
| 59 } |
| 60 |
56 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} | 61 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} |
57 | 62 |
58 void GpuTask::run(GrContextFactory& factory) { | 63 void GpuTask::run(GrContextFactory& factory) { |
59 this->start(); | 64 this->start(); |
60 if (FLAGS_gpu && !this->shouldSkip()) { | 65 if (FLAGS_gpu && !this->shouldSkip()) { |
61 this->draw(&factory); | 66 this->draw(&factory); |
62 } | 67 } |
63 this->finish(); | 68 this->finish(); |
64 SkDELETE(this); | 69 SkDELETE(this); |
65 } | 70 } |
66 | 71 |
67 | 72 void GpuTask::spawnChild(CpuTask* task) { |
| 73 // Really spawn a new task so it runs on the CPU threadpool instead of the G
PU one we're on now. |
| 74 this->reallySpawnChild(task); |
| 75 } |
68 | 76 |
69 } // namespace DM | 77 } // namespace DM |
OLD | NEW |