| 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 "base/debug/trace_event_argument.h" | 11 #include "base/debug/trace_event_argument.h" |
| 12 #include "base/strings/stringprintf.h" |
| 12 #include "cc/debug/traced_value.h" | 13 #include "cc/debug/traced_value.h" |
| 13 #include "cc/resources/resource.h" | 14 #include "cc/resources/resource.h" |
| 14 #include "gpu/command_buffer/client/gles2_interface.h" | 15 #include "gpu/command_buffer/client/gles2_interface.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const int kCheckForCompletedRasterTasksDelayMs = 6; | 20 const int kCheckForCompletedRasterTasksDelayMs = 6; |
| 20 | 21 |
| 21 const size_t kMaxScheduledRasterTasks = 48; | 22 const size_t kMaxScheduledRasterTasks = 48; |
| 22 | 23 |
| 23 typedef base::StackVector<RasterTask*, kMaxScheduledRasterTasks> | 24 typedef base::StackVector<RasterTask*, kMaxScheduledRasterTasks> |
| 24 RasterTaskVector; | 25 RasterTaskVector; |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 29 PixelBufferRasterWorkerPool::RasterTaskState::RasterTaskState( |
| 30 RasterTask* task, |
| 31 const TaskSetCollection& task_sets) |
| 32 : type(UNSCHEDULED), task(task), task_sets(task_sets) { |
| 33 } |
| 34 |
| 28 // static | 35 // static |
| 29 scoped_ptr<RasterWorkerPool> PixelBufferRasterWorkerPool::Create( | 36 scoped_ptr<RasterWorkerPool> PixelBufferRasterWorkerPool::Create( |
| 30 base::SequencedTaskRunner* task_runner, | 37 base::SequencedTaskRunner* task_runner, |
| 31 TaskGraphRunner* task_graph_runner, | 38 TaskGraphRunner* task_graph_runner, |
| 32 ContextProvider* context_provider, | 39 ContextProvider* context_provider, |
| 33 ResourceProvider* resource_provider, | 40 ResourceProvider* resource_provider, |
| 34 size_t max_transfer_buffer_usage_bytes) { | 41 size_t max_transfer_buffer_usage_bytes) { |
| 35 return make_scoped_ptr<RasterWorkerPool>( | 42 return make_scoped_ptr<RasterWorkerPool>( |
| 36 new PixelBufferRasterWorkerPool(task_runner, | 43 new PixelBufferRasterWorkerPool(task_runner, |
| 37 task_graph_runner, | 44 task_graph_runner, |
| 38 context_provider, | 45 context_provider, |
| 39 resource_provider, | 46 resource_provider, |
| 40 max_transfer_buffer_usage_bytes)); | 47 max_transfer_buffer_usage_bytes)); |
| 41 } | 48 } |
| 42 | 49 |
| 43 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( | 50 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( |
| 44 base::SequencedTaskRunner* task_runner, | 51 base::SequencedTaskRunner* task_runner, |
| 45 TaskGraphRunner* task_graph_runner, | 52 TaskGraphRunner* task_graph_runner, |
| 46 ContextProvider* context_provider, | 53 ContextProvider* context_provider, |
| 47 ResourceProvider* resource_provider, | 54 ResourceProvider* resource_provider, |
| 48 size_t max_transfer_buffer_usage_bytes) | 55 size_t max_transfer_buffer_usage_bytes) |
| 49 : task_runner_(task_runner), | 56 : task_runner_(task_runner), |
| 50 task_graph_runner_(task_graph_runner), | 57 task_graph_runner_(task_graph_runner), |
| 51 namespace_token_(task_graph_runner->GetNamespaceToken()), | 58 namespace_token_(task_graph_runner->GetNamespaceToken()), |
| 52 context_provider_(context_provider), | 59 context_provider_(context_provider), |
| 53 resource_provider_(resource_provider), | 60 resource_provider_(resource_provider), |
| 54 shutdown_(false), | 61 shutdown_(false), |
| 55 scheduled_raster_task_count_(0u), | 62 scheduled_raster_task_count_(0u), |
| 56 raster_tasks_required_for_activation_count_(0u), | |
| 57 bytes_pending_upload_(0u), | 63 bytes_pending_upload_(0u), |
| 58 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), | 64 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), |
| 59 has_performed_uploads_since_last_flush_(false), | 65 has_performed_uploads_since_last_flush_(false), |
| 60 should_notify_client_if_no_tasks_are_pending_(false), | |
| 61 should_notify_client_if_no_tasks_required_for_activation_are_pending_( | |
| 62 false), | |
| 63 raster_finished_task_pending_(false), | |
| 64 raster_required_for_activation_finished_task_pending_(false), | |
| 65 check_for_completed_raster_task_notifier_( | 66 check_for_completed_raster_task_notifier_( |
| 66 task_runner, | 67 task_runner, |
| 67 base::Bind(&PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks, | 68 base::Bind(&PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks, |
| 68 base::Unretained(this)), | 69 base::Unretained(this)), |
| 69 base::TimeDelta::FromMilliseconds( | 70 base::TimeDelta::FromMilliseconds( |
| 70 kCheckForCompletedRasterTasksDelayMs)), | 71 kCheckForCompletedRasterTasksDelayMs)), |
| 71 raster_finished_weak_ptr_factory_(this) { | 72 raster_finished_weak_ptr_factory_(this) { |
| 72 DCHECK(context_provider_); | 73 DCHECK(context_provider_); |
| 73 } | 74 } |
| 74 | 75 |
| 75 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { | 76 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { |
| 76 DCHECK_EQ(0u, raster_task_states_.size()); | 77 DCHECK_EQ(0u, raster_task_states_.size()); |
| 77 DCHECK_EQ(0u, raster_tasks_with_pending_upload_.size()); | 78 DCHECK_EQ(0u, raster_tasks_with_pending_upload_.size()); |
| 78 DCHECK_EQ(0u, completed_raster_tasks_.size()); | 79 DCHECK_EQ(0u, completed_raster_tasks_.size()); |
| 79 DCHECK_EQ(0u, completed_image_decode_tasks_.size()); | 80 DCHECK_EQ(0u, completed_image_decode_tasks_.size()); |
| 80 DCHECK_EQ(0u, raster_tasks_required_for_activation_count_); | 81 DCHECK(task_set_sizes_ == TaskSetSizes()); |
| 81 } | 82 } |
| 82 | 83 |
| 83 Rasterizer* PixelBufferRasterWorkerPool::AsRasterizer() { return this; } | 84 Rasterizer* PixelBufferRasterWorkerPool::AsRasterizer() { return this; } |
| 84 | 85 |
| 85 void PixelBufferRasterWorkerPool::SetClient(RasterizerClient* client) { | 86 void PixelBufferRasterWorkerPool::SetClient(RasterizerClient* client) { |
| 86 client_ = client; | 87 client_ = client; |
| 87 } | 88 } |
| 88 | 89 |
| 89 void PixelBufferRasterWorkerPool::Shutdown() { | 90 void PixelBufferRasterWorkerPool::Shutdown() { |
| 90 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::Shutdown"); | 91 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::Shutdown"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 110 completed_raster_tasks_.push_back(state.task); | 111 completed_raster_tasks_.push_back(state.task); |
| 111 state.type = RasterTaskState::COMPLETED; | 112 state.type = RasterTaskState::COMPLETED; |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 DCHECK_EQ(completed_raster_tasks_.size(), raster_task_states_.size()); | 115 DCHECK_EQ(completed_raster_tasks_.size(), raster_task_states_.size()); |
| 115 } | 116 } |
| 116 | 117 |
| 117 void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { | 118 void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { |
| 118 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks"); | 119 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks"); |
| 119 | 120 |
| 120 DCHECK_EQ(queue->required_for_activation_count, | 121 if (should_notify_client_if_no_tasks_in_set_are_pending_.none()) |
| 121 static_cast<size_t>( | |
| 122 std::count_if(queue->items.begin(), | |
| 123 queue->items.end(), | |
| 124 RasterTaskQueue::Item::IsRequiredForActivation))); | |
| 125 | |
| 126 if (!should_notify_client_if_no_tasks_are_pending_) | |
| 127 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); | 122 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); |
| 128 | 123 |
| 129 should_notify_client_if_no_tasks_are_pending_ = true; | 124 should_notify_client_if_no_tasks_in_set_are_pending_.set(); |
| 130 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; | 125 task_set_sizes_ = TaskSetSizes(); |
| 131 | |
| 132 raster_tasks_required_for_activation_count_ = 0u; | |
| 133 | 126 |
| 134 // Update raster task state and remove items from old queue. | 127 // Update raster task state and remove items from old queue. |
| 135 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); | 128 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); |
| 136 it != queue->items.end(); | 129 it != queue->items.end(); |
| 137 ++it) { | 130 ++it) { |
| 138 const RasterTaskQueue::Item& item = *it; | 131 const RasterTaskQueue::Item& item = *it; |
| 139 RasterTask* task = item.task; | 132 RasterTask* task = item.task; |
| 140 | 133 |
| 141 // Remove any old items that are associated with this task. The result is | 134 // Remove any old items that are associated with this task. The result is |
| 142 // that the old queue is left with all items not present in this queue, | 135 // that the old queue is left with all items not present in this queue, |
| 143 // which we use below to determine what tasks need to be canceled. | 136 // which we use below to determine what tasks need to be canceled. |
| 144 RasterTaskQueue::Item::Vector::iterator old_it = | 137 RasterTaskQueue::Item::Vector::iterator old_it = |
| 145 std::find_if(raster_tasks_.items.begin(), | 138 std::find_if(raster_tasks_.items.begin(), |
| 146 raster_tasks_.items.end(), | 139 raster_tasks_.items.end(), |
| 147 RasterTaskQueue::Item::TaskComparator(task)); | 140 RasterTaskQueue::Item::TaskComparator(task)); |
| 148 if (old_it != raster_tasks_.items.end()) { | 141 if (old_it != raster_tasks_.items.end()) { |
| 149 std::swap(*old_it, raster_tasks_.items.back()); | 142 std::swap(*old_it, raster_tasks_.items.back()); |
| 150 raster_tasks_.items.pop_back(); | 143 raster_tasks_.items.pop_back(); |
| 151 } | 144 } |
| 152 | 145 |
| 153 RasterTaskState::Vector::iterator state_it = | 146 RasterTaskState::Vector::iterator state_it = |
| 154 std::find_if(raster_task_states_.begin(), | 147 std::find_if(raster_task_states_.begin(), |
| 155 raster_task_states_.end(), | 148 raster_task_states_.end(), |
| 156 RasterTaskState::TaskComparator(task)); | 149 RasterTaskState::TaskComparator(task)); |
| 157 if (state_it != raster_task_states_.end()) { | 150 if (state_it != raster_task_states_.end()) { |
| 158 RasterTaskState& state = *state_it; | 151 RasterTaskState& state = *state_it; |
| 159 | 152 |
| 160 state.required_for_activation = item.required_for_activation; | 153 state.task_sets = item.task_sets; |
| 161 // |raster_tasks_required_for_activation_count| accounts for all tasks | 154 // |raster_tasks_required_for_activation_count| accounts for all tasks |
| 162 // that need to complete before we can send a "ready to activate" signal. | 155 // that need to complete before we can send a "ready to activate" signal. |
| 163 // Tasks that have already completed should not be part of this count. | 156 // Tasks that have already completed should not be part of this count. |
| 164 if (state.type != RasterTaskState::COMPLETED) { | 157 if (state.type != RasterTaskState::COMPLETED) |
| 165 raster_tasks_required_for_activation_count_ += | 158 task_set_sizes_ += item.task_sets; |
| 166 item.required_for_activation; | 159 |
| 167 } | |
| 168 continue; | 160 continue; |
| 169 } | 161 } |
| 170 | 162 |
| 171 DCHECK(!task->HasBeenScheduled()); | 163 DCHECK(!task->HasBeenScheduled()); |
| 172 raster_task_states_.push_back( | 164 raster_task_states_.push_back(RasterTaskState(task, item.task_sets)); |
| 173 RasterTaskState(task, item.required_for_activation)); | 165 task_set_sizes_ += item.task_sets; |
| 174 raster_tasks_required_for_activation_count_ += item.required_for_activation; | |
| 175 } | 166 } |
| 176 | 167 |
| 177 // Determine what tasks in old queue need to be canceled. | 168 // Determine what tasks in old queue need to be canceled. |
| 178 for (RasterTaskQueue::Item::Vector::const_iterator it = | 169 for (RasterTaskQueue::Item::Vector::const_iterator it = |
| 179 raster_tasks_.items.begin(); | 170 raster_tasks_.items.begin(); |
| 180 it != raster_tasks_.items.end(); | 171 it != raster_tasks_.items.end(); |
| 181 ++it) { | 172 ++it) { |
| 182 const RasterTaskQueue::Item& item = *it; | 173 const RasterTaskQueue::Item& item = *it; |
| 183 RasterTask* task = item.task; | 174 RasterTask* task = item.task; |
| 184 | 175 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 196 // Unscheduled task can be canceled. | 187 // Unscheduled task can be canceled. |
| 197 if (state.type == RasterTaskState::UNSCHEDULED) { | 188 if (state.type == RasterTaskState::UNSCHEDULED) { |
| 198 DCHECK(!task->HasBeenScheduled()); | 189 DCHECK(!task->HasBeenScheduled()); |
| 199 DCHECK(std::find(completed_raster_tasks_.begin(), | 190 DCHECK(std::find(completed_raster_tasks_.begin(), |
| 200 completed_raster_tasks_.end(), | 191 completed_raster_tasks_.end(), |
| 201 task) == completed_raster_tasks_.end()); | 192 task) == completed_raster_tasks_.end()); |
| 202 completed_raster_tasks_.push_back(task); | 193 completed_raster_tasks_.push_back(task); |
| 203 state.type = RasterTaskState::COMPLETED; | 194 state.type = RasterTaskState::COMPLETED; |
| 204 } | 195 } |
| 205 | 196 |
| 206 // No longer required for activation. | 197 // No longer in any task set. |
| 207 state.required_for_activation = false; | 198 state.task_sets.reset(); |
| 208 } | 199 } |
| 209 | 200 |
| 210 raster_tasks_.Swap(queue); | 201 raster_tasks_.Swap(queue); |
| 211 | 202 |
| 212 // Check for completed tasks when ScheduleTasks() is called as | 203 // Check for completed tasks when ScheduleTasks() is called as |
| 213 // priorities might have changed and this maximizes the number | 204 // priorities might have changed and this maximizes the number |
| 214 // of top priority tasks that are scheduled. | 205 // of top priority tasks that are scheduled. |
| 215 CheckForCompletedRasterizerTasks(); | 206 CheckForCompletedRasterizerTasks(); |
| 216 CheckForCompletedUploads(); | 207 CheckForCompletedUploads(); |
| 217 FlushUploads(); | 208 FlushUploads(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 262 } |
| 272 | 263 |
| 273 void PixelBufferRasterWorkerPool::ReleaseBufferForRaster(RasterTask* task) { | 264 void PixelBufferRasterWorkerPool::ReleaseBufferForRaster(RasterTask* task) { |
| 274 DCHECK(std::find_if(raster_task_states_.begin(), | 265 DCHECK(std::find_if(raster_task_states_.begin(), |
| 275 raster_task_states_.end(), | 266 raster_task_states_.end(), |
| 276 RasterTaskState::TaskComparator(task)) != | 267 RasterTaskState::TaskComparator(task)) != |
| 277 raster_task_states_.end()); | 268 raster_task_states_.end()); |
| 278 resource_provider_->ReleasePixelRasterBuffer(task->resource()->id()); | 269 resource_provider_->ReleasePixelRasterBuffer(task->resource()->id()); |
| 279 } | 270 } |
| 280 | 271 |
| 281 void PixelBufferRasterWorkerPool::OnRasterFinished() { | 272 void PixelBufferRasterWorkerPool::OnRasterTaskSetFinished(TaskSet task_set) { |
| 282 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::OnRasterFinished"); | 273 TRACE_EVENT1("cc", |
| 274 "PixelBufferRasterWorkerPool::OnRasterTaskSetFinished", |
| 275 "task_set", |
| 276 task_set); |
| 283 | 277 |
| 284 // |should_notify_client_if_no_tasks_are_pending_| can be set to false as | 278 // There's no need to call CheckForCompletedRasterTasks() if the client has |
| 285 // a result of a scheduled CheckForCompletedRasterTasks() call. No need to | 279 // already been notified. |
| 286 // perform another check in that case as we've already notified the client. | 280 if (!should_notify_client_if_no_tasks_in_set_are_pending_[task_set]) |
| 287 if (!should_notify_client_if_no_tasks_are_pending_) | |
| 288 return; | 281 return; |
| 289 raster_finished_task_pending_ = false; | 282 task_set_finished_tasks_pending_[task_set] = false; |
| 290 | |
| 291 // Call CheckForCompletedRasterTasks() when we've finished running all | |
| 292 // raster tasks needed since last time ScheduleTasks() was called. | |
| 293 // This reduces latency between the time when all tasks have finished | |
| 294 // running and the time when the client is notified. | |
| 295 CheckForCompletedRasterTasks(); | |
| 296 } | |
| 297 | |
| 298 void PixelBufferRasterWorkerPool::OnRasterRequiredForActivationFinished() { | |
| 299 TRACE_EVENT0( | |
| 300 "cc", | |
| 301 "PixelBufferRasterWorkerPool::OnRasterRequiredForActivationFinished"); | |
| 302 | |
| 303 // Analogous to OnRasterTasksFinished(), there's no need to call | |
| 304 // CheckForCompletedRasterTasks() if the client has already been notified. | |
| 305 if (!should_notify_client_if_no_tasks_required_for_activation_are_pending_) | |
| 306 return; | |
| 307 raster_required_for_activation_finished_task_pending_ = false; | |
| 308 | 283 |
| 309 // This reduces latency between the time when all tasks required for | 284 // This reduces latency between the time when all tasks required for |
| 310 // activation have finished running and the time when the client is | 285 // activation have finished running and the time when the client is |
| 311 // notified. | 286 // notified. |
| 312 CheckForCompletedRasterTasks(); | 287 CheckForCompletedRasterTasks(); |
| 313 } | 288 } |
| 314 | 289 |
| 315 void PixelBufferRasterWorkerPool::FlushUploads() { | 290 void PixelBufferRasterWorkerPool::FlushUploads() { |
| 316 if (!has_performed_uploads_since_last_flush_) | 291 if (!has_performed_uploads_since_last_flush_) |
| 317 return; | 292 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 337 | 312 |
| 338 // Uploads complete in the order they are issued. | 313 // Uploads complete in the order they are issued. |
| 339 if (!resource_provider_->DidSetPixelsComplete(task->resource()->id())) | 314 if (!resource_provider_->DidSetPixelsComplete(task->resource()->id())) |
| 340 break; | 315 break; |
| 341 | 316 |
| 342 tasks_with_completed_uploads.push_back(task); | 317 tasks_with_completed_uploads.push_back(task); |
| 343 raster_tasks_with_pending_upload_.pop_front(); | 318 raster_tasks_with_pending_upload_.pop_front(); |
| 344 } | 319 } |
| 345 | 320 |
| 346 DCHECK(client_); | 321 DCHECK(client_); |
| 322 TaskSetCollection task_sets_forced_to_complete = |
| 323 client_->TasksThatShouldBeForcedToComplete(); |
| 347 bool should_force_some_uploads_to_complete = | 324 bool should_force_some_uploads_to_complete = |
| 348 shutdown_ || client_->ShouldForceTasksRequiredForActivationToComplete(); | 325 shutdown_ || task_sets_forced_to_complete.any(); |
| 349 | 326 |
| 350 if (should_force_some_uploads_to_complete) { | 327 if (should_force_some_uploads_to_complete) { |
| 351 RasterTask::Vector tasks_with_uploads_to_force; | 328 RasterTask::Vector tasks_with_uploads_to_force; |
| 352 RasterTaskDeque::iterator it = raster_tasks_with_pending_upload_.begin(); | 329 RasterTaskDeque::iterator it = raster_tasks_with_pending_upload_.begin(); |
| 353 while (it != raster_tasks_with_pending_upload_.end()) { | 330 while (it != raster_tasks_with_pending_upload_.end()) { |
| 354 RasterTask* task = it->get(); | 331 RasterTask* task = it->get(); |
| 355 RasterTaskState::Vector::const_iterator state_it = | 332 RasterTaskState::Vector::const_iterator state_it = |
| 356 std::find_if(raster_task_states_.begin(), | 333 std::find_if(raster_task_states_.begin(), |
| 357 raster_task_states_.end(), | 334 raster_task_states_.end(), |
| 358 RasterTaskState::TaskComparator(task)); | 335 RasterTaskState::TaskComparator(task)); |
| 359 DCHECK(state_it != raster_task_states_.end()); | 336 DCHECK(state_it != raster_task_states_.end()); |
| 360 const RasterTaskState& state = *state_it; | 337 const RasterTaskState& state = *state_it; |
| 361 | 338 |
| 362 // Force all uploads required for activation to complete. | 339 // Force all uploads required for activation to complete. |
| 363 // During shutdown, force all pending uploads to complete. | 340 // During shutdown, force all pending uploads to complete. |
| 364 if (shutdown_ || state.required_for_activation) { | 341 if (shutdown_ || (state.task_sets & task_sets_forced_to_complete).any()) { |
| 365 tasks_with_uploads_to_force.push_back(task); | 342 tasks_with_uploads_to_force.push_back(task); |
| 366 tasks_with_completed_uploads.push_back(task); | 343 tasks_with_completed_uploads.push_back(task); |
| 367 it = raster_tasks_with_pending_upload_.erase(it); | 344 it = raster_tasks_with_pending_upload_.erase(it); |
| 368 continue; | 345 continue; |
| 369 } | 346 } |
| 370 | 347 |
| 371 ++it; | 348 ++it; |
| 372 } | 349 } |
| 373 | 350 |
| 374 // Force uploads in reverse order. Since forcing can cause a wait on | 351 // Force uploads in reverse order. Since forcing can cause a wait on |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // Async set pixels commands are not necessarily processed in-sequence with | 384 // Async set pixels commands are not necessarily processed in-sequence with |
| 408 // drawing commands. Read lock fences are required to ensure that async | 385 // drawing commands. Read lock fences are required to ensure that async |
| 409 // commands don't access the resource while used for drawing. | 386 // commands don't access the resource while used for drawing. |
| 410 resource_provider_->EnableReadLockFences(task->resource()->id()); | 387 resource_provider_->EnableReadLockFences(task->resource()->id()); |
| 411 | 388 |
| 412 DCHECK(std::find(completed_raster_tasks_.begin(), | 389 DCHECK(std::find(completed_raster_tasks_.begin(), |
| 413 completed_raster_tasks_.end(), | 390 completed_raster_tasks_.end(), |
| 414 task) == completed_raster_tasks_.end()); | 391 task) == completed_raster_tasks_.end()); |
| 415 completed_raster_tasks_.push_back(task); | 392 completed_raster_tasks_.push_back(task); |
| 416 state.type = RasterTaskState::COMPLETED; | 393 state.type = RasterTaskState::COMPLETED; |
| 417 DCHECK_LE(static_cast<size_t>(state.required_for_activation), | 394 // Triggers if the current task belongs to a set that should be empty. |
| 418 raster_tasks_required_for_activation_count_); | 395 DCHECK((state.task_sets & ~task_set_sizes_.ToTaskSetCollection()).none()); |
| 419 raster_tasks_required_for_activation_count_ -= | 396 task_set_sizes_ -= state.task_sets; |
| 420 state.required_for_activation; | |
| 421 } | 397 } |
| 422 } | 398 } |
| 423 | 399 |
| 424 void PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks() { | 400 void PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks() { |
| 425 TRACE_EVENT0("cc", | 401 TRACE_EVENT0("cc", |
| 426 "PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks"); | 402 "PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks"); |
| 427 | 403 |
| 428 // Since this function can be called directly, cancel any pending checks. | 404 // Since this function can be called directly, cancel any pending checks. |
| 429 check_for_completed_raster_task_notifier_.Cancel(); | 405 check_for_completed_raster_task_notifier_.Cancel(); |
| 430 | 406 |
| 431 DCHECK(should_notify_client_if_no_tasks_are_pending_); | 407 DCHECK(should_notify_client_if_no_tasks_in_set_are_pending_.any()); |
| 432 | 408 |
| 433 CheckForCompletedRasterizerTasks(); | 409 CheckForCompletedRasterizerTasks(); |
| 434 CheckForCompletedUploads(); | 410 CheckForCompletedUploads(); |
| 435 FlushUploads(); | 411 FlushUploads(); |
| 436 | 412 |
| 437 // Determine what client notifications to generate. | 413 // Determine what client notifications to generate. |
| 438 bool will_notify_client_that_no_tasks_required_for_activation_are_pending = | 414 TaskSetCollection will_notify_client_that_no_tasks_in_set_are_pending = |
| 439 (should_notify_client_if_no_tasks_required_for_activation_are_pending_ && | 415 should_notify_client_if_no_tasks_in_set_are_pending_ & |
| 440 !raster_required_for_activation_finished_task_pending_ && | 416 ~task_set_finished_tasks_pending_ & ~HasPendingTasksInSets(); |
| 441 !HasPendingTasksRequiredForActivation()); | |
| 442 bool will_notify_client_that_no_tasks_are_pending = | |
| 443 (should_notify_client_if_no_tasks_are_pending_ && | |
| 444 !raster_required_for_activation_finished_task_pending_ && | |
| 445 !raster_finished_task_pending_ && !HasPendingTasks()); | |
| 446 | 417 |
| 447 // Adjust the need to generate notifications before scheduling more tasks. | 418 // Adjust the need to generate notifications before scheduling more tasks. |
| 448 should_notify_client_if_no_tasks_required_for_activation_are_pending_ &= | 419 should_notify_client_if_no_tasks_in_set_are_pending_ &= |
| 449 !will_notify_client_that_no_tasks_required_for_activation_are_pending; | 420 ~will_notify_client_that_no_tasks_in_set_are_pending; |
| 450 should_notify_client_if_no_tasks_are_pending_ &= | |
| 451 !will_notify_client_that_no_tasks_are_pending; | |
| 452 | 421 |
| 453 scheduled_raster_task_count_ = 0; | 422 scheduled_raster_task_count_ = 0; |
| 454 if (PendingRasterTaskCount()) | 423 if (PendingRasterTaskCount()) |
| 455 ScheduleMoreTasks(); | 424 ScheduleMoreTasks(); |
| 456 | 425 |
| 457 TRACE_EVENT_ASYNC_STEP_INTO1( | 426 TRACE_EVENT_ASYNC_STEP_INTO1( |
| 458 "cc", "ScheduledTasks", this, StateName(), "state", StateAsValue()); | 427 "cc", "ScheduledTasks", this, StateName(), "state", StateAsValue()); |
| 459 | 428 |
| 460 // Schedule another check for completed raster tasks while there are | 429 // Schedule another check for completed raster tasks while there are |
| 461 // pending raster tasks or pending uploads. | 430 // pending raster tasks or pending uploads. |
| 462 if (HasPendingTasks()) | 431 if (HasPendingTasksInSets().any()) |
| 463 check_for_completed_raster_task_notifier_.Schedule(); | 432 check_for_completed_raster_task_notifier_.Schedule(); |
| 464 | 433 |
| 434 if (should_notify_client_if_no_tasks_in_set_are_pending_.none()) |
| 435 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); |
| 436 |
| 465 // Generate client notifications. | 437 // Generate client notifications. |
| 466 if (will_notify_client_that_no_tasks_required_for_activation_are_pending) { | 438 for (TaskSet task_set = 0; task_set < kNumberOfTaskSets; task_set++) { |
| 467 DCHECK(!HasPendingTasksRequiredForActivation()); | 439 if (will_notify_client_that_no_tasks_in_set_are_pending[task_set]) { |
| 468 client_->DidFinishRunningTasksRequiredForActivation(); | 440 DCHECK(!HasPendingTasksInSets()[task_set]); |
| 469 } | 441 client_->DidFinishRunningTaskSet(task_set); |
| 470 if (will_notify_client_that_no_tasks_are_pending) { | 442 } |
| 471 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); | |
| 472 DCHECK(!HasPendingTasksRequiredForActivation()); | |
| 473 client_->DidFinishRunningTasks(); | |
| 474 } | 443 } |
| 475 } | 444 } |
| 476 | 445 |
| 477 void PixelBufferRasterWorkerPool::ScheduleMoreTasks() { | 446 void PixelBufferRasterWorkerPool::ScheduleMoreTasks() { |
| 478 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleMoreTasks"); | 447 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleMoreTasks"); |
| 479 | 448 |
| 480 RasterTaskVector tasks; | 449 RasterTaskVector tasks; |
| 481 RasterTaskVector tasks_required_for_activation; | 450 RasterTaskVector tasks_in_set[kNumberOfTaskSets]; |
| 482 | 451 |
| 483 unsigned priority = kRasterTaskPriorityBase; | 452 unsigned priority = kRasterTaskPriorityBase; |
| 484 | 453 |
| 485 graph_.Reset(); | 454 graph_.Reset(); |
| 486 | 455 |
| 487 size_t bytes_pending_upload = bytes_pending_upload_; | 456 size_t bytes_pending_upload = bytes_pending_upload_; |
| 488 bool did_throttle_raster_tasks = false; | 457 TaskSetCollection did_throttle_raster_tasks_in_set; |
| 489 bool did_throttle_raster_tasks_required_for_activation = false; | |
| 490 | 458 |
| 491 for (RasterTaskQueue::Item::Vector::const_iterator it = | 459 for (RasterTaskQueue::Item::Vector::const_iterator it = |
| 492 raster_tasks_.items.begin(); | 460 raster_tasks_.items.begin(); |
| 493 it != raster_tasks_.items.end(); | 461 it != raster_tasks_.items.end(); |
| 494 ++it) { | 462 ++it) { |
| 495 const RasterTaskQueue::Item& item = *it; | 463 const RasterTaskQueue::Item& item = *it; |
| 496 RasterTask* task = item.task; | 464 RasterTask* task = item.task; |
| 497 | 465 |
| 498 // |raster_task_states_| contains the state of all tasks that we have not | 466 // |raster_task_states_| contains the state of all tasks that we have not |
| 499 // yet run reply callbacks for. | 467 // yet run reply callbacks for. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 514 continue; | 482 continue; |
| 515 } | 483 } |
| 516 | 484 |
| 517 // All raster tasks need to be throttled by bytes of pending uploads, | 485 // All raster tasks need to be throttled by bytes of pending uploads, |
| 518 // but if it's the only task allow it to complete no matter what its size, | 486 // but if it's the only task allow it to complete no matter what its size, |
| 519 // to prevent starvation of the task queue. | 487 // to prevent starvation of the task queue. |
| 520 size_t new_bytes_pending_upload = bytes_pending_upload; | 488 size_t new_bytes_pending_upload = bytes_pending_upload; |
| 521 new_bytes_pending_upload += task->resource()->bytes(); | 489 new_bytes_pending_upload += task->resource()->bytes(); |
| 522 if (new_bytes_pending_upload > max_bytes_pending_upload_ && | 490 if (new_bytes_pending_upload > max_bytes_pending_upload_ && |
| 523 bytes_pending_upload) { | 491 bytes_pending_upload) { |
| 524 did_throttle_raster_tasks = true; | 492 did_throttle_raster_tasks_in_set |= item.task_sets; |
| 525 if (item.required_for_activation) | |
| 526 did_throttle_raster_tasks_required_for_activation = true; | |
| 527 continue; | 493 continue; |
| 528 } | 494 } |
| 529 | 495 |
| 530 // If raster has finished, just update |bytes_pending_upload|. | 496 // If raster has finished, just update |bytes_pending_upload|. |
| 531 if (state.type == RasterTaskState::UPLOADING) { | 497 if (state.type == RasterTaskState::UPLOADING) { |
| 532 DCHECK(!task->HasCompleted()); | 498 DCHECK(!task->HasCompleted()); |
| 533 bytes_pending_upload = new_bytes_pending_upload; | 499 bytes_pending_upload = new_bytes_pending_upload; |
| 534 continue; | 500 continue; |
| 535 } | 501 } |
| 536 | 502 |
| 537 // Throttle raster tasks based on kMaxScheduledRasterTasks. | 503 // Throttle raster tasks based on kMaxScheduledRasterTasks. |
| 538 if (tasks.container().size() >= kMaxScheduledRasterTasks) { | 504 if (tasks.container().size() >= kMaxScheduledRasterTasks) { |
| 539 did_throttle_raster_tasks = true; | 505 did_throttle_raster_tasks_in_set |= item.task_sets; |
| 540 if (item.required_for_activation) | |
| 541 did_throttle_raster_tasks_required_for_activation = true; | |
| 542 continue; | 506 continue; |
| 543 } | 507 } |
| 544 | 508 |
| 545 // Update |bytes_pending_upload| now that task has cleared all | 509 // Update |bytes_pending_upload| now that task has cleared all |
| 546 // throttling limits. | 510 // throttling limits. |
| 547 bytes_pending_upload = new_bytes_pending_upload; | 511 bytes_pending_upload = new_bytes_pending_upload; |
| 548 | 512 |
| 549 DCHECK(state.type == RasterTaskState::UNSCHEDULED || | 513 DCHECK(state.type == RasterTaskState::UNSCHEDULED || |
| 550 state.type == RasterTaskState::SCHEDULED); | 514 state.type == RasterTaskState::SCHEDULED); |
| 551 state.type = RasterTaskState::SCHEDULED; | 515 state.type = RasterTaskState::SCHEDULED; |
| 552 | 516 |
| 553 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); | 517 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); |
| 554 | 518 |
| 555 tasks.container().push_back(task); | 519 tasks.container().push_back(task); |
| 556 if (item.required_for_activation) | 520 for (TaskSet task_set = 0; task_set < kNumberOfTaskSets; task_set++) { |
| 557 tasks_required_for_activation.container().push_back(task); | 521 if (item.task_sets[task_set]) |
| 522 tasks_in_set[task_set].container().push_back(task); |
| 523 } |
| 558 } | 524 } |
| 559 | 525 |
| 560 // Cancel existing OnRasterFinished callbacks. | 526 // Cancel existing OnRasterFinished callbacks. |
| 561 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 527 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 562 | 528 |
| 563 scoped_refptr<RasterizerTask> | 529 scoped_refptr<RasterizerTask> new_task_set_finished_tasks[kNumberOfTaskSets]; |
| 564 new_raster_required_for_activation_finished_task; | 530 TaskSetSizes scheduled_task_set_sizes; |
| 565 | 531 |
| 566 size_t scheduled_raster_task_required_for_activation_count = | 532 for (TaskSet task_set = 0; task_set < kNumberOfTaskSets; task_set++) { |
| 567 tasks_required_for_activation.container().size(); | 533 scheduled_task_set_sizes[task_set] = |
| 568 DCHECK_LE(scheduled_raster_task_required_for_activation_count, | 534 tasks_in_set[task_set].container().size(); |
| 569 raster_tasks_required_for_activation_count_); | 535 DCHECK_LE(scheduled_task_set_sizes[task_set], task_set_sizes_[task_set]); |
| 570 // Schedule OnRasterTasksRequiredForActivationFinished call only when | 536 // Schedule OnRasterTasksRequiredForActivationFinished call only when |
| 571 // notification is pending and throttling is not preventing all pending | 537 // notification is pending and throttling is not preventing all pending |
| 572 // tasks required for activation from being scheduled. | 538 // tasks required for activation from being scheduled. |
| 573 if (!did_throttle_raster_tasks_required_for_activation && | 539 if (!did_throttle_raster_tasks_in_set[task_set] && |
| 574 should_notify_client_if_no_tasks_required_for_activation_are_pending_) { | 540 should_notify_client_if_no_tasks_in_set_are_pending_[task_set]) { |
| 575 new_raster_required_for_activation_finished_task = | 541 base::debug::TraceEventSyntheticDelay* synthetic_delay = NULL; |
| 576 CreateRasterRequiredForActivationFinishedTask( | 542 if (scheduled_task_set_sizes[task_set] > 0) |
| 577 raster_tasks_.required_for_activation_count, | 543 synthetic_delay = client_->SyntheticDelayForTaskSet(task_set); |
| 578 task_runner_.get(), | 544 new_task_set_finished_tasks[task_set] = CreateRasterFinishedTask( |
| 579 base::Bind(&PixelBufferRasterWorkerPool:: | 545 task_runner_.get(), |
| 580 OnRasterRequiredForActivationFinished, | 546 base::Bind(&PixelBufferRasterWorkerPool::OnRasterTaskSetFinished, |
| 581 raster_finished_weak_ptr_factory_.GetWeakPtr())); | 547 raster_finished_weak_ptr_factory_.GetWeakPtr(), |
| 582 raster_required_for_activation_finished_task_pending_ = true; | 548 task_set), |
| 583 InsertNodeForTask(&graph_, | 549 synthetic_delay); |
| 584 new_raster_required_for_activation_finished_task.get(), | 550 task_set_finished_tasks_pending_[task_set] = true; |
| 585 kRasterRequiredForActivationFinishedTaskPriority, | 551 InsertNodeForTask(&graph_, |
| 586 scheduled_raster_task_required_for_activation_count); | 552 new_task_set_finished_tasks[task_set].get(), |
| 587 for (RasterTaskVector::ContainerType::const_iterator it = | 553 kRasterTaskSetFinishedTaskPriority, |
| 588 tasks_required_for_activation.container().begin(); | 554 scheduled_task_set_sizes[task_set]); |
| 589 it != tasks_required_for_activation.container().end(); | 555 for (RasterTaskVector::ContainerType::const_iterator it = |
| 590 ++it) { | 556 tasks_in_set[task_set].container().begin(); |
| 591 graph_.edges.push_back(TaskGraph::Edge( | 557 it != tasks_in_set[task_set].container().end(); |
| 592 *it, new_raster_required_for_activation_finished_task.get())); | 558 ++it) { |
| 559 graph_.edges.push_back( |
| 560 TaskGraph::Edge(*it, new_task_set_finished_tasks[task_set].get())); |
| 561 } |
| 593 } | 562 } |
| 594 } | 563 } |
| 595 | 564 |
| 596 scoped_refptr<RasterizerTask> new_raster_finished_task; | |
| 597 | |
| 598 size_t scheduled_raster_task_count = tasks.container().size(); | 565 size_t scheduled_raster_task_count = tasks.container().size(); |
| 599 DCHECK_LE(scheduled_raster_task_count, PendingRasterTaskCount()); | 566 DCHECK_LE(scheduled_raster_task_count, PendingRasterTaskCount()); |
| 600 // Schedule OnRasterTasksFinished call only when notification is pending | |
| 601 // and throttling is not preventing all pending tasks from being scheduled. | |
| 602 if (!did_throttle_raster_tasks && | |
| 603 should_notify_client_if_no_tasks_are_pending_) { | |
| 604 new_raster_finished_task = CreateRasterFinishedTask( | |
| 605 task_runner_.get(), | |
| 606 base::Bind(&PixelBufferRasterWorkerPool::OnRasterFinished, | |
| 607 raster_finished_weak_ptr_factory_.GetWeakPtr())); | |
| 608 raster_finished_task_pending_ = true; | |
| 609 InsertNodeForTask(&graph_, | |
| 610 new_raster_finished_task.get(), | |
| 611 kRasterFinishedTaskPriority, | |
| 612 scheduled_raster_task_count); | |
| 613 for (RasterTaskVector::ContainerType::const_iterator it = | |
| 614 tasks.container().begin(); | |
| 615 it != tasks.container().end(); | |
| 616 ++it) { | |
| 617 graph_.edges.push_back( | |
| 618 TaskGraph::Edge(*it, new_raster_finished_task.get())); | |
| 619 } | |
| 620 } | |
| 621 | 567 |
| 622 ScheduleTasksOnOriginThread(this, &graph_); | 568 ScheduleTasksOnOriginThread(this, &graph_); |
| 623 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); | 569 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); |
| 624 | 570 |
| 625 scheduled_raster_task_count_ = scheduled_raster_task_count; | 571 scheduled_raster_task_count_ = scheduled_raster_task_count; |
| 626 | 572 |
| 627 raster_finished_task_ = new_raster_finished_task; | 573 for (TaskSet task_set = 0; task_set < kNumberOfTaskSets; task_set++) |
| 628 raster_required_for_activation_finished_task_ = | 574 task_set_finished_tasks_[task_set] = new_task_set_finished_tasks[task_set]; |
| 629 new_raster_required_for_activation_finished_task; | |
| 630 } | 575 } |
| 631 | 576 |
| 632 unsigned PixelBufferRasterWorkerPool::PendingRasterTaskCount() const { | 577 unsigned PixelBufferRasterWorkerPool::PendingRasterTaskCount() const { |
| 633 unsigned num_completed_raster_tasks = | 578 unsigned num_completed_raster_tasks = |
| 634 raster_tasks_with_pending_upload_.size() + completed_raster_tasks_.size(); | 579 raster_tasks_with_pending_upload_.size() + completed_raster_tasks_.size(); |
| 635 DCHECK_GE(raster_task_states_.size(), num_completed_raster_tasks); | 580 DCHECK_GE(raster_task_states_.size(), num_completed_raster_tasks); |
| 636 return raster_task_states_.size() - num_completed_raster_tasks; | 581 return raster_task_states_.size() - num_completed_raster_tasks; |
| 637 } | 582 } |
| 638 | 583 |
| 639 bool PixelBufferRasterWorkerPool::HasPendingTasks() const { | 584 TaskSetCollection PixelBufferRasterWorkerPool::HasPendingTasksInSets() const { |
| 640 return PendingRasterTaskCount() || !raster_tasks_with_pending_upload_.empty(); | 585 return task_set_sizes_.ToTaskSetCollection(); |
| 641 } | |
| 642 | |
| 643 bool PixelBufferRasterWorkerPool::HasPendingTasksRequiredForActivation() const { | |
| 644 return !!raster_tasks_required_for_activation_count_; | |
| 645 } | 586 } |
| 646 | 587 |
| 647 const char* PixelBufferRasterWorkerPool::StateName() const { | 588 const char* PixelBufferRasterWorkerPool::StateName() const { |
| 648 if (scheduled_raster_task_count_) | 589 if (scheduled_raster_task_count_) |
| 649 return "rasterizing"; | 590 return "rasterizing"; |
| 650 if (PendingRasterTaskCount()) | 591 if (PendingRasterTaskCount()) |
| 651 return "throttled"; | 592 return "throttled"; |
| 652 if (!raster_tasks_with_pending_upload_.empty()) | 593 if (!raster_tasks_with_pending_upload_.empty()) |
| 653 return "waiting_for_uploads"; | 594 return "waiting_for_uploads"; |
| 654 | 595 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 if (item_it != raster_tasks_.items.end()) { | 641 if (item_it != raster_tasks_.items.end()) { |
| 701 state.type = RasterTaskState::UNSCHEDULED; | 642 state.type = RasterTaskState::UNSCHEDULED; |
| 702 continue; | 643 continue; |
| 703 } | 644 } |
| 704 | 645 |
| 705 DCHECK(std::find(completed_raster_tasks_.begin(), | 646 DCHECK(std::find(completed_raster_tasks_.begin(), |
| 706 completed_raster_tasks_.end(), | 647 completed_raster_tasks_.end(), |
| 707 raster_task) == completed_raster_tasks_.end()); | 648 raster_task) == completed_raster_tasks_.end()); |
| 708 completed_raster_tasks_.push_back(raster_task); | 649 completed_raster_tasks_.push_back(raster_task); |
| 709 state.type = RasterTaskState::COMPLETED; | 650 state.type = RasterTaskState::COMPLETED; |
| 710 DCHECK_LE(static_cast<size_t>(state.required_for_activation), | 651 // Triggers if the current task belongs to a set that should be empty. |
| 711 raster_tasks_required_for_activation_count_); | 652 DCHECK((state.task_sets & ~task_set_sizes_.ToTaskSetCollection()).none()); |
| 712 raster_tasks_required_for_activation_count_ -= | 653 task_set_sizes_ -= state.task_sets; |
| 713 state.required_for_activation; | |
| 714 continue; | 654 continue; |
| 715 } | 655 } |
| 716 | 656 |
| 717 resource_provider_->BeginSetPixels(raster_task->resource()->id()); | 657 resource_provider_->BeginSetPixels(raster_task->resource()->id()); |
| 718 has_performed_uploads_since_last_flush_ = true; | 658 has_performed_uploads_since_last_flush_ = true; |
| 719 | 659 |
| 720 bytes_pending_upload_ += raster_task->resource()->bytes(); | 660 bytes_pending_upload_ += raster_task->resource()->bytes(); |
| 721 raster_tasks_with_pending_upload_.push_back(raster_task); | 661 raster_tasks_with_pending_upload_.push_back(raster_task); |
| 722 state.type = RasterTaskState::UPLOADING; | 662 state.type = RasterTaskState::UPLOADING; |
| 723 } | 663 } |
| 724 completed_tasks_.clear(); | 664 completed_tasks_.clear(); |
| 725 } | 665 } |
| 726 | 666 |
| 727 scoped_refptr<base::debug::ConvertableToTraceFormat> | 667 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 728 PixelBufferRasterWorkerPool::StateAsValue() const { | 668 PixelBufferRasterWorkerPool::StateAsValue() const { |
| 729 scoped_refptr<base::debug::TracedValue> state = | 669 scoped_refptr<base::debug::TracedValue> state = |
| 730 new base::debug::TracedValue(); | 670 new base::debug::TracedValue(); |
| 731 state->SetInteger("completed_count", completed_raster_tasks_.size()); | 671 state->SetInteger("completed_count", completed_raster_tasks_.size()); |
| 732 state->SetInteger("pending_count", raster_task_states_.size()); | 672 state->SetInteger("pending_count", raster_task_states_.size()); |
| 733 state->SetInteger("pending_upload_count", | 673 state->SetInteger("pending_upload_count", |
| 734 raster_tasks_with_pending_upload_.size()); | 674 raster_tasks_with_pending_upload_.size()); |
| 735 state->SetInteger("pending_required_for_activation_count", | 675 for (TaskSet task_set = 0; task_set < kNumberOfTaskSets; task_set++) { |
| 736 raster_tasks_required_for_activation_count_); | 676 state->SetInteger( |
| 677 base::StringPrintf("pending_task_in_set_%u", |
| 678 static_cast<unsigned>(task_set)).c_str(), |
| 679 task_set_sizes_[task_set]); |
| 680 } |
| 737 state->BeginDictionary("throttle_state"); | 681 state->BeginDictionary("throttle_state"); |
| 738 ThrottleStateAsValueInto(state.get()); | 682 ThrottleStateAsValueInto(state.get()); |
| 739 state->EndDictionary(); | 683 state->EndDictionary(); |
| 740 return state; | 684 return state; |
| 741 } | 685 } |
| 742 | 686 |
| 743 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( | 687 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( |
| 744 base::debug::TracedValue* throttle_state) const { | 688 base::debug::TracedValue* throttle_state) const { |
| 745 throttle_state->SetInteger("bytes_available_for_upload", | 689 throttle_state->SetInteger("bytes_available_for_upload", |
| 746 max_bytes_pending_upload_ - bytes_pending_upload_); | 690 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 747 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 691 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 748 throttle_state->SetInteger("scheduled_raster_task_count", | 692 throttle_state->SetInteger("scheduled_raster_task_count", |
| 749 scheduled_raster_task_count_); | 693 scheduled_raster_task_count_); |
| 750 } | 694 } |
| 751 | 695 |
| 752 } // namespace cc | 696 } // namespace cc |
| OLD | NEW |