Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: cc/resources/pixel_buffer_raster_worker_pool.cc

Issue 168083002: cc: Remove RasterWorkerPool::Task. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove RasterTaskQueueIterator Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.h ('k') | cc/resources/raster_worker_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/pixel_buffer_raster_worker_pool.h" 5 #include "cc/resources/pixel_buffer_raster_worker_pool.h"
6 6
7 #include "base/containers/stack_container.h" 7 #include "base/containers/stack_container.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/debug/traced_value.h" 10 #include "cc/debug/traced_value.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 // All unscheduled tasks need to be canceled. 82 // All unscheduled tasks need to be canceled.
83 if (it->second == UNSCHEDULED) { 83 if (it->second == UNSCHEDULED) {
84 completed_raster_tasks_.push_back(task); 84 completed_raster_tasks_.push_back(task);
85 it->second = COMPLETED; 85 it->second = COMPLETED;
86 } 86 }
87 } 87 }
88 DCHECK_EQ(completed_raster_tasks_.size(), raster_task_states_.size()); 88 DCHECK_EQ(completed_raster_tasks_.size(), raster_task_states_.size());
89 } 89 }
90 90
91 void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTask::Queue* queue) { 91 void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) {
92 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks"); 92 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks");
93 93
94 DCHECK_EQ(queue->required_for_activation_count,
95 static_cast<size_t>(
96 std::count_if(queue->items.begin(),
97 queue->items.end(),
98 RasterTaskQueue::Item::IsRequiredForActivation)));
99
94 if (!should_notify_client_if_no_tasks_are_pending_) 100 if (!should_notify_client_if_no_tasks_are_pending_)
95 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); 101 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this);
96 102
97 should_notify_client_if_no_tasks_are_pending_ = true; 103 should_notify_client_if_no_tasks_are_pending_ = true;
98 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; 104 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true;
99 105
100 raster_tasks_required_for_activation_.clear(); 106 raster_tasks_required_for_activation_.clear();
101 107
102 // Build new raster task state map. 108 // Build new raster task state map.
103 RasterTaskStateMap new_raster_task_states; 109 RasterTaskStateMap new_raster_task_states;
104 for (RasterTaskQueueIterator it(queue); it; ++it) { 110 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin();
105 internal::RasterWorkerPoolTask* task = *it; 111 it != queue->items.end();
112 ++it) {
113 const RasterTaskQueue::Item& item = *it;
114 internal::RasterWorkerPoolTask* task = item.task;
106 DCHECK(new_raster_task_states.find(task) == new_raster_task_states.end()); 115 DCHECK(new_raster_task_states.find(task) == new_raster_task_states.end());
107 116
108 RasterTaskStateMap::iterator state_it = raster_task_states_.find(task); 117 RasterTaskStateMap::iterator state_it = raster_task_states_.find(task);
109 if (state_it != raster_task_states_.end()) { 118 if (state_it != raster_task_states_.end()) {
110 RasterTaskState state = state_it->second; 119 RasterTaskState state = state_it->second;
111 120
112 new_raster_task_states[task] = state; 121 new_raster_task_states[task] = state;
113 // |raster_tasks_required_for_activation_| contains all tasks that need to 122 // |raster_tasks_required_for_activation_| contains all tasks that need to
114 // complete before we can send a "ready to activate" signal. Tasks that 123 // complete before we can send a "ready to activate" signal. Tasks that
115 // have already completed should not be part of this set. 124 // have already completed should not be part of this set.
116 if (state != COMPLETED && it.required_for_activation()) 125 if (state != COMPLETED && item.required_for_activation)
117 raster_tasks_required_for_activation_.insert(task); 126 raster_tasks_required_for_activation_.insert(task);
118 127
119 raster_task_states_.erase(state_it); 128 raster_task_states_.erase(state_it);
120 } else { 129 } else {
121 DCHECK(!task->HasBeenScheduled()); 130 DCHECK(!task->HasBeenScheduled());
122 new_raster_task_states[task] = UNSCHEDULED; 131 new_raster_task_states[task] = UNSCHEDULED;
123 if (it.required_for_activation()) 132 if (item.required_for_activation)
124 raster_tasks_required_for_activation_.insert(task); 133 raster_tasks_required_for_activation_.insert(task);
125 } 134 }
126 } 135 }
127 136
128 // Transfer old raster task state to |new_raster_task_states| and cancel all 137 // Transfer old raster task state to |new_raster_task_states| and cancel all
129 // remaining unscheduled tasks. 138 // remaining unscheduled tasks.
130 for (RasterTaskStateMap::iterator it = raster_task_states_.begin(); 139 for (RasterTaskStateMap::iterator it = raster_task_states_.begin();
131 it != raster_task_states_.end(); 140 it != raster_task_states_.end();
132 ++it) { 141 ++it) {
133 internal::RasterWorkerPoolTask* task = it->first; 142 internal::RasterWorkerPoolTask* task = it->first;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster(). 244 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster().
236 resource_provider()->UnmapPixelRasterBuffer(task->resource()->id()); 245 resource_provider()->UnmapPixelRasterBuffer(task->resource()->id());
237 246
238 if (!task->HasFinishedRunning() || analysis.is_solid_color) { 247 if (!task->HasFinishedRunning() || analysis.is_solid_color) {
239 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id()); 248 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id());
240 249
241 if (!task->HasFinishedRunning()) { 250 if (!task->HasFinishedRunning()) {
242 // When priorites change, a raster task can be canceled as a result of 251 // When priorites change, a raster task can be canceled as a result of
243 // no longer being of high enough priority to fit in our throttled 252 // no longer being of high enough priority to fit in our throttled
244 // raster task budget. The task has not yet completed in this case. 253 // raster task budget. The task has not yet completed in this case.
245 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { 254 for (RasterTaskQueue::Item::Vector::const_iterator it =
246 if (*it == task) { 255 raster_tasks_.items.begin();
256 it != raster_tasks_.items.end();
257 ++it) {
258 if (it->task == task) {
247 raster_task_states_[task] = UNSCHEDULED; 259 raster_task_states_[task] = UNSCHEDULED;
248 return; 260 return;
249 } 261 }
250 } 262 }
251 } 263 }
252 264
253 DCHECK(std::find(completed_raster_tasks_.begin(), 265 DCHECK(std::find(completed_raster_tasks_.begin(),
254 completed_raster_tasks_.end(), 266 completed_raster_tasks_.end(),
255 task) == completed_raster_tasks_.end()); 267 task) == completed_raster_tasks_.end());
256 completed_raster_tasks_.push_back(task); 268 completed_raster_tasks_.push_back(task);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 WorkerPoolTaskVector tasks; 503 WorkerPoolTaskVector tasks;
492 WorkerPoolTaskVector tasks_required_for_activation; 504 WorkerPoolTaskVector tasks_required_for_activation;
493 505
494 unsigned priority = kRasterTaskPriorityBase; 506 unsigned priority = kRasterTaskPriorityBase;
495 507
496 graph_.Reset(); 508 graph_.Reset();
497 509
498 size_t bytes_pending_upload = bytes_pending_upload_; 510 size_t bytes_pending_upload = bytes_pending_upload_;
499 bool did_throttle_raster_tasks = false; 511 bool did_throttle_raster_tasks = false;
500 512
501 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { 513 for (RasterTaskQueue::Item::Vector::const_iterator it =
502 internal::RasterWorkerPoolTask* task = *it; 514 raster_tasks_.items.begin();
515 it != raster_tasks_.items.end();
516 ++it) {
517 const RasterTaskQueue::Item& item = *it;
518 internal::RasterWorkerPoolTask* task = item.task;
503 519
504 // |raster_task_states_| contains the state of all tasks that we have not 520 // |raster_task_states_| contains the state of all tasks that we have not
505 // yet run reply callbacks for. 521 // yet run reply callbacks for.
506 RasterTaskStateMap::iterator state_it = raster_task_states_.find(task); 522 RasterTaskStateMap::iterator state_it = raster_task_states_.find(task);
507 if (state_it == raster_task_states_.end()) 523 if (state_it == raster_task_states_.end())
508 continue; 524 continue;
509 525
510 // Skip task if completed. 526 // Skip task if completed.
511 if (state_it->second == COMPLETED) { 527 if (state_it->second == COMPLETED) {
512 DCHECK(std::find(completed_raster_tasks_.begin(), 528 DCHECK(std::find(completed_raster_tasks_.begin(),
(...skipping 26 matching lines...) Expand all
539 // Update |bytes_pending_upload| now that task has cleared all 555 // Update |bytes_pending_upload| now that task has cleared all
540 // throttling limits. 556 // throttling limits.
541 bytes_pending_upload = new_bytes_pending_upload; 557 bytes_pending_upload = new_bytes_pending_upload;
542 558
543 DCHECK(state_it->second == UNSCHEDULED || state_it->second == SCHEDULED); 559 DCHECK(state_it->second == UNSCHEDULED || state_it->second == SCHEDULED);
544 state_it->second = SCHEDULED; 560 state_it->second = SCHEDULED;
545 561
546 InsertNodeForRasterTask(&graph_, task, task->dependencies(), priority++); 562 InsertNodeForRasterTask(&graph_, task, task->dependencies(), priority++);
547 563
548 tasks.container().push_back(task); 564 tasks.container().push_back(task);
549 if (it.required_for_activation()) 565 if (item.required_for_activation)
550 tasks_required_for_activation.container().push_back(task); 566 tasks_required_for_activation.container().push_back(task);
551 } 567 }
552 568
553 scoped_refptr<internal::WorkerPoolTask> 569 scoped_refptr<internal::WorkerPoolTask>
554 new_raster_required_for_activation_finished_task; 570 new_raster_required_for_activation_finished_task;
555 571
556 size_t scheduled_raster_task_required_for_activation_count = 572 size_t scheduled_raster_task_required_for_activation_count =
557 tasks_required_for_activation.container().size(); 573 tasks_required_for_activation.container().size();
558 DCHECK_LE(scheduled_raster_task_required_for_activation_count, 574 DCHECK_LE(scheduled_raster_task_required_for_activation_count,
559 raster_tasks_required_for_activation_.size()); 575 raster_tasks_required_for_activation_.size());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 694
679 throttle_state->SetInteger("bytes_available_for_upload", 695 throttle_state->SetInteger("bytes_available_for_upload",
680 max_bytes_pending_upload_ - bytes_pending_upload_); 696 max_bytes_pending_upload_ - bytes_pending_upload_);
681 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 697 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
682 throttle_state->SetInteger("scheduled_raster_task_count", 698 throttle_state->SetInteger("scheduled_raster_task_count",
683 scheduled_raster_task_count_); 699 scheduled_raster_task_count_);
684 return throttle_state.PassAs<base::Value>(); 700 return throttle_state.PassAs<base::Value>();
685 } 701 }
686 702
687 } // namespace cc 703 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.h ('k') | cc/resources/raster_worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698