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" |
28 #include "cc/trees/layer_tree_impl.h" | 29 #include "cc/trees/layer_tree_impl.h" |
29 #include "testing/perf/perf_test.h" | 30 #include "testing/perf/perf_test.h" |
30 | 31 |
31 namespace cc { | 32 namespace cc { |
32 namespace { | 33 namespace { |
33 | 34 |
34 static const int kTimeLimitMillis = 2000; | 35 static const int kTimeLimitMillis = 2000; |
35 static const int kWarmupRuns = 5; | 36 static const int kWarmupRuns = 5; |
36 static const int kTimeCheckInterval = 10; | 37 static const int kTimeCheckInterval = 10; |
37 | 38 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 host_impl->settings().can_use_lcd_text, | 155 host_impl->settings().can_use_lcd_text, |
155 host_impl->settings().layers_always_allowed_lcd_text, | 156 host_impl->settings().layers_always_allowed_lcd_text, |
156 can_render_to_separate_surface, | 157 can_render_to_separate_surface, |
157 host_impl->settings().layer_transforms_should_scale_layer_contents, | 158 host_impl->settings().layer_transforms_should_scale_layer_contents, |
158 host_impl->settings().verify_property_trees, | 159 host_impl->settings().verify_property_trees, |
159 &update_list, 0); | 160 &update_list, 0); |
160 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 161 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
161 } | 162 } |
162 }; | 163 }; |
163 | 164 |
164 class BspTreePerfTest : public CalcDrawPropsImplTest { | 165 class LayerSorterMainTest : public CalcDrawPropsImplTest { |
165 public: | 166 public: |
166 void RunSortLayers() { RunTest(false, false, false); } | 167 void RunSortLayers() { RunTest(false, false, false); } |
167 | 168 |
| 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 |
168 void SetNumberOfDuplicates(int num_duplicates) { | 217 void SetNumberOfDuplicates(int num_duplicates) { |
169 num_duplicates_ = num_duplicates; | 218 num_duplicates_ = num_duplicates; |
170 } | 219 } |
171 | 220 |
172 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 221 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
173 | 222 |
174 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 223 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
175 LayerTreeImpl* active_tree = host_impl->active_tree(); | 224 LayerTreeImpl* active_tree = host_impl->active_tree(); |
176 // First build the tree and then we'll start running tests on layersorter | 225 // First build the tree and then we'll start running tests on layersorter |
177 // itself | 226 // itself |
(...skipping 27 matching lines...) Expand all Loading... |
205 test_list.push_back(polygon_list[i]->CreateCopy()); | 254 test_list.push_back(polygon_list[i]->CreateCopy()); |
206 } | 255 } |
207 } | 256 } |
208 BspTree bsp_tree(&test_list); | 257 BspTree bsp_tree(&test_list); |
209 timer_.NextLap(); | 258 timer_.NextLap(); |
210 } while (!timer_.HasTimeLimitExpired()); | 259 } while (!timer_.HasTimeLimitExpired()); |
211 | 260 |
212 EndTest(); | 261 EndTest(); |
213 } | 262 } |
214 | 263 |
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 | |
225 private: | 264 private: |
226 LayerImplList base_list_; | |
227 int num_duplicates_; | 265 int num_duplicates_; |
228 }; | 266 }; |
229 | 267 |
230 TEST_F(CalcDrawPropsMainTest, TenTen) { | 268 TEST_F(CalcDrawPropsMainTest, TenTen) { |
231 SetTestName("10_10_main_thread"); | 269 SetTestName("10_10_main_thread"); |
232 ReadTestFile("10_10_layer_tree"); | 270 ReadTestFile("10_10_layer_tree"); |
233 RunCalcDrawProps(); | 271 RunCalcDrawProps(); |
234 } | 272 } |
235 | 273 |
236 TEST_F(CalcDrawPropsMainTest, HeavyPage) { | 274 TEST_F(CalcDrawPropsMainTest, HeavyPage) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 ReadTestFile("touch_region_light"); | 306 ReadTestFile("touch_region_light"); |
269 RunCalcDrawProps(); | 307 RunCalcDrawProps(); |
270 } | 308 } |
271 | 309 |
272 TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) { | 310 TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) { |
273 SetTestName("touch_region_heavy"); | 311 SetTestName("touch_region_heavy"); |
274 ReadTestFile("touch_region_heavy"); | 312 ReadTestFile("touch_region_heavy"); |
275 RunCalcDrawProps(); | 313 RunCalcDrawProps(); |
276 } | 314 } |
277 | 315 |
278 TEST_F(BspTreePerfTest, LayerSorterCubes) { | 316 TEST_F(LayerSorterMainTest, LayerSorterCubes) { |
279 SetTestName("layer_sort_cubes"); | 317 SetTestName("layer_sort_cubes"); |
280 ReadTestFile("layer_sort_cubes"); | 318 ReadTestFile("layer_sort_cubes"); |
281 RunSortLayers(); | 319 RunSortLayers(); |
282 } | 320 } |
283 | 321 |
284 TEST_F(BspTreePerfTest, LayerSorterRubik) { | 322 TEST_F(LayerSorterMainTest, LayerSorterRubik) { |
285 SetTestName("layer_sort_rubik"); | 323 SetTestName("layer_sort_rubik"); |
286 ReadTestFile("layer_sort_rubik"); | 324 ReadTestFile("layer_sort_rubik"); |
287 // TODO(vollick): Remove verify_property_trees setting after | 325 // TODO(vollick): Remove verify_property_trees setting after |
288 // crbug.com/444219 is fixed. | 326 // crbug.com/444219 is fixed. |
289 bool old_verify_property_trees = verify_property_trees(); | 327 bool old_verify_property_trees = verify_property_trees(); |
290 set_verify_property_trees(false); | 328 set_verify_property_trees(false); |
291 RunSortLayers(); | 329 RunSortLayers(); |
292 set_verify_property_trees(old_verify_property_trees); | 330 set_verify_property_trees(old_verify_property_trees); |
293 } | 331 } |
294 | 332 |
(...skipping 25 matching lines...) Expand all Loading... |
320 | 358 |
321 TEST_F(BspTreePerfTest, BspTreeCubes_4) { | 359 TEST_F(BspTreePerfTest, BspTreeCubes_4) { |
322 SetTestName("bsp_tree_cubes_4"); | 360 SetTestName("bsp_tree_cubes_4"); |
323 SetNumberOfDuplicates(4); | 361 SetNumberOfDuplicates(4); |
324 ReadTestFile("layer_sort_cubes"); | 362 ReadTestFile("layer_sort_cubes"); |
325 RunSortLayers(); | 363 RunSortLayers(); |
326 } | 364 } |
327 | 365 |
328 } // namespace | 366 } // namespace |
329 } // namespace cc | 367 } // namespace cc |
OLD | NEW |