| 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 } |
| 196 ++it) { | |
| 197 RasterizerTask* task = static_cast<RasterizerTask*>(it->get()); | |
| 198 | 219 |
| 199 task->WillComplete(); | 220 void GpuRasterWorkerPool::CompleteTasks(const Task::Vector& tasks) { |
| 200 task->CompleteOnOriginThread(this); | 221 for (auto& task : tasks) { |
| 201 task->DidComplete(); | 222 RasterTask* raster_task = static_cast<RasterTask*>(task.get()); |
| 202 | 223 |
| 203 task->RunReplyOnOriginThread(); | 224 raster_task->WillComplete(); |
| 225 raster_task->CompleteOnOriginThread(this); |
| 226 raster_task->DidComplete(); |
| 227 |
| 228 raster_task->RunReplyOnOriginThread(); |
| 204 } | 229 } |
| 205 completed_tasks_.clear(); | 230 completed_tasks_.clear(); |
| 206 } | 231 } |
| 207 | 232 |
| 208 scoped_ptr<RasterBuffer> GpuRasterWorkerPool::AcquireBufferForRaster( | 233 scoped_ptr<RasterBuffer> GpuRasterWorkerPool::AcquireBufferForRaster( |
| 209 const Resource* resource) { | 234 const Resource* resource) { |
| 210 return make_scoped_ptr<RasterBuffer>( | 235 return make_scoped_ptr<RasterBuffer>( |
| 211 new RasterBufferImpl(resource_provider_, | 236 new RasterBufferImpl(resource_provider_, |
| 212 resource, | 237 resource, |
| 213 &multi_picture_draw_, | 238 &multi_picture_draw_, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 272 |
| 248 ScopedGpuRaster gpu_raster(context_provider_); | 273 ScopedGpuRaster gpu_raster(context_provider_); |
| 249 task_graph_runner_->RunUntilIdle(); | 274 task_graph_runner_->RunUntilIdle(); |
| 250 | 275 |
| 251 // Draw each all of the pictures that were collected. This will also clear | 276 // Draw each all of the pictures that were collected. This will also clear |
| 252 // the pictures and canvases added to |multi_picture_draw_| | 277 // the pictures and canvases added to |multi_picture_draw_| |
| 253 multi_picture_draw_.draw(); | 278 multi_picture_draw_.draw(); |
| 254 } | 279 } |
| 255 | 280 |
| 256 } // namespace cc | 281 } // namespace cc |
| OLD | NEW |