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" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 completed_raster_tasks_.push_back(state.task); | 110 completed_raster_tasks_.push_back(state.task); |
111 state.type = RasterTaskState::COMPLETED; | 111 state.type = RasterTaskState::COMPLETED; |
112 } | 112 } |
113 } | 113 } |
114 DCHECK_EQ(completed_raster_tasks_.size(), raster_task_states_.size()); | 114 DCHECK_EQ(completed_raster_tasks_.size(), raster_task_states_.size()); |
115 } | 115 } |
116 | 116 |
117 void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { | 117 void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { |
118 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks"); | 118 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::ScheduleTasks"); |
119 | 119 |
120 DCHECK_EQ(queue->required_for_activation_count, | |
121 static_cast<size_t>( | |
122 std::count_if(queue->items.begin(), | |
123 queue->items.end(), | |
124 RasterTaskQueue::Item::IsRequiredForActivation))); | |
125 | |
126 if (!should_notify_client_if_no_tasks_are_pending_) | 120 if (!should_notify_client_if_no_tasks_are_pending_) |
127 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); | 121 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); |
128 | 122 |
129 should_notify_client_if_no_tasks_are_pending_ = true; | 123 should_notify_client_if_no_tasks_are_pending_ = true; |
130 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; | 124 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; |
131 | 125 |
132 raster_tasks_required_for_activation_count_ = 0u; | 126 raster_tasks_required_for_activation_count_ = 0u; |
133 | 127 |
134 // Update raster task state and remove items from old queue. | 128 // Update raster task state and remove items from old queue. |
135 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); | 129 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 559 |
566 size_t scheduled_raster_task_required_for_activation_count = | 560 size_t scheduled_raster_task_required_for_activation_count = |
567 tasks_required_for_activation.container().size(); | 561 tasks_required_for_activation.container().size(); |
568 DCHECK_LE(scheduled_raster_task_required_for_activation_count, | 562 DCHECK_LE(scheduled_raster_task_required_for_activation_count, |
569 raster_tasks_required_for_activation_count_); | 563 raster_tasks_required_for_activation_count_); |
570 // Schedule OnRasterTasksRequiredForActivationFinished call only when | 564 // Schedule OnRasterTasksRequiredForActivationFinished call only when |
571 // notification is pending and throttling is not preventing all pending | 565 // notification is pending and throttling is not preventing all pending |
572 // tasks required for activation from being scheduled. | 566 // tasks required for activation from being scheduled. |
573 if (!did_throttle_raster_tasks_required_for_activation && | 567 if (!did_throttle_raster_tasks_required_for_activation && |
574 should_notify_client_if_no_tasks_required_for_activation_are_pending_) { | 568 should_notify_client_if_no_tasks_required_for_activation_are_pending_) { |
575 new_raster_required_for_activation_finished_task = | 569 new_raster_required_for_activation_finished_task = CreateRasterFinishedTask( |
576 CreateRasterRequiredForActivationFinishedTask( | 570 task_runner_.get(), |
577 raster_tasks_.required_for_activation_count, | 571 base::Bind( |
578 task_runner_.get(), | 572 &PixelBufferRasterWorkerPool::OnRasterRequiredForActivationFinished, |
579 base::Bind(&PixelBufferRasterWorkerPool:: | 573 raster_finished_weak_ptr_factory_.GetWeakPtr())); |
580 OnRasterRequiredForActivationFinished, | |
581 raster_finished_weak_ptr_factory_.GetWeakPtr())); | |
582 raster_required_for_activation_finished_task_pending_ = true; | 574 raster_required_for_activation_finished_task_pending_ = true; |
583 InsertNodeForTask(&graph_, | 575 InsertNodeForTask(&graph_, |
584 new_raster_required_for_activation_finished_task.get(), | 576 new_raster_required_for_activation_finished_task.get(), |
585 kRasterRequiredForActivationFinishedTaskPriority, | 577 kRasterRequiredForActivationFinishedTaskPriority, |
586 scheduled_raster_task_required_for_activation_count); | 578 scheduled_raster_task_required_for_activation_count); |
587 for (RasterTaskVector::ContainerType::const_iterator it = | 579 for (RasterTaskVector::ContainerType::const_iterator it = |
588 tasks_required_for_activation.container().begin(); | 580 tasks_required_for_activation.container().begin(); |
589 it != tasks_required_for_activation.container().end(); | 581 it != tasks_required_for_activation.container().end(); |
590 ++it) { | 582 ++it) { |
591 graph_.edges.push_back(TaskGraph::Edge( | 583 graph_.edges.push_back(TaskGraph::Edge( |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( | 735 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( |
744 base::debug::TracedValue* throttle_state) const { | 736 base::debug::TracedValue* throttle_state) const { |
745 throttle_state->SetInteger("bytes_available_for_upload", | 737 throttle_state->SetInteger("bytes_available_for_upload", |
746 max_bytes_pending_upload_ - bytes_pending_upload_); | 738 max_bytes_pending_upload_ - bytes_pending_upload_); |
747 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 739 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
748 throttle_state->SetInteger("scheduled_raster_task_count", | 740 throttle_state->SetInteger("scheduled_raster_task_count", |
749 scheduled_raster_task_count_); | 741 scheduled_raster_task_count_); |
750 } | 742 } |
751 | 743 |
752 } // namespace cc | 744 } // namespace cc |
OLD | NEW |