Chromium Code Reviews| 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/memory/scoped_ptr.h" | |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "cc/base/scoped_ptr_vector.h" | |
| 15 #include "cc/debug/lap_timer.h" | 17 #include "cc/debug/lap_timer.h" |
| 16 #include "cc/layers/layer.h" | 18 #include "cc/layers/layer.h" |
| 19 #include "cc/output/bsp_tree.h" | |
| 20 #include "cc/quads/draw_polygon.h" | |
| 21 #include "cc/quads/draw_quad.h" | |
| 17 #include "cc/test/fake_content_layer_client.h" | 22 #include "cc/test/fake_content_layer_client.h" |
| 18 #include "cc/test/fake_layer_tree_host_client.h" | 23 #include "cc/test/fake_layer_tree_host_client.h" |
| 19 #include "cc/test/layer_tree_json_parser.h" | 24 #include "cc/test/layer_tree_json_parser.h" |
| 20 #include "cc/test/layer_tree_test.h" | 25 #include "cc/test/layer_tree_test.h" |
| 21 #include "cc/test/paths.h" | 26 #include "cc/test/paths.h" |
| 22 #include "cc/trees/layer_sorter.h" | 27 #include "cc/trees/layer_sorter.h" |
| 23 #include "cc/trees/layer_tree_impl.h" | 28 #include "cc/trees/layer_tree_impl.h" |
| 29 #include "cc/trees/single_thread_proxy.h" | |
| 24 #include "testing/perf/perf_test.h" | 30 #include "testing/perf/perf_test.h" |
| 25 | 31 |
| 26 namespace cc { | 32 namespace cc { |
| 27 namespace { | 33 namespace { |
| 28 | 34 |
| 29 static const int kTimeLimitMillis = 2000; | 35 static const int kTimeLimitMillis = 2000; |
| 30 static const int kWarmupRuns = 5; | 36 static const int kWarmupRuns = 5; |
| 31 static const int kTimeCheckInterval = 10; | 37 static const int kTimeCheckInterval = 10; |
| 32 | 38 |
| 33 class LayerTreeHostCommonPerfTest : public LayerTreeTest { | 39 class LayerTreeHostCommonPerfTest : public LayerTreeTest { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 for (unsigned int i = 0; i < layer->children().size(); i++) { | 206 for (unsigned int i = 0; i < layer->children().size(); i++) { |
| 201 BuildLayerImplList(layer->children()[i], list); | 207 BuildLayerImplList(layer->children()[i], list); |
| 202 } | 208 } |
| 203 } | 209 } |
| 204 | 210 |
| 205 private: | 211 private: |
| 206 LayerImplList base_list_; | 212 LayerImplList base_list_; |
| 207 LayerSorter layer_sorter_; | 213 LayerSorter layer_sorter_; |
| 208 }; | 214 }; |
| 209 | 215 |
| 216 class BspTreePerfTest : public LayerSorterMainTest { | |
| 217 public: | |
| 218 void RunSortLayers() { RunTest(false, false, false); } | |
| 219 | |
| 220 void SetNumberOfDuplicates(int num_duplicates) { | |
| 221 num_duplicates_ = num_duplicates; | |
| 222 } | |
| 223 | |
| 224 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 225 | |
| 226 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
| 227 LayerTreeImpl* active_tree = host_impl->active_tree(); | |
| 228 // First build the tree and then we'll start running tests on layersorter | |
| 229 // itself | |
| 230 bool can_render_to_separate_surface = true; | |
| 231 int max_texture_size = 8096; | |
| 232 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | |
| 233 max_texture_size, | |
| 234 active_tree, | |
| 235 host_impl); | |
| 236 | |
| 237 LayerImplList base_list; | |
| 238 BuildLayerImplList(active_tree->root_layer(), &base_list); | |
| 239 | |
| 240 int polygon_counter = 0; | |
| 241 ScopedPtrVector<DrawPolygon> polygon_list; | |
| 242 for (LayerImplList::iterator it = base_list.begin(); it != base_list.end(); | |
| 243 ++it) { | |
| 244 DrawPolygon* draw_polygon = new DrawPolygon(NULL, | |
| 245 (*it)->visible_content_rect(), | |
|
enne (OOO)
2014/07/30 18:43:56
Are the visible content rects valid in this test?
troyhildebrandt
2014/07/30 23:36:57
Using bounds() now.
| |
| 246 (*it)->draw_transform(), | |
| 247 polygon_counter++); | |
| 248 polygon_list.push_back(scoped_ptr<DrawPolygon>(draw_polygon)); | |
| 249 } | |
| 250 | |
| 251 timer_.Reset(); | |
| 252 do { | |
| 253 ScopedPtrDeque<DrawPolygon> test_list; | |
| 254 int dupe_counter = num_duplicates_; | |
| 255 while (dupe_counter-- > 0) { | |
|
enne (OOO)
2014/07/30 18:43:56
Use a for loop here.
troyhildebrandt
2014/07/30 23:36:57
Done.
| |
| 256 for (unsigned int i = 0; i < polygon_list.size(); i++) { | |
| 257 test_list.push_back(polygon_list[i]->CreateCopy()); | |
| 258 } | |
| 259 } | |
| 260 BspTree bsp_tree(&test_list); | |
| 261 timer_.NextLap(); | |
| 262 } while (!timer_.HasTimeLimitExpired()); | |
| 263 | |
| 264 EndTest(); | |
| 265 } | |
| 266 | |
| 267 private: | |
| 268 int num_duplicates_; | |
| 269 }; | |
| 270 | |
| 210 TEST_F(CalcDrawPropsMainTest, TenTen) { | 271 TEST_F(CalcDrawPropsMainTest, TenTen) { |
| 211 SetTestName("10_10_main_thread"); | 272 SetTestName("10_10_main_thread"); |
| 212 ReadTestFile("10_10_layer_tree"); | 273 ReadTestFile("10_10_layer_tree"); |
| 213 RunCalcDrawProps(); | 274 RunCalcDrawProps(); |
| 214 } | 275 } |
| 215 | 276 |
| 216 TEST_F(CalcDrawPropsMainTest, HeavyPage) { | 277 TEST_F(CalcDrawPropsMainTest, HeavyPage) { |
| 217 SetTestName("heavy_page_main_thread"); | 278 SetTestName("heavy_page_main_thread"); |
| 218 ReadTestFile("heavy_layer_tree"); | 279 ReadTestFile("heavy_layer_tree"); |
| 219 RunCalcDrawProps(); | 280 RunCalcDrawProps(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 ReadTestFile("layer_sort_cubes"); | 321 ReadTestFile("layer_sort_cubes"); |
| 261 RunSortLayers(); | 322 RunSortLayers(); |
| 262 } | 323 } |
| 263 | 324 |
| 264 TEST_F(LayerSorterMainTest, LayerSorterRubik) { | 325 TEST_F(LayerSorterMainTest, LayerSorterRubik) { |
| 265 SetTestName("layer_sort_rubik"); | 326 SetTestName("layer_sort_rubik"); |
| 266 ReadTestFile("layer_sort_rubik"); | 327 ReadTestFile("layer_sort_rubik"); |
| 267 RunSortLayers(); | 328 RunSortLayers(); |
| 268 } | 329 } |
| 269 | 330 |
| 331 TEST_F(BspTreePerfTest, BspTreeCubes) { | |
| 332 SetTestName("bsp_tree_cubes"); | |
| 333 SetNumberOfDuplicates(1); | |
| 334 ReadTestFile("layer_sort_cubes"); | |
| 335 RunSortLayers(); | |
| 336 } | |
| 337 | |
| 338 TEST_F(BspTreePerfTest, BspTreeRubik) { | |
| 339 SetTestName("bsp_tree_rubik"); | |
| 340 SetNumberOfDuplicates(1); | |
| 341 ReadTestFile("layer_sort_rubik"); | |
| 342 RunSortLayers(); | |
| 343 } | |
| 344 | |
| 345 TEST_F(BspTreePerfTest, BspTreeCubes_2) { | |
| 346 SetTestName("bsp_tree_cubes_2"); | |
| 347 SetNumberOfDuplicates(2); | |
| 348 ReadTestFile("layer_sort_cubes"); | |
| 349 RunSortLayers(); | |
| 350 } | |
| 351 | |
| 352 TEST_F(BspTreePerfTest, BspTreeCubes_4) { | |
| 353 SetTestName("bsp_tree_cubes_4"); | |
| 354 SetNumberOfDuplicates(4); | |
| 355 ReadTestFile("layer_sort_cubes"); | |
| 356 RunSortLayers(); | |
| 357 } | |
| 358 | |
| 270 } // namespace | 359 } // namespace |
| 271 } // namespace cc | 360 } // namespace cc |
| OLD | NEW |