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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "cc/base/scoped_ptr_deque.h" | 16 #include "cc/base/scoped_ptr_deque.h" |
17 #include "cc/base/scoped_ptr_vector.h" | 17 #include "cc/base/scoped_ptr_vector.h" |
18 #include "cc/debug/lap_timer.h" | 18 #include "cc/debug/lap_timer.h" |
19 #include "cc/layers/layer.h" | 19 #include "cc/layers/layer.h" |
20 #include "cc/output/bsp_tree.h" | 20 #include "cc/output/bsp_tree.h" |
21 #include "cc/quads/draw_polygon.h" | 21 #include "cc/quads/draw_polygon.h" |
22 #include "cc/quads/draw_quad.h" | 22 #include "cc/quads/draw_quad.h" |
23 #include "cc/test/fake_content_layer_client.h" | 23 #include "cc/test/fake_content_layer_client.h" |
24 #include "cc/test/fake_layer_tree_host_client.h" | 24 #include "cc/test/fake_layer_tree_host_client.h" |
25 #include "cc/test/layer_tree_json_parser.h" | 25 #include "cc/test/layer_tree_json_parser.h" |
26 #include "cc/test/layer_tree_test.h" | 26 #include "cc/test/layer_tree_test.h" |
27 #include "cc/test/paths.h" | 27 #include "cc/test/paths.h" |
28 #include "cc/trees/layer_sorter.h" | |
29 #include "cc/trees/layer_tree_impl.h" | 28 #include "cc/trees/layer_tree_impl.h" |
30 #include "testing/perf/perf_test.h" | 29 #include "testing/perf/perf_test.h" |
31 | 30 |
32 namespace cc { | 31 namespace cc { |
33 namespace { | 32 namespace { |
34 | 33 |
35 static const int kTimeLimitMillis = 2000; | 34 static const int kTimeLimitMillis = 2000; |
36 static const int kWarmupRuns = 5; | 35 static const int kWarmupRuns = 5; |
37 static const int kTimeCheckInterval = 10; | 36 static const int kTimeCheckInterval = 10; |
38 | 37 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 host_impl->settings().can_use_lcd_text, | 154 host_impl->settings().can_use_lcd_text, |
156 host_impl->settings().layers_always_allowed_lcd_text, | 155 host_impl->settings().layers_always_allowed_lcd_text, |
157 can_render_to_separate_surface, | 156 can_render_to_separate_surface, |
158 host_impl->settings().layer_transforms_should_scale_layer_contents, | 157 host_impl->settings().layer_transforms_should_scale_layer_contents, |
159 host_impl->settings().verify_property_trees, | 158 host_impl->settings().verify_property_trees, |
160 &update_list, 0); | 159 &update_list, 0); |
161 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 160 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
162 } | 161 } |
163 }; | 162 }; |
164 | 163 |
165 class LayerSorterMainTest : public CalcDrawPropsImplTest { | 164 class BspTreePerfTest : public CalcDrawPropsImplTest { |
166 public: | 165 public: |
167 void RunSortLayers() { RunTest(false, false, false); } | 166 void RunSortLayers() { RunTest(false, false, false); } |
168 | 167 |
169 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
170 | |
171 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | |
172 LayerTreeImpl* active_tree = host_impl->active_tree(); | |
173 // First build the tree and then we'll start running tests on layersorter | |
174 // itself | |
175 bool can_render_to_separate_surface = true; | |
176 int max_texture_size = 8096; | |
177 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | |
178 max_texture_size, | |
179 active_tree, | |
180 host_impl); | |
181 | |
182 // Behaviour of this test is different from that of sorting in practice. | |
183 // In this case, all layers that exist in any 3D context are put into a list | |
184 // and are sorted as one big 3D context instead of several smaller ones. | |
185 BuildLayerImplList(active_tree->root_layer(), &base_list_); | |
186 timer_.Reset(); | |
187 do { | |
188 // Here we'll move the layers into a LayerImpl list of their own to be | |
189 // sorted so we don't have a sorted list for every run after the first | |
190 LayerImplList test_list = base_list_; | |
191 layer_sorter_.Sort(test_list.begin(), test_list.end()); | |
192 timer_.NextLap(); | |
193 } while (!timer_.HasTimeLimitExpired()); | |
194 | |
195 EndTest(); | |
196 } | |
197 | |
198 void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) { | |
199 if (layer->Is3dSorted()) { | |
200 list->push_back(layer); | |
201 } | |
202 | |
203 for (size_t i = 0; i < layer->children().size(); i++) { | |
204 BuildLayerImplList(layer->children()[i], list); | |
205 } | |
206 } | |
207 | |
208 private: | |
209 LayerImplList base_list_; | |
210 LayerSorter layer_sorter_; | |
211 }; | |
212 | |
213 class BspTreePerfTest : public LayerSorterMainTest { | |
214 public: | |
215 void RunSortLayers() { RunTest(false, false, false); } | |
216 | |
217 void SetNumberOfDuplicates(int num_duplicates) { | 168 void SetNumberOfDuplicates(int num_duplicates) { |
218 num_duplicates_ = num_duplicates; | 169 num_duplicates_ = num_duplicates; |
219 } | 170 } |
220 | 171 |
221 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 172 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
222 | 173 |
223 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 174 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
224 LayerTreeImpl* active_tree = host_impl->active_tree(); | 175 LayerTreeImpl* active_tree = host_impl->active_tree(); |
225 // First build the tree and then we'll start running tests on layersorter | 176 // First build the tree and then we'll start running tests on layersorter |
226 // itself | 177 // itself |
(...skipping 27 matching lines...) Expand all Loading... |
254 test_list.push_back(polygon_list[i]->CreateCopy()); | 205 test_list.push_back(polygon_list[i]->CreateCopy()); |
255 } | 206 } |
256 } | 207 } |
257 BspTree bsp_tree(&test_list); | 208 BspTree bsp_tree(&test_list); |
258 timer_.NextLap(); | 209 timer_.NextLap(); |
259 } while (!timer_.HasTimeLimitExpired()); | 210 } while (!timer_.HasTimeLimitExpired()); |
260 | 211 |
261 EndTest(); | 212 EndTest(); |
262 } | 213 } |
263 | 214 |
| 215 void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) { |
| 216 if (layer->Is3dSorted()) { |
| 217 list->push_back(layer); |
| 218 } |
| 219 |
| 220 for (size_t i = 0; i < layer->children().size(); i++) { |
| 221 BuildLayerImplList(layer->children()[i], list); |
| 222 } |
| 223 } |
| 224 |
264 private: | 225 private: |
| 226 LayerImplList base_list_; |
265 int num_duplicates_; | 227 int num_duplicates_; |
266 }; | 228 }; |
267 | 229 |
268 TEST_F(CalcDrawPropsMainTest, TenTen) { | 230 TEST_F(CalcDrawPropsMainTest, TenTen) { |
269 SetTestName("10_10_main_thread"); | 231 SetTestName("10_10_main_thread"); |
270 ReadTestFile("10_10_layer_tree"); | 232 ReadTestFile("10_10_layer_tree"); |
271 RunCalcDrawProps(); | 233 RunCalcDrawProps(); |
272 } | 234 } |
273 | 235 |
274 TEST_F(CalcDrawPropsMainTest, HeavyPage) { | 236 TEST_F(CalcDrawPropsMainTest, HeavyPage) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 ReadTestFile("touch_region_light"); | 268 ReadTestFile("touch_region_light"); |
307 RunCalcDrawProps(); | 269 RunCalcDrawProps(); |
308 } | 270 } |
309 | 271 |
310 TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) { | 272 TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) { |
311 SetTestName("touch_region_heavy"); | 273 SetTestName("touch_region_heavy"); |
312 ReadTestFile("touch_region_heavy"); | 274 ReadTestFile("touch_region_heavy"); |
313 RunCalcDrawProps(); | 275 RunCalcDrawProps(); |
314 } | 276 } |
315 | 277 |
316 TEST_F(LayerSorterMainTest, LayerSorterCubes) { | 278 TEST_F(BspTreePerfTest, LayerSorterCubes) { |
317 SetTestName("layer_sort_cubes"); | 279 SetTestName("layer_sort_cubes"); |
318 ReadTestFile("layer_sort_cubes"); | 280 ReadTestFile("layer_sort_cubes"); |
319 RunSortLayers(); | 281 RunSortLayers(); |
320 } | 282 } |
321 | 283 |
322 TEST_F(LayerSorterMainTest, LayerSorterRubik) { | 284 TEST_F(BspTreePerfTest, LayerSorterRubik) { |
323 SetTestName("layer_sort_rubik"); | 285 SetTestName("layer_sort_rubik"); |
324 ReadTestFile("layer_sort_rubik"); | 286 ReadTestFile("layer_sort_rubik"); |
325 // TODO(vollick): Remove verify_property_trees setting after | 287 // TODO(vollick): Remove verify_property_trees setting after |
326 // crbug.com/444219 is fixed. | 288 // crbug.com/444219 is fixed. |
327 bool old_verify_property_trees = verify_property_trees(); | 289 bool old_verify_property_trees = verify_property_trees(); |
328 set_verify_property_trees(false); | 290 set_verify_property_trees(false); |
329 RunSortLayers(); | 291 RunSortLayers(); |
330 set_verify_property_trees(old_verify_property_trees); | 292 set_verify_property_trees(old_verify_property_trees); |
331 } | 293 } |
332 | 294 |
(...skipping 25 matching lines...) Expand all Loading... |
358 | 320 |
359 TEST_F(BspTreePerfTest, BspTreeCubes_4) { | 321 TEST_F(BspTreePerfTest, BspTreeCubes_4) { |
360 SetTestName("bsp_tree_cubes_4"); | 322 SetTestName("bsp_tree_cubes_4"); |
361 SetNumberOfDuplicates(4); | 323 SetNumberOfDuplicates(4); |
362 ReadTestFile("layer_sort_cubes"); | 324 ReadTestFile("layer_sort_cubes"); |
363 RunSortLayers(); | 325 RunSortLayers(); |
364 } | 326 } |
365 | 327 |
366 } // namespace | 328 } // namespace |
367 } // namespace cc | 329 } // namespace cc |
OLD | NEW |