OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <memory> | 8 #include <memory> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); | 64 base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); |
65 ASSERT_TRUE(base::ReadFileToString(json_file, &json_)); | 65 ASSERT_TRUE(base::ReadFileToString(json_file, &json_)); |
66 } | 66 } |
67 | 67 |
68 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 68 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
69 | 69 |
70 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 70 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
71 LayerTreeImpl* active_tree = host_impl->active_tree(); | 71 LayerTreeImpl* active_tree = host_impl->active_tree(); |
72 // First build the tree and then we'll start running tests on layersorter | 72 // First build the tree and then we'll start running tests on layersorter |
73 // itself | 73 // itself |
74 bool can_render_to_separate_surface = true; | |
75 int max_texture_size = 8096; | 74 int max_texture_size = 8096; |
76 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, max_texture_size, | 75 DoCalcDrawPropertiesImpl(max_texture_size, active_tree, host_impl); |
77 active_tree, host_impl); | |
78 | 76 |
79 LayerImplList base_list; | 77 LayerImplList base_list; |
80 BuildLayerImplList(active_tree->root_layer_for_testing(), &base_list); | 78 BuildLayerImplList(active_tree->root_layer_for_testing(), &base_list); |
81 | 79 |
82 int polygon_counter = 0; | 80 int polygon_counter = 0; |
83 std::vector<std::unique_ptr<DrawPolygon>> polygon_list; | 81 std::vector<std::unique_ptr<DrawPolygon>> polygon_list; |
84 for (LayerImplList::iterator it = base_list.begin(); it != base_list.end(); | 82 for (LayerImplList::iterator it = base_list.begin(); it != base_list.end(); |
85 ++it) { | 83 ++it) { |
86 DrawPolygon* draw_polygon = new DrawPolygon( | 84 DrawPolygon* draw_polygon = new DrawPolygon( |
87 NULL, gfx::RectF(gfx::SizeF((*it)->bounds())), | 85 NULL, gfx::RectF(gfx::SizeF((*it)->bounds())), |
88 (*it)->draw_properties().target_space_transform, polygon_counter++); | 86 (*it)->draw_properties().target_space_transform, polygon_counter++); |
89 polygon_list.push_back(std::unique_ptr<DrawPolygon>(draw_polygon)); | 87 polygon_list.push_back(std::unique_ptr<DrawPolygon>(draw_polygon)); |
90 } | 88 } |
91 | 89 |
92 timer_.Reset(); | 90 timer_.Reset(); |
93 do { | 91 do { |
94 std::deque<std::unique_ptr<DrawPolygon>> test_list; | 92 std::deque<std::unique_ptr<DrawPolygon>> test_list; |
95 for (int i = 0; i < num_duplicates_; i++) { | 93 for (int i = 0; i < num_duplicates_; i++) { |
96 for (size_t i = 0; i < polygon_list.size(); i++) { | 94 for (size_t i = 0; i < polygon_list.size(); i++) { |
97 test_list.push_back(polygon_list[i]->CreateCopy()); | 95 test_list.push_back(polygon_list[i]->CreateCopy()); |
98 } | 96 } |
99 } | 97 } |
100 BspTree bsp_tree(&test_list); | 98 BspTree bsp_tree(&test_list); |
101 timer_.NextLap(); | 99 timer_.NextLap(); |
102 } while (!timer_.HasTimeLimitExpired()); | 100 } while (!timer_.HasTimeLimitExpired()); |
103 | 101 |
104 EndTest(); | 102 EndTest(); |
105 } | 103 } |
106 | 104 |
107 void DoCalcDrawPropertiesImpl(bool can_render_to_separate_surface, | 105 void DoCalcDrawPropertiesImpl(int max_texture_size, |
108 int max_texture_size, | |
109 LayerTreeImpl* active_tree, | 106 LayerTreeImpl* active_tree, |
110 LayerTreeHostImpl* host_impl) { | 107 LayerTreeHostImpl* host_impl) { |
111 LayerImplList update_list; | 108 LayerImplList update_list; |
112 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( | 109 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( |
113 active_tree->root_layer_for_testing(), active_tree->DrawViewportSize(), | 110 active_tree->root_layer_for_testing(), active_tree->DrawViewportSize(), |
114 host_impl->DrawTransform(), active_tree->device_scale_factor(), | 111 host_impl->DrawTransform(), active_tree->device_scale_factor(), |
115 active_tree->current_page_scale_factor(), | 112 active_tree->current_page_scale_factor(), |
116 active_tree->InnerViewportContainerLayer(), | 113 active_tree->InnerViewportContainerLayer(), |
117 active_tree->InnerViewportScrollLayer(), | 114 active_tree->InnerViewportScrollLayer(), |
118 active_tree->OuterViewportScrollLayer(), | 115 active_tree->OuterViewportScrollLayer(), |
119 active_tree->elastic_overscroll()->Current(active_tree->IsActiveTree()), | 116 active_tree->elastic_overscroll()->Current(active_tree->IsActiveTree()), |
120 active_tree->OverscrollElasticityLayer(), max_texture_size, | 117 active_tree->OverscrollElasticityLayer(), max_texture_size, |
121 can_render_to_separate_surface, | |
122 host_impl->settings().layer_transforms_should_scale_layer_contents, | 118 host_impl->settings().layer_transforms_should_scale_layer_contents, |
123 false, // do not verify_clip_tree_calculation for perf tests | 119 false, // do not verify_clip_tree_calculation for perf tests |
124 false, // do not verify_visible_rect_calculation for perf tests | 120 false, // do not verify_visible_rect_calculation for perf tests |
125 &update_list, active_tree->property_trees()); | 121 &update_list, active_tree->property_trees()); |
126 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 122 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
127 } | 123 } |
128 | 124 |
129 void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) { | 125 void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) { |
130 for (auto* layer_impl : *layer->layer_tree_impl()) { | 126 for (auto* layer_impl : *layer->layer_tree_impl()) { |
131 if (layer_impl->Is3dSorted() && !layer_impl->bounds().IsEmpty()) { | 127 if (layer_impl->Is3dSorted() && !layer_impl->bounds().IsEmpty()) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 180 |
185 TEST_F(BspTreePerfTest, BspTreeCubes_4) { | 181 TEST_F(BspTreePerfTest, BspTreeCubes_4) { |
186 SetTestName("bsp_tree_cubes_4"); | 182 SetTestName("bsp_tree_cubes_4"); |
187 SetNumberOfDuplicates(4); | 183 SetNumberOfDuplicates(4); |
188 ReadTestFile("layer_sort_cubes"); | 184 ReadTestFile("layer_sort_cubes"); |
189 RunTest(CompositorMode::SINGLE_THREADED); | 185 RunTest(CompositorMode::SINGLE_THREADED); |
190 } | 186 } |
191 | 187 |
192 } // namespace | 188 } // namespace |
193 } // namespace cc | 189 } // namespace cc |
OLD | NEW |