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