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/image_raster_worker_pool.h" | 5 #include "cc/resources/image_raster_worker_pool.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "cc/debug/traced_value.h" | 9 #include "cc/debug/traced_value.h" |
10 #include "cc/resources/resource.h" | 10 #include "cc/resources/resource.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 TRACE_EVENT0("cc", "ImageRasterWorkerPool::Shutdown"); | 44 TRACE_EVENT0("cc", "ImageRasterWorkerPool::Shutdown"); |
45 | 45 |
46 TaskGraph empty; | 46 TaskGraph empty; |
47 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 47 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
48 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | 48 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
49 } | 49 } |
50 | 50 |
51 void ImageRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { | 51 void ImageRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { |
52 TRACE_EVENT0("cc", "ImageRasterWorkerPool::ScheduleTasks"); | 52 TRACE_EVENT0("cc", "ImageRasterWorkerPool::ScheduleTasks"); |
53 | 53 |
54 DCHECK_EQ(queue->required_for_activation_count, | |
55 static_cast<size_t>( | |
56 std::count_if(queue->items.begin(), | |
57 queue->items.end(), | |
58 RasterTaskQueue::Item::IsRequiredForActivation))); | |
59 | |
60 if (!raster_tasks_pending_) | 54 if (!raster_tasks_pending_) |
61 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); | 55 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); |
62 | 56 |
63 raster_tasks_pending_ = true; | 57 raster_tasks_pending_ = true; |
64 raster_tasks_required_for_activation_pending_ = true; | 58 raster_tasks_required_for_activation_pending_ = true; |
65 | 59 |
66 unsigned priority = kRasterTaskPriorityBase; | 60 unsigned priority = kRasterTaskPriorityBase; |
67 | 61 |
68 graph_.Reset(); | 62 graph_.Reset(); |
69 | 63 |
70 // Cancel existing OnRasterFinished callbacks. | 64 // Cancel existing OnRasterFinished callbacks. |
71 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 65 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
72 | 66 |
73 scoped_refptr<RasterizerTask> | 67 scoped_refptr<RasterizerTask> |
74 new_raster_required_for_activation_finished_task( | 68 new_raster_required_for_activation_finished_task(CreateRasterFinishedTask( |
75 CreateRasterRequiredForActivationFinishedTask( | 69 task_runner_.get(), |
76 queue->required_for_activation_count, | 70 base::Bind( |
77 task_runner_.get(), | 71 &ImageRasterWorkerPool::OnRasterRequiredForActivationFinished, |
78 base::Bind( | 72 raster_finished_weak_ptr_factory_.GetWeakPtr()))); |
79 &ImageRasterWorkerPool::OnRasterRequiredForActivationFinished, | |
80 raster_finished_weak_ptr_factory_.GetWeakPtr()))); | |
81 scoped_refptr<RasterizerTask> new_raster_finished_task( | 73 scoped_refptr<RasterizerTask> new_raster_finished_task( |
82 CreateRasterFinishedTask( | 74 CreateRasterFinishedTask( |
83 task_runner_.get(), | 75 task_runner_.get(), |
84 base::Bind(&ImageRasterWorkerPool::OnRasterFinished, | 76 base::Bind(&ImageRasterWorkerPool::OnRasterFinished, |
85 raster_finished_weak_ptr_factory_.GetWeakPtr()))); | 77 raster_finished_weak_ptr_factory_.GetWeakPtr()))); |
86 | 78 |
79 size_t required_for_activation_count = 0; | |
80 | |
87 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); | 81 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); |
88 it != queue->items.end(); | 82 it != queue->items.end(); |
89 ++it) { | 83 ++it) { |
90 const RasterTaskQueue::Item& item = *it; | 84 const RasterTaskQueue::Item& item = *it; |
91 RasterTask* task = item.task; | 85 RasterTask* task = item.task; |
92 DCHECK(!task->HasCompleted()); | 86 DCHECK(!task->HasCompleted()); |
93 | 87 |
94 if (item.required_for_activation) { | 88 if (item.required_for_activation) { |
89 required_for_activation_count++; | |
reveman
2014/09/12 20:06:34
nit: ++required_for_activation_count
ernstm
2014/09/12 20:20:38
Done.
| |
95 graph_.edges.push_back(TaskGraph::Edge( | 90 graph_.edges.push_back(TaskGraph::Edge( |
96 task, new_raster_required_for_activation_finished_task.get())); | 91 task, new_raster_required_for_activation_finished_task.get())); |
97 } | 92 } |
98 | 93 |
99 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); | 94 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++); |
100 | 95 |
101 graph_.edges.push_back( | 96 graph_.edges.push_back( |
102 TaskGraph::Edge(task, new_raster_finished_task.get())); | 97 TaskGraph::Edge(task, new_raster_finished_task.get())); |
103 } | 98 } |
104 | 99 |
105 InsertNodeForTask(&graph_, | 100 InsertNodeForTask(&graph_, |
106 new_raster_required_for_activation_finished_task.get(), | 101 new_raster_required_for_activation_finished_task.get(), |
107 kRasterRequiredForActivationFinishedTaskPriority, | 102 kRasterRequiredForActivationFinishedTaskPriority, |
108 queue->required_for_activation_count); | 103 required_for_activation_count); |
109 InsertNodeForTask(&graph_, | 104 InsertNodeForTask(&graph_, |
110 new_raster_finished_task.get(), | 105 new_raster_finished_task.get(), |
111 kRasterFinishedTaskPriority, | 106 kRasterFinishedTaskPriority, |
112 queue->items.size()); | 107 queue->items.size()); |
113 | 108 |
114 ScheduleTasksOnOriginThread(this, &graph_); | 109 ScheduleTasksOnOriginThread(this, &graph_); |
115 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); | 110 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); |
116 | 111 |
117 raster_finished_task_ = new_raster_finished_task; | 112 raster_finished_task_ = new_raster_finished_task; |
118 raster_required_for_activation_finished_task_ = | 113 raster_required_for_activation_finished_task_ = |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 ImageRasterWorkerPool::StateAsValue() const { | 173 ImageRasterWorkerPool::StateAsValue() const { |
179 scoped_refptr<base::debug::TracedValue> state = | 174 scoped_refptr<base::debug::TracedValue> state = |
180 new base::debug::TracedValue(); | 175 new base::debug::TracedValue(); |
181 | 176 |
182 state->SetBoolean("tasks_required_for_activation_pending", | 177 state->SetBoolean("tasks_required_for_activation_pending", |
183 raster_tasks_required_for_activation_pending_); | 178 raster_tasks_required_for_activation_pending_); |
184 return state; | 179 return state; |
185 } | 180 } |
186 | 181 |
187 } // namespace cc | 182 } // namespace cc |
OLD | NEW |