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 "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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 new_raster_task_states[task] = state; | 126 new_raster_task_states[task] = state; |
127 // |raster_tasks_required_for_activation_| contains all tasks that need to | 127 // |raster_tasks_required_for_activation_| contains all tasks that need to |
128 // complete before we can send a "ready to activate" signal. Tasks that | 128 // complete before we can send a "ready to activate" signal. Tasks that |
129 // have already completed should not be part of this set. | 129 // have already completed should not be part of this set. |
130 if (state != COMPLETED && IsRasterTaskRequiredForActivation(task)) | 130 if (state != COMPLETED && IsRasterTaskRequiredForActivation(task)) |
131 raster_tasks_required_for_activation_.insert(task); | 131 raster_tasks_required_for_activation_.insert(task); |
132 | 132 |
133 raster_task_states_.erase(state_it); | 133 raster_task_states_.erase(state_it); |
134 } else { | 134 } else { |
| 135 DCHECK(!task->HasBeenScheduled()); |
135 new_raster_task_states[task] = UNSCHEDULED; | 136 new_raster_task_states[task] = UNSCHEDULED; |
136 if (IsRasterTaskRequiredForActivation(task)) | 137 if (IsRasterTaskRequiredForActivation(task)) |
137 raster_tasks_required_for_activation_.insert(task); | 138 raster_tasks_required_for_activation_.insert(task); |
138 } | 139 } |
139 } | 140 } |
140 | 141 |
141 // Transfer old raster task state to |new_raster_task_states| and cancel all | 142 // Transfer old raster task state to |new_raster_task_states| and cancel all |
142 // remaining unscheduled tasks. | 143 // remaining unscheduled tasks. |
143 for (RasterTaskStateMap::iterator it = raster_task_states_.begin(); | 144 for (RasterTaskStateMap::iterator it = raster_task_states_.begin(); |
144 it != raster_task_states_.end(); | 145 it != raster_task_states_.end(); |
145 ++it) { | 146 ++it) { |
146 internal::RasterWorkerPoolTask* task = it->first; | 147 internal::RasterWorkerPoolTask* task = it->first; |
147 DCHECK(new_raster_task_states.find(task) == new_raster_task_states.end()); | 148 DCHECK(new_raster_task_states.find(task) == new_raster_task_states.end()); |
148 DCHECK(!IsRasterTaskRequiredForActivation(task)); | 149 DCHECK(!IsRasterTaskRequiredForActivation(task)); |
149 | 150 |
150 // Unscheduled task can be canceled. | 151 // Unscheduled task can be canceled. |
151 if (it->second == UNSCHEDULED) { | 152 if (it->second == UNSCHEDULED) { |
| 153 DCHECK(!task->HasBeenScheduled()); |
152 DCHECK(std::find(completed_raster_tasks_.begin(), | 154 DCHECK(std::find(completed_raster_tasks_.begin(), |
153 completed_raster_tasks_.end(), | 155 completed_raster_tasks_.end(), |
154 task) == completed_raster_tasks_.end()); | 156 task) == completed_raster_tasks_.end()); |
155 completed_raster_tasks_.push_back(task); | 157 completed_raster_tasks_.push_back(task); |
156 new_raster_task_states[task] = COMPLETED; | 158 new_raster_task_states[task] = COMPLETED; |
157 continue; | 159 continue; |
158 } | 160 } |
159 | 161 |
160 // Move state to |new_raster_task_states|. | 162 // Move state to |new_raster_task_states|. |
161 new_raster_task_states[task] = it->second; | 163 new_raster_task_states[task] = it->second; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 // All raster tasks need to be throttled by bytes of pending uploads. | 520 // All raster tasks need to be throttled by bytes of pending uploads. |
519 size_t new_bytes_pending_upload = bytes_pending_upload; | 521 size_t new_bytes_pending_upload = bytes_pending_upload; |
520 new_bytes_pending_upload += task->resource()->bytes(); | 522 new_bytes_pending_upload += task->resource()->bytes(); |
521 if (new_bytes_pending_upload > max_bytes_pending_upload_) { | 523 if (new_bytes_pending_upload > max_bytes_pending_upload_) { |
522 did_throttle_raster_tasks = true; | 524 did_throttle_raster_tasks = true; |
523 break; | 525 break; |
524 } | 526 } |
525 | 527 |
526 // If raster has finished, just update |bytes_pending_upload|. | 528 // If raster has finished, just update |bytes_pending_upload|. |
527 if (state_it->second == UPLOADING) { | 529 if (state_it->second == UPLOADING) { |
| 530 DCHECK(task->HasCompleted()); |
528 bytes_pending_upload = new_bytes_pending_upload; | 531 bytes_pending_upload = new_bytes_pending_upload; |
529 continue; | 532 continue; |
530 } | 533 } |
531 | 534 |
532 // Throttle raster tasks based on kMaxScheduledRasterTasks. | 535 // Throttle raster tasks based on kMaxScheduledRasterTasks. |
533 size_t scheduled_raster_task_count = | 536 size_t scheduled_raster_task_count = |
534 tasks[PREPAINT_TYPE].container().size() + | 537 tasks[PREPAINT_TYPE].container().size() + |
535 tasks[REQUIRED_FOR_ACTIVATION_TYPE].container().size(); | 538 tasks[REQUIRED_FOR_ACTIVATION_TYPE].container().size(); |
536 if (scheduled_raster_task_count >= kMaxScheduledRasterTasks) { | 539 if (scheduled_raster_task_count >= kMaxScheduledRasterTasks) { |
537 did_throttle_raster_tasks = true; | 540 did_throttle_raster_tasks = true; |
538 break; | 541 break; |
539 } | 542 } |
540 | 543 |
541 // Update |bytes_pending_upload| now that task has cleared all | 544 // Update |bytes_pending_upload| now that task has cleared all |
542 // throttling limits. | 545 // throttling limits. |
543 bytes_pending_upload = new_bytes_pending_upload; | 546 bytes_pending_upload = new_bytes_pending_upload; |
544 | 547 |
545 RasterTaskType type = IsRasterTaskRequiredForActivation(task) | 548 RasterTaskType type = IsRasterTaskRequiredForActivation(task) |
546 ? REQUIRED_FOR_ACTIVATION_TYPE | 549 ? REQUIRED_FOR_ACTIVATION_TYPE |
547 : PREPAINT_TYPE; | 550 : PREPAINT_TYPE; |
548 | 551 |
549 task->ScheduleOnOriginThread(this); | |
550 DCHECK(state_it->second == UNSCHEDULED || state_it->second == SCHEDULED); | 552 DCHECK(state_it->second == UNSCHEDULED || state_it->second == SCHEDULED); |
551 state_it->second = SCHEDULED; | 553 state_it->second = SCHEDULED; |
552 | 554 |
553 tasks[type].container().push_back(CreateGraphNodeForRasterTask( | 555 tasks[type].container().push_back(CreateGraphNodeForRasterTask( |
554 task, task->dependencies(), priority++, &graph)); | 556 task, task->dependencies(), priority++, &graph)); |
555 } | 557 } |
556 | 558 |
557 scoped_refptr<internal::WorkerPoolTask> | 559 scoped_refptr<internal::WorkerPoolTask> |
558 new_raster_required_for_activation_finished_task; | 560 new_raster_required_for_activation_finished_task; |
559 | 561 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 | 674 |
673 throttle_state->SetInteger("bytes_available_for_upload", | 675 throttle_state->SetInteger("bytes_available_for_upload", |
674 max_bytes_pending_upload_ - bytes_pending_upload_); | 676 max_bytes_pending_upload_ - bytes_pending_upload_); |
675 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 677 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
676 throttle_state->SetInteger("scheduled_raster_task_count", | 678 throttle_state->SetInteger("scheduled_raster_task_count", |
677 scheduled_raster_task_count_); | 679 scheduled_raster_task_count_); |
678 return throttle_state.PassAs<base::Value>(); | 680 return throttle_state.PassAs<base::Value>(); |
679 } | 681 } |
680 | 682 |
681 } // namespace cc | 683 } // namespace cc |
OLD | NEW |