| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/containers/stack_container.h" | 9 #include "base/containers/stack_container.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "cc/debug/traced_value.h" | 11 #include "cc/debug/traced_value.h" |
| 12 #include "cc/resources/resource.h" | 12 #include "cc/resources/resource.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const int kCheckForCompletedRasterTasksDelayMs = 6; | 17 const int kCheckForCompletedRasterTasksDelayMs = 6; |
| 18 | 18 |
| 19 const size_t kMaxScheduledRasterTasks = 48; | 19 const size_t kMaxScheduledRasterTasks = 48; |
| 20 | 20 |
| 21 typedef base::StackVector<internal::WorkerPoolTask*, kMaxScheduledRasterTasks> | 21 typedef base::StackVector<internal::RasterTask*, kMaxScheduledRasterTasks> |
| 22 WorkerPoolTaskVector; | 22 RasterTaskVector; |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 // static | 26 // static |
| 27 scoped_ptr<PixelBufferRasterWorkerPool> PixelBufferRasterWorkerPool::Create( | 27 scoped_ptr<RasterWorkerPool> PixelBufferRasterWorkerPool::Create( |
| 28 base::SequencedTaskRunner* task_runner, | 28 base::SequencedTaskRunner* task_runner, |
| 29 internal::TaskGraphRunner* task_graph_runner, |
| 29 ResourceProvider* resource_provider, | 30 ResourceProvider* resource_provider, |
| 30 size_t max_transfer_buffer_usage_bytes) { | 31 size_t max_transfer_buffer_usage_bytes) { |
| 31 return make_scoped_ptr( | 32 return make_scoped_ptr<RasterWorkerPool>( |
| 32 new PixelBufferRasterWorkerPool(task_runner, | 33 new PixelBufferRasterWorkerPool(task_runner, |
| 33 GetTaskGraphRunner(), | 34 task_graph_runner, |
| 34 resource_provider, | 35 resource_provider, |
| 35 max_transfer_buffer_usage_bytes)); | 36 max_transfer_buffer_usage_bytes)); |
| 36 } | 37 } |
| 37 | 38 |
| 38 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( | 39 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( |
| 39 base::SequencedTaskRunner* task_runner, | 40 base::SequencedTaskRunner* task_runner, |
| 40 internal::TaskGraphRunner* task_graph_runner, | 41 internal::TaskGraphRunner* task_graph_runner, |
| 41 ResourceProvider* resource_provider, | 42 ResourceProvider* resource_provider, |
| 42 size_t max_transfer_buffer_usage_bytes) | 43 size_t max_transfer_buffer_usage_bytes) |
| 43 : task_runner_(task_runner), | 44 : task_runner_(task_runner), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 61 | 62 |
| 62 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { | 63 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { |
| 63 DCHECK(!check_for_completed_raster_tasks_pending_); | 64 DCHECK(!check_for_completed_raster_tasks_pending_); |
| 64 DCHECK_EQ(0u, raster_task_states_.size()); | 65 DCHECK_EQ(0u, raster_task_states_.size()); |
| 65 DCHECK_EQ(0u, raster_tasks_with_pending_upload_.size()); | 66 DCHECK_EQ(0u, raster_tasks_with_pending_upload_.size()); |
| 66 DCHECK_EQ(0u, completed_raster_tasks_.size()); | 67 DCHECK_EQ(0u, completed_raster_tasks_.size()); |
| 67 DCHECK_EQ(0u, completed_image_decode_tasks_.size()); | 68 DCHECK_EQ(0u, completed_image_decode_tasks_.size()); |
| 68 DCHECK_EQ(0u, raster_tasks_required_for_activation_count_); | 69 DCHECK_EQ(0u, raster_tasks_required_for_activation_count_); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void PixelBufferRasterWorkerPool::SetClient(RasterWorkerPoolClient* client) { | 72 Rasterizer* PixelBufferRasterWorkerPool::AsRasterizer() { return this; } |
| 73 |
| 74 void PixelBufferRasterWorkerPool::SetClient(RasterizerClient* client) { |
| 72 client_ = client; | 75 client_ = client; |
| 73 } | 76 } |
| 74 | 77 |
| 75 void PixelBufferRasterWorkerPool::Shutdown() { | 78 void PixelBufferRasterWorkerPool::Shutdown() { |
| 76 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::Shutdown"); | 79 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::Shutdown"); |
| 77 | 80 |
| 78 shutdown_ = true; | 81 shutdown_ = true; |
| 79 | 82 |
| 80 internal::TaskGraph empty; | 83 internal::TaskGraph empty; |
| 81 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 84 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
| 82 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | 85 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
| 83 | 86 |
| 84 CheckForCompletedWorkerPoolTasks(); | 87 CheckForCompletedRasterizerTasks(); |
| 85 CheckForCompletedUploads(); | 88 CheckForCompletedUploads(); |
| 86 | 89 |
| 87 check_for_completed_raster_tasks_pending_ = false; | 90 check_for_completed_raster_tasks_pending_ = false; |
| 88 | 91 |
| 89 for (RasterTaskState::Vector::iterator it = raster_task_states_.begin(); | 92 for (RasterTaskState::Vector::iterator it = raster_task_states_.begin(); |
| 90 it != raster_task_states_.end(); | 93 it != raster_task_states_.end(); |
| 91 ++it) { | 94 ++it) { |
| 92 RasterTaskState& state = *it; | 95 RasterTaskState& state = *it; |
| 93 | 96 |
| 94 // All unscheduled tasks need to be canceled. | 97 // All unscheduled tasks need to be canceled. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 115 should_notify_client_if_no_tasks_are_pending_ = true; | 118 should_notify_client_if_no_tasks_are_pending_ = true; |
| 116 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; | 119 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; |
| 117 | 120 |
| 118 raster_tasks_required_for_activation_count_ = 0u; | 121 raster_tasks_required_for_activation_count_ = 0u; |
| 119 | 122 |
| 120 // Update raster task state and remove items from old queue. | 123 // Update raster task state and remove items from old queue. |
| 121 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); | 124 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); |
| 122 it != queue->items.end(); | 125 it != queue->items.end(); |
| 123 ++it) { | 126 ++it) { |
| 124 const RasterTaskQueue::Item& item = *it; | 127 const RasterTaskQueue::Item& item = *it; |
| 125 internal::WorkerPoolTask* task = item.task; | 128 internal::RasterTask* task = item.task; |
| 126 | 129 |
| 127 // Remove any old items that are associated with this task. The result is | 130 // Remove any old items that are associated with this task. The result is |
| 128 // that the old queue is left with all items not present in this queue, | 131 // that the old queue is left with all items not present in this queue, |
| 129 // which we use below to determine what tasks need to be canceled. | 132 // which we use below to determine what tasks need to be canceled. |
| 130 RasterTaskQueue::Item::Vector::iterator old_it = | 133 RasterTaskQueue::Item::Vector::iterator old_it = |
| 131 std::find_if(raster_tasks_.items.begin(), | 134 std::find_if(raster_tasks_.items.begin(), |
| 132 raster_tasks_.items.end(), | 135 raster_tasks_.items.end(), |
| 133 RasterTaskQueue::Item::TaskComparator(task)); | 136 RasterTaskQueue::Item::TaskComparator(task)); |
| 134 if (old_it != raster_tasks_.items.end()) { | 137 if (old_it != raster_tasks_.items.end()) { |
| 135 std::swap(*old_it, raster_tasks_.items.back()); | 138 std::swap(*old_it, raster_tasks_.items.back()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 159 RasterTaskState(task, item.required_for_activation)); | 162 RasterTaskState(task, item.required_for_activation)); |
| 160 raster_tasks_required_for_activation_count_ += item.required_for_activation; | 163 raster_tasks_required_for_activation_count_ += item.required_for_activation; |
| 161 } | 164 } |
| 162 | 165 |
| 163 // Determine what tasks in old queue need to be canceled. | 166 // Determine what tasks in old queue need to be canceled. |
| 164 for (RasterTaskQueue::Item::Vector::const_iterator it = | 167 for (RasterTaskQueue::Item::Vector::const_iterator it = |
| 165 raster_tasks_.items.begin(); | 168 raster_tasks_.items.begin(); |
| 166 it != raster_tasks_.items.end(); | 169 it != raster_tasks_.items.end(); |
| 167 ++it) { | 170 ++it) { |
| 168 const RasterTaskQueue::Item& item = *it; | 171 const RasterTaskQueue::Item& item = *it; |
| 169 internal::WorkerPoolTask* task = item.task; | 172 internal::RasterTask* task = item.task; |
| 170 | 173 |
| 171 RasterTaskState::Vector::iterator state_it = | 174 RasterTaskState::Vector::iterator state_it = |
| 172 std::find_if(raster_task_states_.begin(), | 175 std::find_if(raster_task_states_.begin(), |
| 173 raster_task_states_.end(), | 176 raster_task_states_.end(), |
| 174 RasterTaskState::TaskComparator(task)); | 177 RasterTaskState::TaskComparator(task)); |
| 175 // We've already processed completion if we can't find a RasterTaskState for | 178 // We've already processed completion if we can't find a RasterTaskState for |
| 176 // this task. | 179 // this task. |
| 177 if (state_it == raster_task_states_.end()) | 180 if (state_it == raster_task_states_.end()) |
| 178 continue; | 181 continue; |
| 179 | 182 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 191 | 194 |
| 192 // No longer required for activation. | 195 // No longer required for activation. |
| 193 state.required_for_activation = false; | 196 state.required_for_activation = false; |
| 194 } | 197 } |
| 195 | 198 |
| 196 raster_tasks_.Swap(queue); | 199 raster_tasks_.Swap(queue); |
| 197 | 200 |
| 198 // Check for completed tasks when ScheduleTasks() is called as | 201 // Check for completed tasks when ScheduleTasks() is called as |
| 199 // priorities might have changed and this maximizes the number | 202 // priorities might have changed and this maximizes the number |
| 200 // of top priority tasks that are scheduled. | 203 // of top priority tasks that are scheduled. |
| 201 CheckForCompletedWorkerPoolTasks(); | 204 CheckForCompletedRasterizerTasks(); |
| 202 CheckForCompletedUploads(); | 205 CheckForCompletedUploads(); |
| 203 FlushUploads(); | 206 FlushUploads(); |
| 204 | 207 |
| 205 // Schedule new tasks. | 208 // Schedule new tasks. |
| 206 ScheduleMoreTasks(); | 209 ScheduleMoreTasks(); |
| 207 | 210 |
| 208 // Cancel any pending check for completed raster tasks and schedule | 211 // Cancel any pending check for completed raster tasks and schedule |
| 209 // another check. | 212 // another check. |
| 210 check_for_completed_raster_tasks_time_ = base::TimeTicks(); | 213 check_for_completed_raster_tasks_time_ = base::TimeTicks(); |
| 211 ScheduleCheckForCompletedRasterTasks(); | 214 ScheduleCheckForCompletedRasterTasks(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 223 return GL_TEXTURE_2D; | 226 return GL_TEXTURE_2D; |
| 224 } | 227 } |
| 225 | 228 |
| 226 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { | 229 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { |
| 227 return resource_provider_->memory_efficient_texture_format(); | 230 return resource_provider_->memory_efficient_texture_format(); |
| 228 } | 231 } |
| 229 | 232 |
| 230 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { | 233 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { |
| 231 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); | 234 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); |
| 232 | 235 |
| 233 CheckForCompletedWorkerPoolTasks(); | 236 CheckForCompletedRasterizerTasks(); |
| 234 CheckForCompletedUploads(); | 237 CheckForCompletedUploads(); |
| 235 FlushUploads(); | 238 FlushUploads(); |
| 236 | 239 |
| 237 for (internal::WorkerPoolTask::Vector::const_iterator it = | 240 for (internal::RasterizerTask::Vector::const_iterator it = |
| 238 completed_image_decode_tasks_.begin(); | 241 completed_image_decode_tasks_.begin(); |
| 239 it != completed_image_decode_tasks_.end(); | 242 it != completed_image_decode_tasks_.end(); |
| 240 ++it) { | 243 ++it) { |
| 241 internal::WorkerPoolTask* task = it->get(); | 244 internal::RasterizerTask* task = it->get(); |
| 242 task->RunReplyOnOriginThread(); | 245 task->RunReplyOnOriginThread(); |
| 243 } | 246 } |
| 244 completed_image_decode_tasks_.clear(); | 247 completed_image_decode_tasks_.clear(); |
| 245 | 248 |
| 246 for (internal::WorkerPoolTask::Vector::const_iterator it = | 249 for (internal::RasterTask::Vector::const_iterator it = |
| 247 completed_raster_tasks_.begin(); | 250 completed_raster_tasks_.begin(); |
| 248 it != completed_raster_tasks_.end(); | 251 it != completed_raster_tasks_.end(); |
| 249 ++it) { | 252 ++it) { |
| 250 internal::WorkerPoolTask* task = it->get(); | 253 internal::RasterTask* task = it->get(); |
| 251 RasterTaskState::Vector::iterator state_it = | 254 RasterTaskState::Vector::iterator state_it = |
| 252 std::find_if(raster_task_states_.begin(), | 255 std::find_if(raster_task_states_.begin(), |
| 253 raster_task_states_.end(), | 256 raster_task_states_.end(), |
| 254 RasterTaskState::TaskComparator(task)); | 257 RasterTaskState::TaskComparator(task)); |
| 255 DCHECK(state_it != raster_task_states_.end()); | 258 DCHECK(state_it != raster_task_states_.end()); |
| 256 DCHECK_EQ(RasterTaskState::COMPLETED, state_it->type); | 259 DCHECK_EQ(RasterTaskState::COMPLETED, state_it->type); |
| 257 | 260 |
| 258 std::swap(*state_it, raster_task_states_.back()); | 261 std::swap(*state_it, raster_task_states_.back()); |
| 259 raster_task_states_.pop_back(); | 262 raster_task_states_.pop_back(); |
| 260 | 263 |
| 261 task->RunReplyOnOriginThread(); | 264 task->RunReplyOnOriginThread(); |
| 262 } | 265 } |
| 263 completed_raster_tasks_.clear(); | 266 completed_raster_tasks_.clear(); |
| 264 } | 267 } |
| 265 | 268 |
| 266 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster( | 269 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster( |
| 267 internal::WorkerPoolTask* task, | 270 internal::RasterTask* task) { |
| 268 const Resource* resource) { | |
| 269 RasterTaskState::Vector::iterator it = | 271 RasterTaskState::Vector::iterator it = |
| 270 std::find_if(raster_task_states_.begin(), | 272 std::find_if(raster_task_states_.begin(), |
| 271 raster_task_states_.end(), | 273 raster_task_states_.end(), |
| 272 RasterTaskState::TaskComparator(task)); | 274 RasterTaskState::TaskComparator(task)); |
| 273 DCHECK(it != raster_task_states_.end()); | 275 DCHECK(it != raster_task_states_.end()); |
| 274 DCHECK(!it->resource); | 276 resource_provider_->AcquirePixelRasterBuffer(task->resource()->id()); |
| 275 it->resource = resource; | 277 return resource_provider_->MapPixelRasterBuffer(task->resource()->id()); |
| 276 resource_provider_->AcquirePixelRasterBuffer(resource->id()); | |
| 277 return resource_provider_->MapPixelRasterBuffer(resource->id()); | |
| 278 } | 278 } |
| 279 | 279 |
| 280 void PixelBufferRasterWorkerPool::ReleaseCanvasForRaster( | 280 void PixelBufferRasterWorkerPool::ReleaseCanvasForRaster( |
| 281 internal::WorkerPoolTask* task, | 281 internal::RasterTask* task) { |
| 282 const Resource* resource) { | |
| 283 RasterTaskState::Vector::iterator it = | 282 RasterTaskState::Vector::iterator it = |
| 284 std::find_if(raster_task_states_.begin(), | 283 std::find_if(raster_task_states_.begin(), |
| 285 raster_task_states_.end(), | 284 raster_task_states_.end(), |
| 286 RasterTaskState::TaskComparator(task)); | 285 RasterTaskState::TaskComparator(task)); |
| 287 DCHECK(it != raster_task_states_.end()); | 286 DCHECK(it != raster_task_states_.end()); |
| 288 DCHECK(it->resource == resource); | 287 resource_provider_->ReleasePixelRasterBuffer(task->resource()->id()); |
| 289 resource_provider_->ReleasePixelRasterBuffer(resource->id()); | |
| 290 } | 288 } |
| 291 | 289 |
| 292 void PixelBufferRasterWorkerPool::OnRasterFinished() { | 290 void PixelBufferRasterWorkerPool::OnRasterFinished() { |
| 293 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::OnRasterFinished"); | 291 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::OnRasterFinished"); |
| 294 | 292 |
| 295 // |should_notify_client_if_no_tasks_are_pending_| can be set to false as | 293 // |should_notify_client_if_no_tasks_are_pending_| can be set to false as |
| 296 // a result of a scheduled CheckForCompletedRasterTasks() call. No need to | 294 // a result of a scheduled CheckForCompletedRasterTasks() call. No need to |
| 297 // perform another check in that case as we've already notified the client. | 295 // perform another check in that case as we've already notified the client. |
| 298 if (!should_notify_client_if_no_tasks_are_pending_) | 296 if (!should_notify_client_if_no_tasks_are_pending_) |
| 299 return; | 297 return; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 325 | 323 |
| 326 void PixelBufferRasterWorkerPool::FlushUploads() { | 324 void PixelBufferRasterWorkerPool::FlushUploads() { |
| 327 if (!has_performed_uploads_since_last_flush_) | 325 if (!has_performed_uploads_since_last_flush_) |
| 328 return; | 326 return; |
| 329 | 327 |
| 330 resource_provider_->ShallowFlushIfSupported(); | 328 resource_provider_->ShallowFlushIfSupported(); |
| 331 has_performed_uploads_since_last_flush_ = false; | 329 has_performed_uploads_since_last_flush_ = false; |
| 332 } | 330 } |
| 333 | 331 |
| 334 void PixelBufferRasterWorkerPool::CheckForCompletedUploads() { | 332 void PixelBufferRasterWorkerPool::CheckForCompletedUploads() { |
| 335 internal::WorkerPoolTask::Vector tasks_with_completed_uploads; | 333 internal::RasterTask::Vector tasks_with_completed_uploads; |
| 336 | 334 |
| 337 // First check if any have completed. | 335 // First check if any have completed. |
| 338 while (!raster_tasks_with_pending_upload_.empty()) { | 336 while (!raster_tasks_with_pending_upload_.empty()) { |
| 339 internal::WorkerPoolTask* task = | 337 internal::RasterTask* task = |
| 340 raster_tasks_with_pending_upload_.front().get(); | 338 raster_tasks_with_pending_upload_.front().get(); |
| 341 RasterTaskState::Vector::const_iterator it = | 339 DCHECK(std::find_if(raster_task_states_.begin(), |
| 342 std::find_if(raster_task_states_.begin(), | 340 raster_task_states_.end(), |
| 343 raster_task_states_.end(), | 341 RasterTaskState::TaskComparator(task)) != |
| 344 RasterTaskState::TaskComparator(task)); | 342 raster_task_states_.end()); |
| 345 DCHECK(it != raster_task_states_.end()); | 343 DCHECK_EQ(RasterTaskState::UPLOADING, |
| 346 DCHECK_EQ(RasterTaskState::UPLOADING, it->type); | 344 std::find_if(raster_task_states_.begin(), |
| 345 raster_task_states_.end(), |
| 346 RasterTaskState::TaskComparator(task))->type); |
| 347 | 347 |
| 348 // Uploads complete in the order they are issued. | 348 // Uploads complete in the order they are issued. |
| 349 if (!resource_provider_->DidSetPixelsComplete(it->resource->id())) | 349 if (!resource_provider_->DidSetPixelsComplete(task->resource()->id())) |
| 350 break; | 350 break; |
| 351 | 351 |
| 352 tasks_with_completed_uploads.push_back(task); | 352 tasks_with_completed_uploads.push_back(task); |
| 353 raster_tasks_with_pending_upload_.pop_front(); | 353 raster_tasks_with_pending_upload_.pop_front(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 DCHECK(client_); | 356 DCHECK(client_); |
| 357 bool should_force_some_uploads_to_complete = | 357 bool should_force_some_uploads_to_complete = |
| 358 shutdown_ || client_->ShouldForceTasksRequiredForActivationToComplete(); | 358 shutdown_ || client_->ShouldForceTasksRequiredForActivationToComplete(); |
| 359 | 359 |
| 360 if (should_force_some_uploads_to_complete) { | 360 if (should_force_some_uploads_to_complete) { |
| 361 internal::WorkerPoolTask::Vector tasks_with_uploads_to_force; | 361 internal::RasterTask::Vector tasks_with_uploads_to_force; |
| 362 TaskDeque::iterator it = raster_tasks_with_pending_upload_.begin(); | 362 RasterTaskDeque::iterator it = raster_tasks_with_pending_upload_.begin(); |
| 363 while (it != raster_tasks_with_pending_upload_.end()) { | 363 while (it != raster_tasks_with_pending_upload_.end()) { |
| 364 internal::WorkerPoolTask* task = it->get(); | 364 internal::RasterTask* task = it->get(); |
| 365 RasterTaskState::Vector::const_iterator state_it = | 365 RasterTaskState::Vector::const_iterator state_it = |
| 366 std::find_if(raster_task_states_.begin(), | 366 std::find_if(raster_task_states_.begin(), |
| 367 raster_task_states_.end(), | 367 raster_task_states_.end(), |
| 368 RasterTaskState::TaskComparator(task)); | 368 RasterTaskState::TaskComparator(task)); |
| 369 DCHECK(state_it != raster_task_states_.end()); | 369 DCHECK(state_it != raster_task_states_.end()); |
| 370 const RasterTaskState& state = *state_it; |
| 370 | 371 |
| 371 // Force all uploads required for activation to complete. | 372 // Force all uploads required for activation to complete. |
| 372 // During shutdown, force all pending uploads to complete. | 373 // During shutdown, force all pending uploads to complete. |
| 373 if (shutdown_ || state_it->required_for_activation) { | 374 if (shutdown_ || state.required_for_activation) { |
| 374 tasks_with_uploads_to_force.push_back(task); | 375 tasks_with_uploads_to_force.push_back(task); |
| 375 tasks_with_completed_uploads.push_back(task); | 376 tasks_with_completed_uploads.push_back(task); |
| 376 it = raster_tasks_with_pending_upload_.erase(it); | 377 it = raster_tasks_with_pending_upload_.erase(it); |
| 377 continue; | 378 continue; |
| 378 } | 379 } |
| 379 | 380 |
| 380 ++it; | 381 ++it; |
| 381 } | 382 } |
| 382 | 383 |
| 383 // Force uploads in reverse order. Since forcing can cause a wait on | 384 // Force uploads in reverse order. Since forcing can cause a wait on |
| 384 // all previous uploads, we would rather wait only once downstream. | 385 // all previous uploads, we would rather wait only once downstream. |
| 385 for (internal::WorkerPoolTask::Vector::reverse_iterator it = | 386 for (internal::RasterTask::Vector::reverse_iterator it = |
| 386 tasks_with_uploads_to_force.rbegin(); | 387 tasks_with_uploads_to_force.rbegin(); |
| 387 it != tasks_with_uploads_to_force.rend(); | 388 it != tasks_with_uploads_to_force.rend(); |
| 388 ++it) { | 389 ++it) { |
| 389 internal::WorkerPoolTask* task = it->get(); | 390 internal::RasterTask* task = it->get(); |
| 390 RasterTaskState::Vector::const_iterator state_it = | |
| 391 std::find_if(raster_task_states_.begin(), | |
| 392 raster_task_states_.end(), | |
| 393 RasterTaskState::TaskComparator(task)); | |
| 394 DCHECK(state_it != raster_task_states_.end()); | |
| 395 DCHECK(state_it->resource); | |
| 396 | 391 |
| 397 resource_provider_->ForceSetPixelsToComplete(state_it->resource->id()); | 392 resource_provider_->ForceSetPixelsToComplete(task->resource()->id()); |
| 398 has_performed_uploads_since_last_flush_ = true; | 393 has_performed_uploads_since_last_flush_ = true; |
| 399 } | 394 } |
| 400 } | 395 } |
| 401 | 396 |
| 402 // Release shared memory and move tasks with completed uploads | 397 // Release shared memory and move tasks with completed uploads |
| 403 // to |completed_raster_tasks_|. | 398 // to |completed_raster_tasks_|. |
| 404 for (internal::WorkerPoolTask::Vector::const_iterator it = | 399 for (internal::RasterTask::Vector::const_iterator it = |
| 405 tasks_with_completed_uploads.begin(); | 400 tasks_with_completed_uploads.begin(); |
| 406 it != tasks_with_completed_uploads.end(); | 401 it != tasks_with_completed_uploads.end(); |
| 407 ++it) { | 402 ++it) { |
| 408 internal::WorkerPoolTask* task = it->get(); | 403 internal::RasterTask* task = it->get(); |
| 409 RasterTaskState::Vector::iterator state_it = | 404 RasterTaskState::Vector::iterator state_it = |
| 410 std::find_if(raster_task_states_.begin(), | 405 std::find_if(raster_task_states_.begin(), |
| 411 raster_task_states_.end(), | 406 raster_task_states_.end(), |
| 412 RasterTaskState::TaskComparator(task)); | 407 RasterTaskState::TaskComparator(task)); |
| 413 DCHECK(state_it != raster_task_states_.end()); | 408 DCHECK(state_it != raster_task_states_.end()); |
| 414 RasterTaskState& state = *state_it; | 409 RasterTaskState& state = *state_it; |
| 415 | 410 |
| 416 bytes_pending_upload_ -= state.resource->bytes(); | 411 bytes_pending_upload_ -= task->resource()->bytes(); |
| 417 | 412 |
| 418 task->WillComplete(); | 413 task->WillComplete(); |
| 419 task->CompleteOnOriginThread(this); | 414 task->CompleteOnOriginThread(this); |
| 420 task->DidComplete(); | 415 task->DidComplete(); |
| 421 | 416 |
| 422 DCHECK(std::find(completed_raster_tasks_.begin(), | 417 DCHECK(std::find(completed_raster_tasks_.begin(), |
| 423 completed_raster_tasks_.end(), | 418 completed_raster_tasks_.end(), |
| 424 task) == completed_raster_tasks_.end()); | 419 task) == completed_raster_tasks_.end()); |
| 425 completed_raster_tasks_.push_back(task); | 420 completed_raster_tasks_.push_back(task); |
| 426 state.type = RasterTaskState::COMPLETED; | 421 state.type = RasterTaskState::COMPLETED; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 CheckForCompletedRasterTasks(); | 467 CheckForCompletedRasterTasks(); |
| 473 } | 468 } |
| 474 | 469 |
| 475 void PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks() { | 470 void PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks() { |
| 476 TRACE_EVENT0("cc", | 471 TRACE_EVENT0("cc", |
| 477 "PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks"); | 472 "PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks"); |
| 478 | 473 |
| 479 DCHECK(should_notify_client_if_no_tasks_are_pending_); | 474 DCHECK(should_notify_client_if_no_tasks_are_pending_); |
| 480 check_for_completed_raster_tasks_time_ = base::TimeTicks(); | 475 check_for_completed_raster_tasks_time_ = base::TimeTicks(); |
| 481 | 476 |
| 482 CheckForCompletedWorkerPoolTasks(); | 477 CheckForCompletedRasterizerTasks(); |
| 483 CheckForCompletedUploads(); | 478 CheckForCompletedUploads(); |
| 484 FlushUploads(); | 479 FlushUploads(); |
| 485 | 480 |
| 486 // Determine what client notifications to generate. | 481 // Determine what client notifications to generate. |
| 487 bool will_notify_client_that_no_tasks_required_for_activation_are_pending = | 482 bool will_notify_client_that_no_tasks_required_for_activation_are_pending = |
| 488 (should_notify_client_if_no_tasks_required_for_activation_are_pending_ && | 483 (should_notify_client_if_no_tasks_required_for_activation_are_pending_ && |
| 489 !raster_required_for_activation_finished_task_pending_ && | 484 !raster_required_for_activation_finished_task_pending_ && |
| 490 !HasPendingTasksRequiredForActivation()); | 485 !HasPendingTasksRequiredForActivation()); |
| 491 bool will_notify_client_that_no_tasks_are_pending = | 486 bool will_notify_client_that_no_tasks_are_pending = |
| 492 (should_notify_client_if_no_tasks_are_pending_ && | 487 (should_notify_client_if_no_tasks_are_pending_ && |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 if (will_notify_client_that_no_tasks_are_pending) { | 519 if (will_notify_client_that_no_tasks_are_pending) { |
| 525 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); | 520 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); |
| 526 DCHECK(!HasPendingTasksRequiredForActivation()); | 521 DCHECK(!HasPendingTasksRequiredForActivation()); |
| 527 client_->DidFinishRunningTasks(); | 522 client_->DidFinishRunningTasks(); |
| 528 } | 523 } |
| 529 } | 524 } |
| 530 | 525 |
| 531 void PixelBufferRasterWorkerPool::ScheduleMoreTasks() { | 526 void PixelBufferRasterWorkerPool::ScheduleMoreTasks() { |
| 532 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleMoreTasks"); | 527 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleMoreTasks"); |
| 533 | 528 |
| 534 WorkerPoolTaskVector tasks; | 529 RasterTaskVector tasks; |
| 535 WorkerPoolTaskVector tasks_required_for_activation; | 530 RasterTaskVector tasks_required_for_activation; |
| 536 | 531 |
| 537 unsigned priority = kRasterTaskPriorityBase; | 532 unsigned priority = kRasterTaskPriorityBase; |
| 538 | 533 |
| 539 graph_.Reset(); | 534 graph_.Reset(); |
| 540 | 535 |
| 541 size_t bytes_pending_upload = bytes_pending_upload_; | 536 size_t bytes_pending_upload = bytes_pending_upload_; |
| 542 bool did_throttle_raster_tasks = false; | 537 bool did_throttle_raster_tasks = false; |
| 543 bool did_throttle_raster_tasks_required_for_activation = false; | 538 bool did_throttle_raster_tasks_required_for_activation = false; |
| 544 | 539 |
| 545 for (RasterTaskQueue::Item::Vector::const_iterator it = | 540 for (RasterTaskQueue::Item::Vector::const_iterator it = |
| 546 raster_tasks_.items.begin(); | 541 raster_tasks_.items.begin(); |
| 547 it != raster_tasks_.items.end(); | 542 it != raster_tasks_.items.end(); |
| 548 ++it) { | 543 ++it) { |
| 549 const RasterTaskQueue::Item& item = *it; | 544 const RasterTaskQueue::Item& item = *it; |
| 550 internal::RasterWorkerPoolTask* task = item.task; | 545 internal::RasterTask* task = item.task; |
| 551 | 546 |
| 552 // |raster_task_states_| contains the state of all tasks that we have not | 547 // |raster_task_states_| contains the state of all tasks that we have not |
| 553 // yet run reply callbacks for. | 548 // yet run reply callbacks for. |
| 554 RasterTaskState::Vector::iterator state_it = | 549 RasterTaskState::Vector::iterator state_it = |
| 555 std::find_if(raster_task_states_.begin(), | 550 std::find_if(raster_task_states_.begin(), |
| 556 raster_task_states_.end(), | 551 raster_task_states_.end(), |
| 557 RasterTaskState::TaskComparator(task)); | 552 RasterTaskState::TaskComparator(task)); |
| 558 if (state_it == raster_task_states_.end()) | 553 if (state_it == raster_task_states_.end()) |
| 559 continue; | 554 continue; |
| 560 | 555 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); | 599 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); |
| 605 | 600 |
| 606 tasks.container().push_back(task); | 601 tasks.container().push_back(task); |
| 607 if (item.required_for_activation) | 602 if (item.required_for_activation) |
| 608 tasks_required_for_activation.container().push_back(task); | 603 tasks_required_for_activation.container().push_back(task); |
| 609 } | 604 } |
| 610 | 605 |
| 611 // Cancel existing OnRasterFinished callbacks. | 606 // Cancel existing OnRasterFinished callbacks. |
| 612 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 607 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 613 | 608 |
| 614 scoped_refptr<internal::WorkerPoolTask> | 609 scoped_refptr<internal::RasterizerTask> |
| 615 new_raster_required_for_activation_finished_task; | 610 new_raster_required_for_activation_finished_task; |
| 616 | 611 |
| 617 size_t scheduled_raster_task_required_for_activation_count = | 612 size_t scheduled_raster_task_required_for_activation_count = |
| 618 tasks_required_for_activation.container().size(); | 613 tasks_required_for_activation.container().size(); |
| 619 DCHECK_LE(scheduled_raster_task_required_for_activation_count, | 614 DCHECK_LE(scheduled_raster_task_required_for_activation_count, |
| 620 raster_tasks_required_for_activation_count_); | 615 raster_tasks_required_for_activation_count_); |
| 621 // Schedule OnRasterTasksRequiredForActivationFinished call only when | 616 // Schedule OnRasterTasksRequiredForActivationFinished call only when |
| 622 // notification is pending and throttling is not preventing all pending | 617 // notification is pending and throttling is not preventing all pending |
| 623 // tasks required for activation from being scheduled. | 618 // tasks required for activation from being scheduled. |
| 624 if (!did_throttle_raster_tasks_required_for_activation && | 619 if (!did_throttle_raster_tasks_required_for_activation && |
| 625 should_notify_client_if_no_tasks_required_for_activation_are_pending_) { | 620 should_notify_client_if_no_tasks_required_for_activation_are_pending_) { |
| 626 new_raster_required_for_activation_finished_task = | 621 new_raster_required_for_activation_finished_task = |
| 627 CreateRasterRequiredForActivationFinishedTask( | 622 CreateRasterRequiredForActivationFinishedTask( |
| 628 raster_tasks_.required_for_activation_count, | 623 raster_tasks_.required_for_activation_count, |
| 629 task_runner_.get(), | 624 task_runner_.get(), |
| 630 base::Bind(&PixelBufferRasterWorkerPool:: | 625 base::Bind(&PixelBufferRasterWorkerPool:: |
| 631 OnRasterRequiredForActivationFinished, | 626 OnRasterRequiredForActivationFinished, |
| 632 raster_finished_weak_ptr_factory_.GetWeakPtr())); | 627 raster_finished_weak_ptr_factory_.GetWeakPtr())); |
| 633 raster_required_for_activation_finished_task_pending_ = true; | 628 raster_required_for_activation_finished_task_pending_ = true; |
| 634 InsertNodeForTask(&graph_, | 629 InsertNodeForTask(&graph_, |
| 635 new_raster_required_for_activation_finished_task.get(), | 630 new_raster_required_for_activation_finished_task.get(), |
| 636 kRasterRequiredForActivationFinishedTaskPriority, | 631 kRasterRequiredForActivationFinishedTaskPriority, |
| 637 scheduled_raster_task_required_for_activation_count); | 632 scheduled_raster_task_required_for_activation_count); |
| 638 for (WorkerPoolTaskVector::ContainerType::const_iterator it = | 633 for (RasterTaskVector::ContainerType::const_iterator it = |
| 639 tasks_required_for_activation.container().begin(); | 634 tasks_required_for_activation.container().begin(); |
| 640 it != tasks_required_for_activation.container().end(); | 635 it != tasks_required_for_activation.container().end(); |
| 641 ++it) { | 636 ++it) { |
| 642 graph_.edges.push_back(internal::TaskGraph::Edge( | 637 graph_.edges.push_back(internal::TaskGraph::Edge( |
| 643 *it, new_raster_required_for_activation_finished_task.get())); | 638 *it, new_raster_required_for_activation_finished_task.get())); |
| 644 } | 639 } |
| 645 } | 640 } |
| 646 | 641 |
| 647 scoped_refptr<internal::WorkerPoolTask> new_raster_finished_task; | 642 scoped_refptr<internal::RasterizerTask> new_raster_finished_task; |
| 648 | 643 |
| 649 size_t scheduled_raster_task_count = tasks.container().size(); | 644 size_t scheduled_raster_task_count = tasks.container().size(); |
| 650 DCHECK_LE(scheduled_raster_task_count, PendingRasterTaskCount()); | 645 DCHECK_LE(scheduled_raster_task_count, PendingRasterTaskCount()); |
| 651 // Schedule OnRasterTasksFinished call only when notification is pending | 646 // Schedule OnRasterTasksFinished call only when notification is pending |
| 652 // and throttling is not preventing all pending tasks from being scheduled. | 647 // and throttling is not preventing all pending tasks from being scheduled. |
| 653 if (!did_throttle_raster_tasks && | 648 if (!did_throttle_raster_tasks && |
| 654 should_notify_client_if_no_tasks_are_pending_) { | 649 should_notify_client_if_no_tasks_are_pending_) { |
| 655 new_raster_finished_task = CreateRasterFinishedTask( | 650 new_raster_finished_task = CreateRasterFinishedTask( |
| 656 task_runner_.get(), | 651 task_runner_.get(), |
| 657 base::Bind(&PixelBufferRasterWorkerPool::OnRasterFinished, | 652 base::Bind(&PixelBufferRasterWorkerPool::OnRasterFinished, |
| 658 raster_finished_weak_ptr_factory_.GetWeakPtr())); | 653 raster_finished_weak_ptr_factory_.GetWeakPtr())); |
| 659 raster_finished_task_pending_ = true; | 654 raster_finished_task_pending_ = true; |
| 660 InsertNodeForTask(&graph_, | 655 InsertNodeForTask(&graph_, |
| 661 new_raster_finished_task.get(), | 656 new_raster_finished_task.get(), |
| 662 kRasterFinishedTaskPriority, | 657 kRasterFinishedTaskPriority, |
| 663 scheduled_raster_task_count); | 658 scheduled_raster_task_count); |
| 664 for (WorkerPoolTaskVector::ContainerType::const_iterator it = | 659 for (RasterTaskVector::ContainerType::const_iterator it = |
| 665 tasks.container().begin(); | 660 tasks.container().begin(); |
| 666 it != tasks.container().end(); | 661 it != tasks.container().end(); |
| 667 ++it) { | 662 ++it) { |
| 668 graph_.edges.push_back( | 663 graph_.edges.push_back( |
| 669 internal::TaskGraph::Edge(*it, new_raster_finished_task.get())); | 664 internal::TaskGraph::Edge(*it, new_raster_finished_task.get())); |
| 670 } | 665 } |
| 671 } | 666 } |
| 672 | 667 |
| 673 ScheduleTasksOnOriginThread(this, &graph_); | 668 ScheduleTasksOnOriginThread(this, &graph_); |
| 674 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); | 669 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 699 if (scheduled_raster_task_count_) | 694 if (scheduled_raster_task_count_) |
| 700 return "rasterizing"; | 695 return "rasterizing"; |
| 701 if (PendingRasterTaskCount()) | 696 if (PendingRasterTaskCount()) |
| 702 return "throttled"; | 697 return "throttled"; |
| 703 if (!raster_tasks_with_pending_upload_.empty()) | 698 if (!raster_tasks_with_pending_upload_.empty()) |
| 704 return "waiting_for_uploads"; | 699 return "waiting_for_uploads"; |
| 705 | 700 |
| 706 return "finishing"; | 701 return "finishing"; |
| 707 } | 702 } |
| 708 | 703 |
| 709 void PixelBufferRasterWorkerPool::CheckForCompletedWorkerPoolTasks() { | 704 void PixelBufferRasterWorkerPool::CheckForCompletedRasterizerTasks() { |
| 710 TRACE_EVENT0("cc", | 705 TRACE_EVENT0("cc", |
| 711 "PixelBufferRasterWorkerPool::CheckForCompletedWorkerPoolTasks"); | 706 "PixelBufferRasterWorkerPool::CheckForCompletedRasterizerTasks"); |
| 712 | 707 |
| 713 task_graph_runner_->CollectCompletedTasks(namespace_token_, | 708 task_graph_runner_->CollectCompletedTasks(namespace_token_, |
| 714 &completed_tasks_); | 709 &completed_tasks_); |
| 715 for (internal::Task::Vector::const_iterator it = completed_tasks_.begin(); | 710 for (internal::Task::Vector::const_iterator it = completed_tasks_.begin(); |
| 716 it != completed_tasks_.end(); | 711 it != completed_tasks_.end(); |
| 717 ++it) { | 712 ++it) { |
| 718 internal::WorkerPoolTask* task = | 713 internal::RasterizerTask* task = |
| 719 static_cast<internal::WorkerPoolTask*>(it->get()); | 714 static_cast<internal::RasterizerTask*>(it->get()); |
| 720 | 715 |
| 721 RasterTaskState::Vector::iterator state_it = | 716 internal::RasterTask* raster_task = task->AsRasterTask(); |
| 722 std::find_if(raster_task_states_.begin(), | 717 if (!raster_task) { |
| 723 raster_task_states_.end(), | |
| 724 RasterTaskState::TaskComparator(task)); | |
| 725 if (state_it == raster_task_states_.end()) { | |
| 726 task->WillComplete(); | 718 task->WillComplete(); |
| 727 task->CompleteOnOriginThread(this); | 719 task->CompleteOnOriginThread(this); |
| 728 task->DidComplete(); | 720 task->DidComplete(); |
| 729 | 721 |
| 730 completed_image_decode_tasks_.push_back(task); | 722 completed_image_decode_tasks_.push_back(task); |
| 731 continue; | 723 continue; |
| 732 } | 724 } |
| 733 | 725 |
| 726 RasterTaskState::Vector::iterator state_it = |
| 727 std::find_if(raster_task_states_.begin(), |
| 728 raster_task_states_.end(), |
| 729 RasterTaskState::TaskComparator(raster_task)); |
| 730 DCHECK(state_it != raster_task_states_.end()); |
| 731 |
| 734 RasterTaskState& state = *state_it; | 732 RasterTaskState& state = *state_it; |
| 735 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type); | 733 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type); |
| 736 DCHECK(state.resource); | |
| 737 | 734 |
| 738 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster(). | 735 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster(). |
| 739 bool content_has_changed = | 736 bool content_has_changed = resource_provider_->UnmapPixelRasterBuffer( |
| 740 resource_provider_->UnmapPixelRasterBuffer(state.resource->id()); | 737 raster_task->resource()->id()); |
| 741 | 738 |
| 742 // |content_has_changed| can be false as result of task being canceled or | 739 // |content_has_changed| can be false as result of task being canceled or |
| 743 // task implementation deciding not to modify bitmap (ie. analysis of raster | 740 // task implementation deciding not to modify bitmap (ie. analysis of raster |
| 744 // commands detected content as a solid color). | 741 // commands detected content as a solid color). |
| 745 if (!content_has_changed) { | 742 if (!content_has_changed) { |
| 746 task->WillComplete(); | 743 raster_task->WillComplete(); |
| 747 task->CompleteOnOriginThread(this); | 744 raster_task->CompleteOnOriginThread(this); |
| 748 task->DidComplete(); | 745 raster_task->DidComplete(); |
| 749 | 746 |
| 750 if (!task->HasFinishedRunning()) { | 747 if (!raster_task->HasFinishedRunning()) { |
| 751 // When priorites change, a raster task can be canceled as a result of | 748 // When priorites change, a raster task can be canceled as a result of |
| 752 // no longer being of high enough priority to fit in our throttled | 749 // no longer being of high enough priority to fit in our throttled |
| 753 // raster task budget. The task has not yet completed in this case. | 750 // raster task budget. The task has not yet completed in this case. |
| 754 RasterTaskQueue::Item::Vector::const_iterator item_it = | 751 RasterTaskQueue::Item::Vector::const_iterator item_it = |
| 755 std::find_if(raster_tasks_.items.begin(), | 752 std::find_if(raster_tasks_.items.begin(), |
| 756 raster_tasks_.items.end(), | 753 raster_tasks_.items.end(), |
| 757 RasterTaskQueue::Item::TaskComparator(task)); | 754 RasterTaskQueue::Item::TaskComparator(raster_task)); |
| 758 if (item_it != raster_tasks_.items.end()) { | 755 if (item_it != raster_tasks_.items.end()) { |
| 759 state.type = RasterTaskState::UNSCHEDULED; | 756 state.type = RasterTaskState::UNSCHEDULED; |
| 760 state.resource = NULL; | |
| 761 continue; | 757 continue; |
| 762 } | 758 } |
| 763 } | 759 } |
| 764 | 760 |
| 765 DCHECK(std::find(completed_raster_tasks_.begin(), | 761 DCHECK(std::find(completed_raster_tasks_.begin(), |
| 766 completed_raster_tasks_.end(), | 762 completed_raster_tasks_.end(), |
| 767 task) == completed_raster_tasks_.end()); | 763 raster_task) == completed_raster_tasks_.end()); |
| 768 completed_raster_tasks_.push_back(task); | 764 completed_raster_tasks_.push_back(raster_task); |
| 769 state.type = RasterTaskState::COMPLETED; | 765 state.type = RasterTaskState::COMPLETED; |
| 770 DCHECK_LE(static_cast<size_t>(state.required_for_activation), | 766 DCHECK_LE(static_cast<size_t>(state.required_for_activation), |
| 771 raster_tasks_required_for_activation_count_); | 767 raster_tasks_required_for_activation_count_); |
| 772 raster_tasks_required_for_activation_count_ -= | 768 raster_tasks_required_for_activation_count_ -= |
| 773 state.required_for_activation; | 769 state.required_for_activation; |
| 774 continue; | 770 continue; |
| 775 } | 771 } |
| 776 | 772 |
| 777 DCHECK(task->HasFinishedRunning()); | 773 DCHECK(raster_task->HasFinishedRunning()); |
| 778 | 774 |
| 779 resource_provider_->BeginSetPixels(state.resource->id()); | 775 resource_provider_->BeginSetPixels(raster_task->resource()->id()); |
| 780 has_performed_uploads_since_last_flush_ = true; | 776 has_performed_uploads_since_last_flush_ = true; |
| 781 | 777 |
| 782 bytes_pending_upload_ += state.resource->bytes(); | 778 bytes_pending_upload_ += raster_task->resource()->bytes(); |
| 783 raster_tasks_with_pending_upload_.push_back(task); | 779 raster_tasks_with_pending_upload_.push_back(raster_task); |
| 784 state.type = RasterTaskState::UPLOADING; | 780 state.type = RasterTaskState::UPLOADING; |
| 785 } | 781 } |
| 786 completed_tasks_.clear(); | 782 completed_tasks_.clear(); |
| 787 } | 783 } |
| 788 | 784 |
| 789 scoped_ptr<base::Value> PixelBufferRasterWorkerPool::StateAsValue() const { | 785 scoped_ptr<base::Value> PixelBufferRasterWorkerPool::StateAsValue() const { |
| 790 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); | 786 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); |
| 791 | 787 |
| 792 state->SetInteger("completed_count", completed_raster_tasks_.size()); | 788 state->SetInteger("completed_count", completed_raster_tasks_.size()); |
| 793 state->SetInteger("pending_count", raster_task_states_.size()); | 789 state->SetInteger("pending_count", raster_task_states_.size()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 805 | 801 |
| 806 throttle_state->SetInteger("bytes_available_for_upload", | 802 throttle_state->SetInteger("bytes_available_for_upload", |
| 807 max_bytes_pending_upload_ - bytes_pending_upload_); | 803 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 808 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 804 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 809 throttle_state->SetInteger("scheduled_raster_task_count", | 805 throttle_state->SetInteger("scheduled_raster_task_count", |
| 810 scheduled_raster_task_count_); | 806 scheduled_raster_task_count_); |
| 811 return throttle_state.PassAs<base::Value>(); | 807 return throttle_state.PassAs<base::Value>(); |
| 812 } | 808 } |
| 813 | 809 |
| 814 } // namespace cc | 810 } // namespace cc |
| OLD | NEW |