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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 43 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
44 kTimeCheckInterval) {} | 44 kTimeCheckInterval) {} |
45 | 45 |
46 void ReadTestFile(const std::string& name) { | 46 void ReadTestFile(const std::string& name) { |
47 base::FilePath test_data_dir; | 47 base::FilePath test_data_dir; |
48 ASSERT_TRUE(PathService::Get(CCPaths::DIR_TEST_DATA, &test_data_dir)); | 48 ASSERT_TRUE(PathService::Get(CCPaths::DIR_TEST_DATA, &test_data_dir)); |
49 base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); | 49 base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); |
50 ASSERT_TRUE(base::ReadFileToString(json_file, &json_)); | 50 ASSERT_TRUE(base::ReadFileToString(json_file, &json_)); |
51 } | 51 } |
52 | 52 |
53 virtual void SetupTree() override { | 53 void SetupTree() override { |
54 gfx::Size viewport = gfx::Size(720, 1038); | 54 gfx::Size viewport = gfx::Size(720, 1038); |
55 layer_tree_host()->SetViewportSize(viewport); | 55 layer_tree_host()->SetViewportSize(viewport); |
56 scoped_refptr<Layer> root = | 56 scoped_refptr<Layer> root = |
57 ParseTreeFromJson(json_, &content_layer_client_); | 57 ParseTreeFromJson(json_, &content_layer_client_); |
58 ASSERT_TRUE(root.get()); | 58 ASSERT_TRUE(root.get()); |
59 layer_tree_host()->SetRootLayer(root); | 59 layer_tree_host()->SetRootLayer(root); |
60 } | 60 } |
61 | 61 |
62 void SetTestName(const std::string& name) { test_name_ = name; } | 62 void SetTestName(const std::string& name) { test_name_ = name; } |
63 | 63 |
64 virtual void AfterTest() override { | 64 void AfterTest() override { |
65 CHECK(!test_name_.empty()) << "Must SetTestName() before TearDown()."; | 65 CHECK(!test_name_.empty()) << "Must SetTestName() before TearDown()."; |
66 perf_test::PrintResult("calc_draw_props_time", | 66 perf_test::PrintResult("calc_draw_props_time", |
67 "", | 67 "", |
68 test_name_, | 68 test_name_, |
69 1000 * timer_.MsPerLap(), | 69 1000 * timer_.MsPerLap(), |
70 "us", | 70 "us", |
71 true); | 71 true); |
72 } | 72 } |
73 | 73 |
74 protected: | 74 protected: |
75 FakeContentLayerClient content_layer_client_; | 75 FakeContentLayerClient content_layer_client_; |
76 LapTimer timer_; | 76 LapTimer timer_; |
77 std::string test_name_; | 77 std::string test_name_; |
78 std::string json_; | 78 std::string json_; |
79 }; | 79 }; |
80 | 80 |
81 class CalcDrawPropsMainTest : public LayerTreeHostCommonPerfTest { | 81 class CalcDrawPropsMainTest : public LayerTreeHostCommonPerfTest { |
82 public: | 82 public: |
83 void RunCalcDrawProps() { | 83 void RunCalcDrawProps() { |
84 RunTest(false, false, false); | 84 RunTest(false, false, false); |
85 } | 85 } |
86 | 86 |
87 virtual void BeginTest() override { | 87 void BeginTest() override { |
88 timer_.Reset(); | 88 timer_.Reset(); |
89 | 89 |
90 do { | 90 do { |
91 bool can_render_to_separate_surface = true; | 91 bool can_render_to_separate_surface = true; |
92 int max_texture_size = 8096; | 92 int max_texture_size = 8096; |
93 RenderSurfaceLayerList update_list; | 93 RenderSurfaceLayerList update_list; |
94 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs( | 94 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs( |
95 layer_tree_host()->root_layer(), | 95 layer_tree_host()->root_layer(), |
96 layer_tree_host()->device_viewport_size(), | 96 layer_tree_host()->device_viewport_size(), |
97 gfx::Transform(), | 97 gfx::Transform(), |
(...skipping 16 matching lines...) Expand all Loading... |
114 EndTest(); | 114 EndTest(); |
115 } | 115 } |
116 }; | 116 }; |
117 | 117 |
118 class CalcDrawPropsImplTest : public LayerTreeHostCommonPerfTest { | 118 class CalcDrawPropsImplTest : public LayerTreeHostCommonPerfTest { |
119 public: | 119 public: |
120 void RunCalcDrawProps() { | 120 void RunCalcDrawProps() { |
121 RunTestWithImplSidePainting(); | 121 RunTestWithImplSidePainting(); |
122 } | 122 } |
123 | 123 |
124 virtual void BeginTest() override { | 124 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
125 PostSetNeedsCommitToMainThread(); | |
126 } | |
127 | 125 |
128 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 126 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
129 timer_.Reset(); | 127 timer_.Reset(); |
130 LayerTreeImpl* active_tree = host_impl->active_tree(); | 128 LayerTreeImpl* active_tree = host_impl->active_tree(); |
131 | 129 |
132 do { | 130 do { |
133 bool can_render_to_separate_surface = true; | 131 bool can_render_to_separate_surface = true; |
134 int max_texture_size = 8096; | 132 int max_texture_size = 8096; |
135 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | 133 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, |
136 max_texture_size, | 134 max_texture_size, |
137 active_tree, | 135 active_tree, |
138 host_impl); | 136 host_impl); |
(...skipping 23 matching lines...) Expand all Loading... |
162 &update_list, | 160 &update_list, |
163 0); | 161 0); |
164 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 162 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
165 } | 163 } |
166 }; | 164 }; |
167 | 165 |
168 class LayerSorterMainTest : public CalcDrawPropsImplTest { | 166 class LayerSorterMainTest : public CalcDrawPropsImplTest { |
169 public: | 167 public: |
170 void RunSortLayers() { RunTest(false, false, false); } | 168 void RunSortLayers() { RunTest(false, false, false); } |
171 | 169 |
172 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 170 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
173 | 171 |
174 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 172 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
175 LayerTreeImpl* active_tree = host_impl->active_tree(); | 173 LayerTreeImpl* active_tree = host_impl->active_tree(); |
176 // First build the tree and then we'll start running tests on layersorter | 174 // First build the tree and then we'll start running tests on layersorter |
177 // itself | 175 // itself |
178 bool can_render_to_separate_surface = true; | 176 bool can_render_to_separate_surface = true; |
179 int max_texture_size = 8096; | 177 int max_texture_size = 8096; |
180 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | 178 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, |
181 max_texture_size, | 179 max_texture_size, |
182 active_tree, | 180 active_tree, |
183 host_impl); | 181 host_impl); |
184 | 182 |
(...skipping 29 matching lines...) Expand all Loading... |
214 }; | 212 }; |
215 | 213 |
216 class BspTreePerfTest : public LayerSorterMainTest { | 214 class BspTreePerfTest : public LayerSorterMainTest { |
217 public: | 215 public: |
218 void RunSortLayers() { RunTest(false, false, false); } | 216 void RunSortLayers() { RunTest(false, false, false); } |
219 | 217 |
220 void SetNumberOfDuplicates(int num_duplicates) { | 218 void SetNumberOfDuplicates(int num_duplicates) { |
221 num_duplicates_ = num_duplicates; | 219 num_duplicates_ = num_duplicates; |
222 } | 220 } |
223 | 221 |
224 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 222 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
225 | 223 |
226 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 224 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
227 LayerTreeImpl* active_tree = host_impl->active_tree(); | 225 LayerTreeImpl* active_tree = host_impl->active_tree(); |
228 // First build the tree and then we'll start running tests on layersorter | 226 // First build the tree and then we'll start running tests on layersorter |
229 // itself | 227 // itself |
230 bool can_render_to_separate_surface = true; | 228 bool can_render_to_separate_surface = true; |
231 int max_texture_size = 8096; | 229 int max_texture_size = 8096; |
232 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | 230 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, |
233 max_texture_size, | 231 max_texture_size, |
234 active_tree, | 232 active_tree, |
235 host_impl); | 233 host_impl); |
236 | 234 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 349 |
352 TEST_F(BspTreePerfTest, BspTreeCubes_4) { | 350 TEST_F(BspTreePerfTest, BspTreeCubes_4) { |
353 SetTestName("bsp_tree_cubes_4"); | 351 SetTestName("bsp_tree_cubes_4"); |
354 SetNumberOfDuplicates(4); | 352 SetNumberOfDuplicates(4); |
355 ReadTestFile("layer_sort_cubes"); | 353 ReadTestFile("layer_sort_cubes"); |
356 RunSortLayers(); | 354 RunSortLayers(); |
357 } | 355 } |
358 | 356 |
359 } // namespace | 357 } // namespace |
360 } // namespace cc | 358 } // namespace cc |
OLD | NEW |