OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/gpu_raster_worker_pool.h" | 5 #include "cc/resources/gpu_raster_worker_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 } | 117 } |
118 | 118 |
119 void GpuRasterWorkerPool::Shutdown() { | 119 void GpuRasterWorkerPool::Shutdown() { |
120 TRACE_EVENT0("cc", "GpuRasterWorkerPool::Shutdown"); | 120 TRACE_EVENT0("cc", "GpuRasterWorkerPool::Shutdown"); |
121 | 121 |
122 TaskGraph empty; | 122 TaskGraph empty; |
123 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 123 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
124 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | 124 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
125 } | 125 } |
126 | 126 |
127 void GpuRasterWorkerPool::RunTasks(RasterTaskQueue* queue) { | |
128 ScopedGpuRaster gpu_raster(context_provider_); | |
129 | |
130 for (auto& item : queue->items) { | |
131 RasterTask* task = item.task; | |
132 DCHECK(!task->HasCompleted()); | |
133 | |
134 task->WillSchedule(); | |
135 task->ScheduleOnOriginThread(this); | |
136 task->DidSchedule(); | |
137 | |
138 task->WillRun(); | |
139 task->RunOnWorkerThread(); | |
140 task->DidRun(); | |
141 | |
142 completed_tasks_.push_back(task); | |
143 } | |
144 | |
145 multi_picture_draw_.draw(); | |
146 | |
147 CompleteTasks(completed_tasks_); | |
148 } | |
149 | |
127 void GpuRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { | 150 void GpuRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { |
128 TRACE_EVENT0("cc", "GpuRasterWorkerPool::ScheduleTasks"); | 151 TRACE_EVENT0("cc", "GpuRasterWorkerPool::ScheduleTasks"); |
129 | 152 |
130 // Mark all task sets as pending. | 153 // Mark all task sets as pending. |
131 raster_pending_.set(); | 154 raster_pending_.set(); |
132 | 155 |
133 unsigned priority = kRasterTaskPriorityBase; | 156 unsigned priority = kRasterTaskPriorityBase; |
134 | 157 |
135 graph_.Reset(); | 158 graph_.Reset(); |
136 | 159 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 std::copy(new_raster_finished_tasks, | 207 std::copy(new_raster_finished_tasks, |
185 new_raster_finished_tasks + kNumberOfTaskSets, | 208 new_raster_finished_tasks + kNumberOfTaskSets, |
186 raster_finished_tasks_); | 209 raster_finished_tasks_); |
187 } | 210 } |
188 | 211 |
189 void GpuRasterWorkerPool::CheckForCompletedTasks() { | 212 void GpuRasterWorkerPool::CheckForCompletedTasks() { |
190 TRACE_EVENT0("cc", "GpuRasterWorkerPool::CheckForCompletedTasks"); | 213 TRACE_EVENT0("cc", "GpuRasterWorkerPool::CheckForCompletedTasks"); |
191 | 214 |
192 task_graph_runner_->CollectCompletedTasks(namespace_token_, | 215 task_graph_runner_->CollectCompletedTasks(namespace_token_, |
193 &completed_tasks_); | 216 &completed_tasks_); |
194 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | 217 CompleteTasks(completed_tasks_); |
195 it != completed_tasks_.end(); | 218 completed_tasks_.clear(); |
vmiura
2014/11/20 01:48:42
Since CompleteTasks() calls completed_tasks_.clear
ernstm
2014/11/20 01:57:01
Done.
| |
196 ++it) { | 219 } |
197 RasterizerTask* task = static_cast<RasterizerTask*>(it->get()); | |
198 | 220 |
199 task->WillComplete(); | 221 void GpuRasterWorkerPool::CompleteTasks(const Task::Vector& tasks) { |
200 task->CompleteOnOriginThread(this); | 222 for (auto& task : tasks) { |
201 task->DidComplete(); | 223 RasterTask* raster_task = static_cast<RasterTask*>(task.get()); |
202 | 224 |
203 task->RunReplyOnOriginThread(); | 225 raster_task->WillComplete(); |
226 raster_task->CompleteOnOriginThread(this); | |
227 raster_task->DidComplete(); | |
228 | |
229 raster_task->RunReplyOnOriginThread(); | |
204 } | 230 } |
205 completed_tasks_.clear(); | 231 completed_tasks_.clear(); |
206 } | 232 } |
207 | 233 |
208 scoped_ptr<RasterBuffer> GpuRasterWorkerPool::AcquireBufferForRaster( | 234 scoped_ptr<RasterBuffer> GpuRasterWorkerPool::AcquireBufferForRaster( |
209 const Resource* resource) { | 235 const Resource* resource) { |
210 return make_scoped_ptr<RasterBuffer>( | 236 return make_scoped_ptr<RasterBuffer>( |
211 new RasterBufferImpl(resource_provider_, | 237 new RasterBufferImpl(resource_provider_, |
212 resource, | 238 resource, |
213 &multi_picture_draw_, | 239 &multi_picture_draw_, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 273 |
248 ScopedGpuRaster gpu_raster(context_provider_); | 274 ScopedGpuRaster gpu_raster(context_provider_); |
249 task_graph_runner_->RunUntilIdle(); | 275 task_graph_runner_->RunUntilIdle(); |
250 | 276 |
251 // Draw each all of the pictures that were collected. This will also clear | 277 // Draw each all of the pictures that were collected. This will also clear |
252 // the pictures and canvases added to |multi_picture_draw_| | 278 // the pictures and canvases added to |multi_picture_draw_| |
253 multi_picture_draw_.draw(); | 279 multi_picture_draw_.draw(); |
254 } | 280 } |
255 | 281 |
256 } // namespace cc | 282 } // namespace cc |
OLD | NEW |