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_controller.h" | |
| 20 #include "cc/output/bsp_tree.h" | |
| 21 #include "cc/quads/draw_polygon.h" | |
| 22 #include "cc/quads/draw_quad.h" | |
| 17 #include "cc/test/fake_content_layer_client.h" | 23 #include "cc/test/fake_content_layer_client.h" |
| 18 #include "cc/test/fake_layer_tree_host_client.h" | 24 #include "cc/test/fake_layer_tree_host_client.h" |
| 19 #include "cc/test/layer_tree_json_parser.h" | 25 #include "cc/test/layer_tree_json_parser.h" |
| 20 #include "cc/test/layer_tree_test.h" | 26 #include "cc/test/layer_tree_test.h" |
| 21 #include "cc/test/paths.h" | 27 #include "cc/test/paths.h" |
| 22 #include "cc/trees/layer_sorter.h" | 28 #include "cc/trees/layer_sorter.h" |
| 23 #include "cc/trees/layer_tree_impl.h" | 29 #include "cc/trees/layer_tree_impl.h" |
| 30 #include "cc/trees/single_thread_proxy.h" | |
| 24 #include "testing/perf/perf_test.h" | 31 #include "testing/perf/perf_test.h" |
| 25 | 32 |
| 26 namespace cc { | 33 namespace cc { |
| 27 namespace { | 34 namespace { |
| 28 | 35 |
| 29 static const int kTimeLimitMillis = 2000; | 36 static const int kTimeLimitMillis = 2000; |
| 30 static const int kWarmupRuns = 5; | 37 static const int kWarmupRuns = 5; |
| 31 static const int kTimeCheckInterval = 10; | 38 static const int kTimeCheckInterval = 10; |
| 32 | 39 |
| 33 class LayerTreeHostCommonPerfTest : public LayerTreeTest { | 40 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++) { | 207 for (unsigned int i = 0; i < layer->children().size(); i++) { |
| 201 BuildLayerImplList(layer->children()[i], list); | 208 BuildLayerImplList(layer->children()[i], list); |
| 202 } | 209 } |
| 203 } | 210 } |
| 204 | 211 |
| 205 private: | 212 private: |
| 206 LayerImplList base_list_; | 213 LayerImplList base_list_; |
| 207 LayerSorter layer_sorter_; | 214 LayerSorter layer_sorter_; |
| 208 }; | 215 }; |
| 209 | 216 |
| 217 class BspTreePerfTest : public LayerSorterMainTest { | |
| 218 public: | |
| 219 void RunSortLayers() { RunTest(false, false, false); } | |
| 220 | |
| 221 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 222 | |
| 223 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
| 224 LayerTreeImpl* active_tree = host_impl->active_tree(); | |
| 225 // First build the tree and then we'll start running tests on layersorter | |
| 226 // itself | |
| 227 bool can_render_to_separate_surface = true; | |
| 228 int max_texture_size = 8096; | |
| 229 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | |
| 230 max_texture_size, | |
| 231 active_tree, | |
| 232 host_impl); | |
| 233 | |
| 234 LayerImplList base_list; | |
| 235 BuildLayerImplList(active_tree->root_layer(), &base_list); | |
| 236 | |
| 237 int polygon_counter = 0; | |
| 238 ScopedPtrVector<DrawPolygon> polygon_list; | |
| 239 for (LayerImplList::iterator it = base_list.begin(); it != base_list.end(); | |
| 240 ++it) { | |
| 241 gfx::Point3F points[8]; | |
| 242 int num_vertices_in_clipped_quad; | |
| 243 gfx::QuadF send_quad((*it)->visible_content_rect()); | |
| 244 MathUtil::MapClippedQuad3d((*it)->draw_transform(), | |
|
enne (OOO)
2014/07/28 23:37:40
It seems to me like maybe you just need a DrawPoly
troyhildebrandt
2014/07/29 19:57:17
Made a more general purpose constructor that will
| |
| 245 send_quad, | |
| 246 points, | |
| 247 &num_vertices_in_clipped_quad); | |
| 248 std::vector<gfx::Point3F> points_vector; | |
| 249 for (int i = 0; i < num_vertices_in_clipped_quad; i++) { | |
| 250 points_vector.push_back(points[i]); | |
| 251 } | |
| 252 DrawPolygon* draw_polygon = | |
| 253 new DrawPolygon(NULL, points_vector, polygon_counter++); | |
| 254 draw_polygon->ApplyTransformToNormal((*it)->draw_transform()); | |
| 255 polygon_list.push_back(scoped_ptr<DrawPolygon>(draw_polygon)); | |
| 256 } | |
| 257 | |
| 258 timer_.Reset(); | |
| 259 do { | |
| 260 ScopedPtrVector<DrawPolygon> test_list; | |
| 261 for (unsigned int i = 0; i < polygon_list.size(); i++) { | |
| 262 test_list.push_back(polygon_list[i]->CreateCopy()); | |
| 263 } | |
| 264 BspController bsp_controller; | |
| 265 BspTree bsp_tree(&bsp_controller, &test_list); | |
| 266 timer_.NextLap(); | |
| 267 } while (!timer_.HasTimeLimitExpired()); | |
| 268 | |
| 269 EndTest(); | |
| 270 } | |
| 271 }; | |
| 272 | |
| 210 TEST_F(CalcDrawPropsMainTest, TenTen) { | 273 TEST_F(CalcDrawPropsMainTest, TenTen) { |
| 211 SetTestName("10_10_main_thread"); | 274 SetTestName("10_10_main_thread"); |
| 212 ReadTestFile("10_10_layer_tree"); | 275 ReadTestFile("10_10_layer_tree"); |
| 213 RunCalcDrawProps(); | 276 RunCalcDrawProps(); |
| 214 } | 277 } |
| 215 | 278 |
| 216 TEST_F(CalcDrawPropsMainTest, HeavyPage) { | 279 TEST_F(CalcDrawPropsMainTest, HeavyPage) { |
| 217 SetTestName("heavy_page_main_thread"); | 280 SetTestName("heavy_page_main_thread"); |
| 218 ReadTestFile("heavy_layer_tree"); | 281 ReadTestFile("heavy_layer_tree"); |
| 219 RunCalcDrawProps(); | 282 RunCalcDrawProps(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 ReadTestFile("layer_sort_cubes"); | 323 ReadTestFile("layer_sort_cubes"); |
| 261 RunSortLayers(); | 324 RunSortLayers(); |
| 262 } | 325 } |
| 263 | 326 |
| 264 TEST_F(LayerSorterMainTest, LayerSorterRubik) { | 327 TEST_F(LayerSorterMainTest, LayerSorterRubik) { |
| 265 SetTestName("layer_sort_rubik"); | 328 SetTestName("layer_sort_rubik"); |
| 266 ReadTestFile("layer_sort_rubik"); | 329 ReadTestFile("layer_sort_rubik"); |
| 267 RunSortLayers(); | 330 RunSortLayers(); |
| 268 } | 331 } |
| 269 | 332 |
| 333 TEST_F(BspTreePerfTest, BspTreeCubes) { | |
| 334 SetTestName("bsp_tree_cubes"); | |
| 335 ReadTestFile("layer_sort_cubes"); | |
| 336 RunSortLayers(); | |
| 337 } | |
| 338 | |
| 339 TEST_F(BspTreePerfTest, BspTreeRubik) { | |
|
enne (OOO)
2014/07/28 23:37:40
For completeness can you add a BspTreeCubes_2 and
troyhildebrandt
2014/07/29 19:57:17
Done.
| |
| 340 SetTestName("bsp_tree_rubik"); | |
| 341 ReadTestFile("layer_sort_rubik"); | |
| 342 RunSortLayers(); | |
| 343 } | |
| 344 | |
| 270 } // namespace | 345 } // namespace |
| 271 } // namespace cc | 346 } // namespace cc |
| OLD | NEW |