Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/pixel_buffer_raster_worker_pool.h" | 5 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
| 6 | 6 |
| 7 #include "base/containers/stack_container.h" | 7 #include "base/containers/stack_container.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks"); | 141 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks"); |
| 142 | 142 |
| 143 RasterWorkerPool::SetRasterTasks(queue); | 143 RasterWorkerPool::SetRasterTasks(queue); |
| 144 | 144 |
| 145 if (!should_notify_client_if_no_tasks_are_pending_) | 145 if (!should_notify_client_if_no_tasks_are_pending_) |
| 146 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); | 146 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); |
| 147 | 147 |
| 148 should_notify_client_if_no_tasks_are_pending_ = true; | 148 should_notify_client_if_no_tasks_are_pending_ = true; |
| 149 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; | 149 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; |
| 150 | 150 |
| 151 tasks_required_for_activation_.clear(); | |
| 152 | |
| 151 // Build new pixel buffer task set. | 153 // Build new pixel buffer task set. |
| 152 TaskMap new_pixel_buffer_tasks; | 154 TaskMap new_pixel_buffer_tasks; |
| 153 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); | 155 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); |
| 154 it != raster_tasks().end(); ++it) { | 156 it != raster_tasks().end(); ++it) { |
| 155 internal::RasterWorkerPoolTask* task = it->get(); | 157 internal::RasterWorkerPoolTask* task = it->get(); |
| 156 DCHECK(new_pixel_buffer_tasks.find(task) == new_pixel_buffer_tasks.end()); | 158 DCHECK(new_pixel_buffer_tasks.find(task) == new_pixel_buffer_tasks.end()); |
| 157 DCHECK(!task->HasCompleted()); | 159 DCHECK(!task->HasCompleted()); |
| 158 | 160 |
| 159 // Use existing pixel buffer task if available. | 161 new_pixel_buffer_tasks[task] = pixel_buffer_tasks_[task]; |
| 160 TaskMap::iterator pixel_buffer_it = pixel_buffer_tasks_.find(task); | 162 pixel_buffer_tasks_.erase(task); |
| 161 if (pixel_buffer_it == pixel_buffer_tasks_.end()) { | |
| 162 new_pixel_buffer_tasks[task] = NULL; | |
| 163 continue; | |
| 164 } | |
| 165 | 163 |
| 166 new_pixel_buffer_tasks[task] = pixel_buffer_it->second; | 164 if (IsRasterTaskRequiredForActivation(task)) |
| 167 pixel_buffer_tasks_.erase(task); | 165 tasks_required_for_activation_.insert(task); |
| 168 } | 166 } |
| 169 | 167 |
| 170 // Transfer remaining pixel buffer tasks to |new_pixel_buffer_tasks| | 168 // Transfer remaining pixel buffer tasks to |new_pixel_buffer_tasks| |
| 171 // and cancel all remaining inactive tasks. | 169 // and cancel all remaining inactive tasks. |
| 172 for (TaskMap::iterator it = pixel_buffer_tasks_.begin(); | 170 for (TaskMap::iterator it = pixel_buffer_tasks_.begin(); |
| 173 it != pixel_buffer_tasks_.end(); ++it) { | 171 it != pixel_buffer_tasks_.end(); ++it) { |
| 174 internal::RasterWorkerPoolTask* task = it->first; | 172 internal::RasterWorkerPoolTask* task = it->first; |
| 175 internal::WorkerPoolTask* pixel_buffer_task = it->second.get(); | 173 internal::WorkerPoolTask* pixel_buffer_task = it->second.get(); |
| 176 | 174 |
| 177 // Move task to |new_pixel_buffer_tasks| | 175 // Move task to |new_pixel_buffer_tasks| |
| 178 new_pixel_buffer_tasks[task] = pixel_buffer_task; | 176 new_pixel_buffer_tasks[task] = pixel_buffer_task; |
| 179 | 177 |
| 180 // Inactive task can be canceled. | 178 // Inactive task can be canceled. |
| 181 if (!pixel_buffer_task && !task->HasFinishedRunning()) { | 179 if (!pixel_buffer_task && !task->HasFinishedRunning()) { |
| 182 task->DidRun(true); | 180 task->DidRun(true); |
| 183 DCHECK(std::find(completed_tasks_.begin(), | 181 DCHECK(std::find(completed_tasks_.begin(), |
| 184 completed_tasks_.end(), | 182 completed_tasks_.end(), |
| 185 task) == completed_tasks_.end()); | 183 task) == completed_tasks_.end()); |
| 186 completed_tasks_.push_back(task); | 184 completed_tasks_.push_back(task); |
| 185 } else if (IsRasterTaskRequiredForActivation(task)) { | |
| 186 tasks_required_for_activation_.insert(task); | |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 tasks_required_for_activation_.clear(); | 190 if (!tasks_required_for_activation_.empty()) { |
|
reveman
2013/09/13 16:51:46
this is just an optimization, right? can you inste
vmpstr
2013/09/16 16:09:16
Done. I did an explicit if/break, but it could als
| |
| 191 for (TaskMap::iterator it = new_pixel_buffer_tasks.begin(); | 191 // |tasks_required_for_activation_| contains all tasks that need to |
| 192 it != new_pixel_buffer_tasks.end(); ++it) { | 192 // complete before we can send a "ready to activate" signal. Tasks |
| 193 internal::RasterWorkerPoolTask* task = it->first; | 193 // that have already completed should not be part of this set. |
| 194 if (IsRasterTaskRequiredForActivation(task)) | 194 for (TaskDeque::const_iterator it = completed_tasks_.begin(); |
| 195 tasks_required_for_activation_.insert(task); | 195 it != completed_tasks_.end(); ++it) { |
| 196 } | 196 tasks_required_for_activation_.erase(*it); |
| 197 | 197 } |
| 198 // |tasks_required_for_activation_| contains all tasks that need to | |
| 199 // complete before we can send a "ready to activate" signal. Tasks | |
| 200 // that have already completed should not be part of this set. | |
| 201 for (TaskDeque::const_iterator it = completed_tasks_.begin(); | |
| 202 it != completed_tasks_.end(); ++it) { | |
| 203 tasks_required_for_activation_.erase(*it); | |
| 204 } | 198 } |
| 205 | 199 |
| 206 pixel_buffer_tasks_.swap(new_pixel_buffer_tasks); | 200 pixel_buffer_tasks_.swap(new_pixel_buffer_tasks); |
| 207 | 201 |
| 208 // Check for completed tasks when ScheduleTasks() is called as | 202 // Check for completed tasks when ScheduleTasks() is called as |
| 209 // priorities might have changed and this maximizes the number | 203 // priorities might have changed and this maximizes the number |
| 210 // of top priority tasks that are scheduled. | 204 // of top priority tasks that are scheduled. |
| 211 RasterWorkerPool::CheckForCompletedTasks(); | 205 RasterWorkerPool::CheckForCompletedTasks(); |
| 212 CheckForCompletedUploads(); | 206 CheckForCompletedUploads(); |
| 213 FlushUploads(); | 207 FlushUploads(); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 | 667 |
| 674 throttle_state->SetInteger("bytes_available_for_upload", | 668 throttle_state->SetInteger("bytes_available_for_upload", |
| 675 max_bytes_pending_upload_ - bytes_pending_upload_); | 669 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 676 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 670 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 677 throttle_state->SetInteger("scheduled_raster_task_count", | 671 throttle_state->SetInteger("scheduled_raster_task_count", |
| 678 scheduled_raster_task_count_); | 672 scheduled_raster_task_count_); |
| 679 return throttle_state.PassAs<base::Value>(); | 673 return throttle_state.PassAs<base::Value>(); |
| 680 } | 674 } |
| 681 | 675 |
| 682 } // namespace cc | 676 } // namespace cc |
| OLD | NEW |