OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/image_copy_raster_worker_pool.h" | 5 #include "cc/resources/image_copy_raster_worker_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 TRACE_EVENT0("cc", "ImageCopyRasterWorkerPool::Shutdown"); | 63 TRACE_EVENT0("cc", "ImageCopyRasterWorkerPool::Shutdown"); |
64 | 64 |
65 TaskGraph empty; | 65 TaskGraph empty; |
66 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 66 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
67 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | 67 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
68 } | 68 } |
69 | 69 |
70 void ImageCopyRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { | 70 void ImageCopyRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { |
71 TRACE_EVENT0("cc", "ImageCopyRasterWorkerPool::ScheduleTasks"); | 71 TRACE_EVENT0("cc", "ImageCopyRasterWorkerPool::ScheduleTasks"); |
72 | 72 |
73 DCHECK_EQ(queue->required_for_activation_count, | |
74 static_cast<size_t>( | |
75 std::count_if(queue->items.begin(), | |
76 queue->items.end(), | |
77 RasterTaskQueue::Item::IsRequiredForActivation))); | |
78 | |
79 if (!raster_tasks_pending_) | 73 if (!raster_tasks_pending_) |
80 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); | 74 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); |
81 | 75 |
82 raster_tasks_pending_ = true; | 76 raster_tasks_pending_ = true; |
83 raster_tasks_required_for_activation_pending_ = true; | 77 raster_tasks_required_for_activation_pending_ = true; |
84 | 78 |
85 unsigned priority = kRasterTaskPriorityBase; | 79 unsigned priority = kRasterTaskPriorityBase; |
86 | 80 |
87 graph_.Reset(); | 81 graph_.Reset(); |
88 | 82 |
89 // Cancel existing OnRasterFinished callbacks. | 83 // Cancel existing OnRasterFinished callbacks. |
90 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 84 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
91 | 85 |
92 scoped_refptr<RasterizerTask> | 86 scoped_refptr<RasterizerTask> |
93 new_raster_required_for_activation_finished_task( | 87 new_raster_required_for_activation_finished_task(CreateRasterFinishedTask( |
94 CreateRasterRequiredForActivationFinishedTask( | 88 task_runner_.get(), |
95 queue->required_for_activation_count, | 89 base::Bind( |
96 task_runner_.get(), | 90 &ImageCopyRasterWorkerPool::OnRasterRequiredForActivationFinished, |
97 base::Bind(&ImageCopyRasterWorkerPool:: | 91 raster_finished_weak_ptr_factory_.GetWeakPtr()))); |
98 OnRasterRequiredForActivationFinished, | |
99 raster_finished_weak_ptr_factory_.GetWeakPtr()))); | |
100 scoped_refptr<RasterizerTask> new_raster_finished_task( | 92 scoped_refptr<RasterizerTask> new_raster_finished_task( |
101 CreateRasterFinishedTask( | 93 CreateRasterFinishedTask( |
102 task_runner_.get(), | 94 task_runner_.get(), |
103 base::Bind(&ImageCopyRasterWorkerPool::OnRasterFinished, | 95 base::Bind(&ImageCopyRasterWorkerPool::OnRasterFinished, |
104 raster_finished_weak_ptr_factory_.GetWeakPtr()))); | 96 raster_finished_weak_ptr_factory_.GetWeakPtr()))); |
105 | 97 |
106 resource_pool_->CheckBusyResources(); | 98 resource_pool_->CheckBusyResources(); |
107 | 99 |
| 100 size_t required_for_activation_count = 0; |
| 101 |
108 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); | 102 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); |
109 it != queue->items.end(); | 103 it != queue->items.end(); |
110 ++it) { | 104 ++it) { |
111 const RasterTaskQueue::Item& item = *it; | 105 const RasterTaskQueue::Item& item = *it; |
112 RasterTask* task = item.task; | 106 RasterTask* task = item.task; |
113 DCHECK(!task->HasCompleted()); | 107 DCHECK(!task->HasCompleted()); |
114 | 108 |
115 if (item.required_for_activation) { | 109 if (item.required_for_activation) { |
| 110 ++required_for_activation_count; |
116 graph_.edges.push_back(TaskGraph::Edge( | 111 graph_.edges.push_back(TaskGraph::Edge( |
117 task, new_raster_required_for_activation_finished_task.get())); | 112 task, new_raster_required_for_activation_finished_task.get())); |
118 } | 113 } |
119 | 114 |
120 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); | 115 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); |
121 | 116 |
122 graph_.edges.push_back( | 117 graph_.edges.push_back( |
123 TaskGraph::Edge(task, new_raster_finished_task.get())); | 118 TaskGraph::Edge(task, new_raster_finished_task.get())); |
124 } | 119 } |
125 | 120 |
126 InsertNodeForTask(&graph_, | 121 InsertNodeForTask(&graph_, |
127 new_raster_required_for_activation_finished_task.get(), | 122 new_raster_required_for_activation_finished_task.get(), |
128 kRasterRequiredForActivationFinishedTaskPriority, | 123 kRasterRequiredForActivationFinishedTaskPriority, |
129 queue->required_for_activation_count); | 124 required_for_activation_count); |
130 InsertNodeForTask(&graph_, | 125 InsertNodeForTask(&graph_, |
131 new_raster_finished_task.get(), | 126 new_raster_finished_task.get(), |
132 kRasterFinishedTaskPriority, | 127 kRasterFinishedTaskPriority, |
133 queue->items.size()); | 128 queue->items.size()); |
134 | 129 |
135 ScheduleTasksOnOriginThread(this, &graph_); | 130 ScheduleTasksOnOriginThread(this, &graph_); |
136 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); | 131 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); |
137 | 132 |
138 raster_finished_task_ = new_raster_finished_task; | 133 raster_finished_task_ = new_raster_finished_task; |
139 raster_required_for_activation_finished_task_ = | 134 raster_required_for_activation_finished_task_ = |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 resource_pool_->total_memory_usage_bytes()); | 250 resource_pool_->total_memory_usage_bytes()); |
256 staging_state->SetInteger("pending_copy_count", | 251 staging_state->SetInteger("pending_copy_count", |
257 resource_pool_->total_resource_count() - | 252 resource_pool_->total_resource_count() - |
258 resource_pool_->acquired_resource_count()); | 253 resource_pool_->acquired_resource_count()); |
259 staging_state->SetInteger("bytes_pending_copy", | 254 staging_state->SetInteger("bytes_pending_copy", |
260 resource_pool_->total_memory_usage_bytes() - | 255 resource_pool_->total_memory_usage_bytes() - |
261 resource_pool_->acquired_memory_usage_bytes()); | 256 resource_pool_->acquired_memory_usage_bytes()); |
262 } | 257 } |
263 | 258 |
264 } // namespace cc | 259 } // namespace cc |
OLD | NEW |