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/raster_worker_pool.h" | 5 #include "cc/resources/raster_worker_pool.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "cc/base/scoped_ptr_deque.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace cc { | 11 namespace cc { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 static const int kTimeLimitMillis = 2000; | 15 static const int kTimeLimitMillis = 2000; |
15 static const int kWarmupRuns = 5; | 16 static const int kWarmupRuns = 5; |
16 static const int kTimeCheckInterval = 10; | 17 static const int kTimeCheckInterval = 10; |
17 | 18 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 | 50 |
50 scoped_refptr<internal::WorkerPoolTask> new_perf_task( | 51 scoped_refptr<internal::WorkerPoolTask> new_perf_task( |
51 new PerfWorkerPoolTaskImpl); | 52 new PerfWorkerPoolTaskImpl); |
52 perf_tasks[task] = new_perf_task; | 53 perf_tasks[task] = new_perf_task; |
53 } | 54 } |
54 | 55 |
55 perf_tasks_.swap(perf_tasks); | 56 perf_tasks_.swap(perf_tasks); |
56 } | 57 } |
57 | 58 |
58 void BuildTaskGraph() { | 59 void BuildTaskGraph() { |
59 RasterTaskGraph graph; | 60 enum RasterTaskType { |
vmpstr
2013/06/27 23:31:21
This enum is in quite a few places, I think it's w
reveman
2013/06/28 17:26:07
Only used by pixel buffer RWP in latest patch.
| |
61 PREPAINT_TYPE = 0, | |
62 REQUIRED_FOR_ACTIVATION_TYPE = 1, | |
63 NUM_TYPES = 2 | |
64 }; | |
65 ScopedPtrDeque<GraphNode> tasks[NUM_TYPES]; | |
66 unsigned priority = 0; | |
67 TaskGraph graph; | |
60 | 68 |
61 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); | 69 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); |
62 it != raster_tasks().end(); ++it) { | 70 it != raster_tasks().end(); ++it) { |
63 internal::RasterWorkerPoolTask* task = it->get(); | 71 internal::RasterWorkerPoolTask* task = it->get(); |
64 | 72 |
73 RasterTaskType type = IsRasterTaskRequiredForActivation(task) ? | |
74 REQUIRED_FOR_ACTIVATION_TYPE : | |
75 PREPAINT_TYPE; | |
76 | |
65 TaskMap::iterator perf_it = perf_tasks_.find(task); | 77 TaskMap::iterator perf_it = perf_tasks_.find(task); |
66 DCHECK(perf_it != perf_tasks_.end()); | 78 DCHECK(perf_it != perf_tasks_.end()); |
67 if (perf_it != perf_tasks_.end()) { | 79 if (perf_it != perf_tasks_.end()) { |
68 internal::WorkerPoolTask* perf_task = perf_it->second.get(); | 80 internal::WorkerPoolTask* perf_task = perf_it->second.get(); |
69 graph.InsertRasterTask(perf_task, task->dependencies()); | 81 |
82 tasks[type].push_back( | |
83 CreateRasterTaskGraphNode(perf_task, | |
84 task->dependencies(), | |
85 priority++, | |
86 &graph)); | |
87 } | |
88 } | |
89 | |
90 scoped_refptr<internal::WorkerPoolTask> | |
91 raster_finished_task(new PerfWorkerPoolTaskImpl); | |
92 scoped_ptr<GraphNode> raster_finished_node( | |
93 new GraphNode(raster_finished_task.get(), 0u)); | |
94 for (unsigned i = 0; i < NUM_TYPES; ++i) { | |
95 for (unsigned j = 0; j < tasks[i].size(); ++j) { | |
96 raster_finished_node->add_dependency(); | |
97 tasks[i][j]->add_dependent(raster_finished_node.get()); | |
98 } | |
99 } | |
100 graph.set(raster_finished_task.get(), raster_finished_node.Pass()); | |
101 | |
102 scoped_refptr<internal::WorkerPoolTask> | |
103 raster_required_for_activation_finished_task( | |
104 new PerfWorkerPoolTaskImpl); | |
105 scoped_ptr<GraphNode> raster_required_for_activation_finished_node( | |
106 new GraphNode(raster_required_for_activation_finished_task.get(), 0u)); | |
107 for (unsigned j = 0; | |
108 j < tasks[REQUIRED_FOR_ACTIVATION_TYPE].size(); | |
109 ++j) { | |
110 raster_required_for_activation_finished_node->add_dependency(); | |
111 tasks[REQUIRED_FOR_ACTIVATION_TYPE][j]->add_dependent( | |
112 raster_required_for_activation_finished_node.get()); | |
113 } | |
114 graph.set(raster_required_for_activation_finished_task.get(), | |
115 raster_required_for_activation_finished_node.Pass()); | |
116 | |
117 for (unsigned i = 0; i < NUM_TYPES; ++i) { | |
118 while (!tasks[i].empty()) { | |
119 scoped_ptr<GraphNode> node = tasks[i].take_front(); | |
120 internal::WorkerPoolTask* task = node->task(); | |
121 graph.set(task, node.Pass()); | |
70 } | 122 } |
71 } | 123 } |
72 } | 124 } |
73 | 125 |
74 private: | 126 private: |
75 TaskMap perf_tasks_; | 127 TaskMap perf_tasks_; |
76 | 128 |
77 DISALLOW_COPY_AND_ASSIGN(PerfRasterWorkerPool); | 129 DISALLOW_COPY_AND_ASSIGN(PerfRasterWorkerPool); |
78 }; | 130 }; |
79 | 131 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 RunBuildTaskGraphTest("build_task_graph_100_4", 100, 4); | 243 RunBuildTaskGraphTest("build_task_graph_100_4", 100, 4); |
192 RunBuildTaskGraphTest("build_task_graph_1000_4", 1000, 4); | 244 RunBuildTaskGraphTest("build_task_graph_1000_4", 1000, 4); |
193 RunBuildTaskGraphTest("build_task_graph_10_16", 10, 16); | 245 RunBuildTaskGraphTest("build_task_graph_10_16", 10, 16); |
194 RunBuildTaskGraphTest("build_task_graph_100_16", 100, 16); | 246 RunBuildTaskGraphTest("build_task_graph_100_16", 100, 16); |
195 RunBuildTaskGraphTest("build_task_graph_1000_16", 1000, 16); | 247 RunBuildTaskGraphTest("build_task_graph_1000_16", 1000, 16); |
196 } | 248 } |
197 | 249 |
198 } // namespace | 250 } // namespace |
199 | 251 |
200 } // namespace cc | 252 } // namespace cc |
OLD | NEW |