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/values.h" | 8 #include "base/values.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 16 matching lines...) Expand all Loading... |
27 TRACE_EVENT0("cc", "ImageRasterWorkerPool::ScheduleTasks"); | 27 TRACE_EVENT0("cc", "ImageRasterWorkerPool::ScheduleTasks"); |
28 | 28 |
29 RasterWorkerPool::SetRasterTasks(queue); | 29 RasterWorkerPool::SetRasterTasks(queue); |
30 | 30 |
31 if (!raster_tasks_pending_) | 31 if (!raster_tasks_pending_) |
32 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); | 32 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); |
33 | 33 |
34 raster_tasks_pending_ = true; | 34 raster_tasks_pending_ = true; |
35 raster_tasks_required_for_activation_pending_ = true; | 35 raster_tasks_required_for_activation_pending_ = true; |
36 | 36 |
37 unsigned priority = 0u; | 37 unsigned priority = kRasterTaskPriorityBase; |
38 TaskGraph graph; | 38 internal::TaskGraph graph; |
39 | 39 |
40 scoped_refptr<internal::WorkerPoolTask> | 40 scoped_refptr<internal::WorkerPoolTask> |
41 new_raster_required_for_activation_finished_task( | 41 new_raster_required_for_activation_finished_task( |
42 CreateRasterRequiredForActivationFinishedTask( | 42 CreateRasterRequiredForActivationFinishedTask( |
43 raster_tasks_required_for_activation().size())); | 43 raster_tasks_required_for_activation().size())); |
44 internal::GraphNode* raster_required_for_activation_finished_node = | |
45 CreateGraphNodeForTask( | |
46 new_raster_required_for_activation_finished_task.get(), | |
47 priority++, | |
48 &graph); | |
49 | |
50 scoped_refptr<internal::WorkerPoolTask> new_raster_finished_task( | 44 scoped_refptr<internal::WorkerPoolTask> new_raster_finished_task( |
51 CreateRasterFinishedTask()); | 45 CreateRasterFinishedTask()); |
52 internal::GraphNode* raster_finished_node = CreateGraphNodeForTask( | 46 |
53 new_raster_finished_task.get(), priority++, &graph); | 47 size_t raster_required_for_activation_finished_dependency_count = 0u; |
| 48 size_t raster_finished_dependency_count = 0u; |
54 | 49 |
55 RasterTaskVector gpu_raster_tasks; | 50 RasterTaskVector gpu_raster_tasks; |
56 | 51 |
57 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); | 52 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); |
58 it != raster_tasks().end(); | 53 it != raster_tasks().end(); |
59 ++it) { | 54 ++it) { |
60 internal::RasterWorkerPoolTask* task = it->get(); | 55 internal::RasterWorkerPoolTask* task = it->get(); |
61 DCHECK(!task->HasCompleted()); | 56 DCHECK(!task->HasCompleted()); |
62 | 57 |
63 if (task->use_gpu_rasterization()) { | 58 if (task->use_gpu_rasterization()) { |
64 gpu_raster_tasks.push_back(task); | 59 gpu_raster_tasks.push_back(task); |
65 continue; | 60 continue; |
66 } | 61 } |
67 | 62 |
68 CreateGraphNodeForImageRasterTask( | 63 if (IsRasterTaskRequiredForActivation(task)) { |
69 task, | 64 ++raster_required_for_activation_finished_dependency_count; |
70 task->dependencies(), | 65 graph.edges.push_back(internal::TaskGraph::Edge( |
71 priority++, | 66 task, new_raster_required_for_activation_finished_task.get())); |
72 IsRasterTaskRequiredForActivation(task), | 67 } |
73 raster_required_for_activation_finished_node, | 68 |
74 raster_finished_node, | 69 InsertNodeForRasterTask(&graph, task, task->dependencies(), priority++); |
75 &graph); | 70 |
| 71 ++raster_finished_dependency_count; |
| 72 graph.edges.push_back( |
| 73 internal::TaskGraph::Edge(task, new_raster_finished_task.get())); |
76 } | 74 } |
77 | 75 |
| 76 InsertNodeForTask(&graph, |
| 77 new_raster_required_for_activation_finished_task.get(), |
| 78 kRasterRequiredForActivationFinishedTaskPriority, |
| 79 raster_required_for_activation_finished_dependency_count); |
| 80 InsertNodeForTask(&graph, |
| 81 new_raster_finished_task.get(), |
| 82 kRasterFinishedTaskPriority, |
| 83 raster_finished_dependency_count); |
| 84 |
78 SetTaskGraph(&graph); | 85 SetTaskGraph(&graph); |
79 | 86 |
80 set_raster_finished_task(new_raster_finished_task); | 87 set_raster_finished_task(new_raster_finished_task); |
81 set_raster_required_for_activation_finished_task( | 88 set_raster_required_for_activation_finished_task( |
82 new_raster_required_for_activation_finished_task); | 89 new_raster_required_for_activation_finished_task); |
83 | 90 |
84 RunGpuRasterTasks(gpu_raster_tasks); | 91 RunGpuRasterTasks(gpu_raster_tasks); |
85 | 92 |
86 TRACE_EVENT_ASYNC_STEP_INTO1( | 93 TRACE_EVENT_ASYNC_STEP_INTO1( |
87 "cc", | 94 "cc", |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 170 |
164 scoped_ptr<base::Value> ImageRasterWorkerPool::StateAsValue() const { | 171 scoped_ptr<base::Value> ImageRasterWorkerPool::StateAsValue() const { |
165 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); | 172 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); |
166 | 173 |
167 state->SetBoolean("tasks_required_for_activation_pending", | 174 state->SetBoolean("tasks_required_for_activation_pending", |
168 raster_tasks_required_for_activation_pending_); | 175 raster_tasks_required_for_activation_pending_); |
169 state->Set("scheduled_state", ScheduledStateAsValue().release()); | 176 state->Set("scheduled_state", ScheduledStateAsValue().release()); |
170 return state.PassAs<base::Value>(); | 177 return state.PassAs<base::Value>(); |
171 } | 178 } |
172 | 179 |
173 // static | |
174 void ImageRasterWorkerPool::CreateGraphNodeForImageRasterTask( | |
175 internal::WorkerPoolTask* image_task, | |
176 const internal::Task::Vector& decode_tasks, | |
177 unsigned priority, | |
178 bool is_required_for_activation, | |
179 internal::GraphNode* raster_required_for_activation_finished_node, | |
180 internal::GraphNode* raster_finished_node, | |
181 TaskGraph* graph) { | |
182 internal::GraphNode* image_node = | |
183 CreateGraphNodeForRasterTask(image_task, decode_tasks, priority, graph); | |
184 | |
185 if (is_required_for_activation) { | |
186 raster_required_for_activation_finished_node->add_dependency(); | |
187 image_node->add_dependent(raster_required_for_activation_finished_node); | |
188 } | |
189 | |
190 raster_finished_node->add_dependency(); | |
191 image_node->add_dependent(raster_finished_node); | |
192 } | |
193 | |
194 } // namespace cc | 180 } // namespace cc |
OLD | NEW |