| 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 <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 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "cc/debug/lap_timer.h" | 17 #include "cc/debug/lap_timer.h" |
| 18 #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" | |
| 22 #include "cc/test/fake_content_layer_client.h" | 19 #include "cc/test/fake_content_layer_client.h" |
| 23 #include "cc/test/fake_layer_tree_host_client.h" | 20 #include "cc/test/fake_layer_tree_host_client.h" |
| 24 #include "cc/test/layer_tree_json_parser.h" | 21 #include "cc/test/layer_tree_json_parser.h" |
| 25 #include "cc/test/layer_tree_test.h" | 22 #include "cc/test/layer_tree_test.h" |
| 26 #include "cc/test/paths.h" | 23 #include "cc/test/paths.h" |
| 27 #include "cc/trees/layer_tree_host_common.h" | 24 #include "cc/trees/layer_tree_host_common.h" |
| 28 #include "cc/trees/layer_tree_impl.h" | 25 #include "cc/trees/layer_tree_impl.h" |
| 29 #include "testing/perf/perf_test.h" | 26 #include "testing/perf/perf_test.h" |
| 30 | 27 |
| 31 namespace cc { | 28 namespace cc { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 active_tree->OverscrollElasticityLayer(), max_texture_size, | 115 active_tree->OverscrollElasticityLayer(), max_texture_size, |
| 119 can_render_to_separate_surface, | 116 can_render_to_separate_surface, |
| 120 host_impl->settings().layer_transforms_should_scale_layer_contents, | 117 host_impl->settings().layer_transforms_should_scale_layer_contents, |
| 121 false, // do not verify_clip_tree_calculation for perf tests | 118 false, // do not verify_clip_tree_calculation for perf tests |
| 122 false, // do not verify_transform_tree_calculation for perf tests | 119 false, // do not verify_transform_tree_calculation for perf tests |
| 123 &update_list, active_tree->property_trees()); | 120 &update_list, active_tree->property_trees()); |
| 124 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 121 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 125 } | 122 } |
| 126 }; | 123 }; |
| 127 | 124 |
| 128 class BspTreePerfTest : public CalcDrawPropsTest { | |
| 129 public: | |
| 130 BspTreePerfTest() : num_duplicates_(1) {} | |
| 131 void RunSortLayers() { RunTest(CompositorMode::SINGLE_THREADED); } | |
| 132 | |
| 133 void SetNumberOfDuplicates(int num_duplicates) { | |
| 134 num_duplicates_ = num_duplicates; | |
| 135 } | |
| 136 | |
| 137 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
| 138 | |
| 139 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | |
| 140 LayerTreeImpl* active_tree = host_impl->active_tree(); | |
| 141 // First build the tree and then we'll start running tests on layersorter | |
| 142 // itself | |
| 143 bool can_render_to_separate_surface = true; | |
| 144 int max_texture_size = 8096; | |
| 145 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | |
| 146 max_texture_size, | |
| 147 active_tree, | |
| 148 host_impl); | |
| 149 | |
| 150 LayerImplList base_list; | |
| 151 BuildLayerImplList(active_tree->root_layer_for_testing(), &base_list); | |
| 152 | |
| 153 int polygon_counter = 0; | |
| 154 std::vector<std::unique_ptr<DrawPolygon>> polygon_list; | |
| 155 for (LayerImplList::iterator it = base_list.begin(); it != base_list.end(); | |
| 156 ++it) { | |
| 157 DrawPolygon* draw_polygon = new DrawPolygon( | |
| 158 NULL, gfx::RectF(gfx::SizeF((*it)->bounds())), | |
| 159 (*it)->draw_properties().target_space_transform, polygon_counter++); | |
| 160 polygon_list.push_back(std::unique_ptr<DrawPolygon>(draw_polygon)); | |
| 161 } | |
| 162 | |
| 163 timer_.Reset(); | |
| 164 do { | |
| 165 std::deque<std::unique_ptr<DrawPolygon>> test_list; | |
| 166 for (int i = 0; i < num_duplicates_; i++) { | |
| 167 for (size_t i = 0; i < polygon_list.size(); i++) { | |
| 168 test_list.push_back(polygon_list[i]->CreateCopy()); | |
| 169 } | |
| 170 } | |
| 171 BspTree bsp_tree(&test_list); | |
| 172 timer_.NextLap(); | |
| 173 } while (!timer_.HasTimeLimitExpired()); | |
| 174 | |
| 175 EndTest(); | |
| 176 } | |
| 177 | |
| 178 void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) { | |
| 179 for (auto* layer_impl : *layer->layer_tree_impl()) { | |
| 180 if (layer_impl->Is3dSorted() && !layer_impl->bounds().IsEmpty()) { | |
| 181 list->push_back(layer_impl); | |
| 182 } | |
| 183 } | |
| 184 } | |
| 185 | |
| 186 private: | |
| 187 LayerImplList base_list_; | |
| 188 int num_duplicates_; | |
| 189 }; | |
| 190 | |
| 191 TEST_F(CalcDrawPropsTest, TenTen) { | 125 TEST_F(CalcDrawPropsTest, TenTen) { |
| 192 SetTestName("10_10"); | 126 SetTestName("10_10"); |
| 193 ReadTestFile("10_10_layer_tree"); | 127 ReadTestFile("10_10_layer_tree"); |
| 194 RunCalcDrawProps(); | 128 RunCalcDrawProps(); |
| 195 } | 129 } |
| 196 | 130 |
| 197 TEST_F(CalcDrawPropsTest, HeavyPage) { | 131 TEST_F(CalcDrawPropsTest, HeavyPage) { |
| 198 SetTestName("heavy_page"); | 132 SetTestName("heavy_page"); |
| 199 ReadTestFile("heavy_layer_tree"); | 133 ReadTestFile("heavy_layer_tree"); |
| 200 RunCalcDrawProps(); | 134 RunCalcDrawProps(); |
| 201 } | 135 } |
| 202 | 136 |
| 203 TEST_F(CalcDrawPropsTest, TouchRegionLight) { | 137 TEST_F(CalcDrawPropsTest, TouchRegionLight) { |
| 204 SetTestName("touch_region_light"); | 138 SetTestName("touch_region_light"); |
| 205 ReadTestFile("touch_region_light"); | 139 ReadTestFile("touch_region_light"); |
| 206 RunCalcDrawProps(); | 140 RunCalcDrawProps(); |
| 207 } | 141 } |
| 208 | 142 |
| 209 TEST_F(CalcDrawPropsTest, TouchRegionHeavy) { | 143 TEST_F(CalcDrawPropsTest, TouchRegionHeavy) { |
| 210 SetTestName("touch_region_heavy"); | 144 SetTestName("touch_region_heavy"); |
| 211 ReadTestFile("touch_region_heavy"); | 145 ReadTestFile("touch_region_heavy"); |
| 212 RunCalcDrawProps(); | 146 RunCalcDrawProps(); |
| 213 } | 147 } |
| 214 | 148 |
| 215 TEST_F(BspTreePerfTest, LayerSorterCubes) { | |
| 216 SetTestName("layer_sort_cubes"); | |
| 217 ReadTestFile("layer_sort_cubes"); | |
| 218 RunSortLayers(); | |
| 219 } | |
| 220 | |
| 221 TEST_F(BspTreePerfTest, LayerSorterRubik) { | |
| 222 SetTestName("layer_sort_rubik"); | |
| 223 ReadTestFile("layer_sort_rubik"); | |
| 224 RunSortLayers(); | |
| 225 } | |
| 226 | |
| 227 TEST_F(BspTreePerfTest, BspTreeCubes) { | |
| 228 SetTestName("bsp_tree_cubes"); | |
| 229 SetNumberOfDuplicates(1); | |
| 230 ReadTestFile("layer_sort_cubes"); | |
| 231 RunSortLayers(); | |
| 232 } | |
| 233 | |
| 234 TEST_F(BspTreePerfTest, BspTreeRubik) { | |
| 235 SetTestName("bsp_tree_rubik"); | |
| 236 SetNumberOfDuplicates(1); | |
| 237 ReadTestFile("layer_sort_rubik"); | |
| 238 RunSortLayers(); | |
| 239 } | |
| 240 | |
| 241 TEST_F(BspTreePerfTest, BspTreeCubes_2) { | |
| 242 SetTestName("bsp_tree_cubes_2"); | |
| 243 SetNumberOfDuplicates(2); | |
| 244 ReadTestFile("layer_sort_cubes"); | |
| 245 RunSortLayers(); | |
| 246 } | |
| 247 | |
| 248 TEST_F(BspTreePerfTest, BspTreeCubes_4) { | |
| 249 SetTestName("bsp_tree_cubes_4"); | |
| 250 SetNumberOfDuplicates(4); | |
| 251 ReadTestFile("layer_sort_cubes"); | |
| 252 RunSortLayers(); | |
| 253 } | |
| 254 | |
| 255 } // namespace | 149 } // namespace |
| 256 } // namespace cc | 150 } // namespace cc |
| OLD | NEW |