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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "cc/debug/lap_timer.h" | 15 #include "cc/debug/lap_timer.h" |
16 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
17 #include "cc/test/fake_content_layer_client.h" | 17 #include "cc/test/fake_content_layer_client.h" |
18 #include "cc/test/fake_layer_tree_host_client.h" | 18 #include "cc/test/fake_layer_tree_host_client.h" |
19 #include "cc/test/layer_tree_json_parser.h" | 19 #include "cc/test/layer_tree_json_parser.h" |
20 #include "cc/test/layer_tree_test.h" | 20 #include "cc/test/layer_tree_test.h" |
21 #include "cc/test/paths.h" | 21 #include "cc/test/paths.h" |
22 #include "cc/trees/layer_sorter.h" | |
22 #include "cc/trees/layer_tree_impl.h" | 23 #include "cc/trees/layer_tree_impl.h" |
23 #include "testing/perf/perf_test.h" | 24 #include "testing/perf/perf_test.h" |
24 | 25 |
25 namespace cc { | 26 namespace cc { |
26 namespace { | 27 namespace { |
27 | 28 |
28 static const int kTimeLimitMillis = 2000; | 29 static const int kTimeLimitMillis = 2000; |
29 static const int kWarmupRuns = 5; | 30 static const int kWarmupRuns = 5; |
30 static const int kTimeCheckInterval = 10; | 31 static const int kTimeCheckInterval = 10; |
31 | 32 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 PostSetNeedsCommitToMainThread(); | 119 PostSetNeedsCommitToMainThread(); |
119 } | 120 } |
120 | 121 |
121 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 122 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
122 timer_.Reset(); | 123 timer_.Reset(); |
123 LayerTreeImpl* active_tree = host_impl->active_tree(); | 124 LayerTreeImpl* active_tree = host_impl->active_tree(); |
124 | 125 |
125 do { | 126 do { |
126 bool can_render_to_separate_surface = true; | 127 bool can_render_to_separate_surface = true; |
127 int max_texture_size = 8096; | 128 int max_texture_size = 8096; |
128 LayerImplList update_list; | 129 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, |
129 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( | 130 max_texture_size, |
130 active_tree->root_layer(), | 131 active_tree, |
131 active_tree->DrawViewportSize(), | 132 host_impl); |
132 host_impl->DrawTransform(), | |
133 active_tree->device_scale_factor(), | |
134 active_tree->total_page_scale_factor(), | |
135 active_tree->InnerViewportContainerLayer(), | |
136 max_texture_size, | |
137 host_impl->settings().can_use_lcd_text, | |
138 can_render_to_separate_surface, | |
139 host_impl->settings().layer_transforms_should_scale_layer_contents, | |
140 &update_list, | |
141 0); | |
142 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
143 | 133 |
144 timer_.NextLap(); | 134 timer_.NextLap(); |
145 } while (!timer_.HasTimeLimitExpired()); | 135 } while (!timer_.HasTimeLimitExpired()); |
146 | 136 |
147 EndTest(); | 137 EndTest(); |
148 } | 138 } |
139 | |
140 void DoCalcDrawPropertiesImpl(bool can_render_to_separate_surface, | |
141 int max_texture_size, | |
142 LayerTreeImpl* active_tree, | |
143 LayerTreeHostImpl* host_impl) { | |
144 LayerImplList update_list; | |
145 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( | |
146 active_tree->root_layer(), | |
147 active_tree->DrawViewportSize(), | |
148 host_impl->DrawTransform(), | |
149 active_tree->device_scale_factor(), | |
150 active_tree->total_page_scale_factor(), | |
151 active_tree->InnerViewportContainerLayer(), | |
152 max_texture_size, | |
153 host_impl->settings().can_use_lcd_text, | |
154 can_render_to_separate_surface, | |
155 host_impl->settings().layer_transforms_should_scale_layer_contents, | |
156 &update_list, | |
157 0); | |
158 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
159 } | |
160 }; | |
161 | |
162 class LayerSorterMainTest : public CalcDrawPropsImplTest { | |
163 public: | |
164 void RunSortLayers() { RunTest(false, false, false); } | |
165 | |
166 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
167 | |
168 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
169 LayerTreeImpl* active_tree = host_impl->active_tree(); | |
170 // First build the tree and then we'll start running tests on layersorter | |
171 // itself | |
172 bool can_render_to_separate_surface = true; | |
173 int max_texture_size = 8096; | |
174 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | |
175 max_texture_size, | |
176 active_tree, | |
177 host_impl); | |
178 | |
179 BuildLayerImplList(active_tree->root_layer(), &base_list); | |
180 | |
181 LayerImplList test_list; | |
182 timer_.Reset(); | |
183 do { | |
184 // Here we'll move the layers into a LayerImpl list of their own to be | |
185 // sorted so we don't have a sorted list for every run after the first | |
186 test_list.clear(); | |
Ian Vollick
2014/05/31 01:52:01
For each list you sort (I think there should be on
Troy Hildebrandt
2014/06/02 22:08:30
Done.
| |
187 for (LayerImplList::iterator it = base_list.begin(); it < base_list.end(); | |
188 ++it) { | |
189 test_list.push_back(*it); | |
190 } | |
191 | |
192 LayerSorter layer_sorter; | |
193 layer_sorter.Sort(test_list.begin(), test_list.end()); | |
194 timer_.NextLap(); | |
195 } while (!timer_.HasTimeLimitExpired()); | |
196 | |
197 EndTest(); | |
198 } | |
199 | |
200 void BuildLayerImplList(LayerImpl* layer, | |
201 LayerImplList* list, | |
202 size_t sorted_3d_level = 0) { | |
203 if (layer == NULL) | |
Ian Vollick
2014/05/31 01:52:01
Will this ever be the case? Correct me if I'm wron
Troy Hildebrandt
2014/06/02 22:08:30
As far as I can tell, it shouldn't be. I removed t
| |
204 return; | |
205 | |
206 size_t sorted_3d = sorted_3d_level + (layer->is_3d_sorted() ? 1 : 0); | |
Ian Vollick
2014/05/31 01:52:01
Using a size_t here is a little wonky and, I think
Troy Hildebrandt
2014/06/02 22:08:30
Removed, using layer->is_3d_sorted() now.
| |
207 if (sorted_3d) { | |
Ian Vollick
2014/05/31 01:52:01
Nit: no braces around one liners. Here and elsewhe
enne (OOO)
2014/06/02 17:54:19
Nit nit: Braces on oneliners are not forbidden by
Ian Vollick
2014/06/02 20:19:30
Wait, what?! That's awesome. I love braces around
| |
208 list->push_back(layer); | |
209 } | |
210 | |
211 for (size_t i = 0; i < layer->children().size(); ++i) { | |
212 BuildLayerImplList(layer->children()[i], list, sorted_3d); | |
213 } | |
214 } | |
215 | |
216 private: | |
217 LayerImplList base_list; | |
149 }; | 218 }; |
150 | 219 |
151 TEST_F(CalcDrawPropsMainTest, TenTen) { | 220 TEST_F(CalcDrawPropsMainTest, TenTen) { |
152 SetTestName("10_10_main_thread"); | 221 SetTestName("10_10_main_thread"); |
153 ReadTestFile("10_10_layer_tree"); | 222 ReadTestFile("10_10_layer_tree"); |
154 RunCalcDrawProps(); | 223 RunCalcDrawProps(); |
155 } | 224 } |
156 | 225 |
157 TEST_F(CalcDrawPropsMainTest, HeavyPage) { | 226 TEST_F(CalcDrawPropsMainTest, HeavyPage) { |
158 SetTestName("heavy_page_main_thread"); | 227 SetTestName("heavy_page_main_thread"); |
(...skipping 30 matching lines...) Expand all Loading... | |
189 ReadTestFile("touch_region_light"); | 258 ReadTestFile("touch_region_light"); |
190 RunCalcDrawProps(); | 259 RunCalcDrawProps(); |
191 } | 260 } |
192 | 261 |
193 TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) { | 262 TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) { |
194 SetTestName("touch_region_heavy"); | 263 SetTestName("touch_region_heavy"); |
195 ReadTestFile("touch_region_heavy"); | 264 ReadTestFile("touch_region_heavy"); |
196 RunCalcDrawProps(); | 265 RunCalcDrawProps(); |
197 } | 266 } |
198 | 267 |
268 TEST_F(LayerSorterMainTest, LayerSorterCubes) { | |
269 SetTestName("layer_sort_cubes"); | |
270 ReadTestFile("layer_sort_cubes"); | |
271 RunSortLayers(); | |
272 } | |
273 | |
274 TEST_F(LayerSorterMainTest, LayerSorterRubik) { | |
275 SetTestName("layer_sort_rubik"); | |
276 ReadTestFile("layer_sort_rubik"); | |
277 RunSortLayers(); | |
278 } | |
279 | |
199 } // namespace | 280 } // namespace |
200 } // namespace cc | 281 } // namespace cc |
OLD | NEW |