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 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each task
."); |
7 | 8 |
8 DECLARE_bool(dryRun); | 9 DECLARE_bool(dryRun); |
9 | 10 |
10 namespace DM { | 11 namespace DM { |
11 | 12 |
12 Task::Task(Reporter* reporter, TaskRunner* taskRunner) | 13 Task::Task(Reporter* reporter, TaskRunner* taskRunner) |
13 : fReporter(reporter) | 14 : fReporter(reporter) |
14 , fTaskRunner(taskRunner) | 15 , fTaskRunner(taskRunner) |
15 , fDepth(0) { | 16 , fDepth(0) { |
16 fReporter->taskCreated(); | 17 fReporter->taskCreated(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Run children serially on this (CPU) thread. This tends to save RAM and i
s usually no slower. | 64 // Run children serially on this (CPU) thread. This tends to save RAM and i
s usually no slower. |
64 // Calling spawnChildNext() is nearly equivalent, but it'd pointlessly conte
nd on the | 65 // Calling spawnChildNext() is nearly equivalent, but it'd pointlessly conte
nd on the |
65 // threadpool; spawnChildNext() is most useful when you want to change threa
dpools. | 66 // threadpool; spawnChildNext() is most useful when you want to change threa
dpools. |
66 task->run(); | 67 task->run(); |
67 } | 68 } |
68 | 69 |
69 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} | 70 GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
skRunner) {} |
70 | 71 |
71 void GpuTask::run(GrContextFactory& factory) { | 72 void GpuTask::run(GrContextFactory& factory) { |
72 if (FLAGS_gpu && !this->shouldSkip()) { | 73 if (FLAGS_gpu && !this->shouldSkip()) { |
| 74 if (FLAGS_resetGpuContext) { |
| 75 factory.destroyContexts(); |
| 76 } |
73 this->start(); | 77 this->start(); |
74 if (!FLAGS_dryRun) this->draw(&factory); | 78 if (!FLAGS_dryRun) this->draw(&factory); |
75 this->finish(); | 79 this->finish(); |
76 } | 80 } |
77 SkDELETE(this); | 81 SkDELETE(this); |
78 } | 82 } |
79 | 83 |
80 void GpuTask::spawnChild(CpuTask* task) { | 84 void GpuTask::spawnChild(CpuTask* task) { |
81 // Really spawn a new task so it runs on the CPU threadpool instead of the G
PU one we're on now. | 85 // Really spawn a new task so it runs on the CPU threadpool instead of the G
PU one we're on now. |
82 // It goes on the front of the queue to minimize the time we must hold refer
ence bitmaps in RAM. | 86 // It goes on the front of the queue to minimize the time we must hold refer
ence bitmaps in RAM. |
83 this->spawnChildNext(task); | 87 this->spawnChildNext(task); |
84 } | 88 } |
85 | 89 |
86 } // namespace DM | 90 } // namespace DM |
OLD | NEW |