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