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 virtual 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 virtual 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 virtual 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 virtual void BeginTest() override { |
125 PostSetNeedsCommitToMainThread(); | 125 PostSetNeedsCommitToMainThread(); |
126 } | 126 } |
127 | 127 |
128 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 128 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
129 timer_.Reset(); | 129 timer_.Reset(); |
130 LayerTreeImpl* active_tree = host_impl->active_tree(); | 130 LayerTreeImpl* active_tree = host_impl->active_tree(); |
131 | 131 |
132 do { | 132 do { |
133 bool can_render_to_separate_surface = true; | 133 bool can_render_to_separate_surface = true; |
134 int max_texture_size = 8096; | 134 int max_texture_size = 8096; |
135 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | 135 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, |
136 max_texture_size, | 136 max_texture_size, |
137 active_tree, | 137 active_tree, |
138 host_impl); | 138 host_impl); |
(...skipping 23 matching lines...) Expand all Loading... |
162 &update_list, | 162 &update_list, |
163 0); | 163 0); |
164 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 164 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
165 } | 165 } |
166 }; | 166 }; |
167 | 167 |
168 class LayerSorterMainTest : public CalcDrawPropsImplTest { | 168 class LayerSorterMainTest : public CalcDrawPropsImplTest { |
169 public: | 169 public: |
170 void RunSortLayers() { RunTest(false, false, false); } | 170 void RunSortLayers() { RunTest(false, false, false); } |
171 | 171 |
172 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 172 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
173 | 173 |
174 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 174 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
175 LayerTreeImpl* active_tree = host_impl->active_tree(); | 175 LayerTreeImpl* active_tree = host_impl->active_tree(); |
176 // First build the tree and then we'll start running tests on layersorter | 176 // First build the tree and then we'll start running tests on layersorter |
177 // itself | 177 // itself |
178 bool can_render_to_separate_surface = true; | 178 bool can_render_to_separate_surface = true; |
179 int max_texture_size = 8096; | 179 int max_texture_size = 8096; |
180 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | 180 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, |
181 max_texture_size, | 181 max_texture_size, |
182 active_tree, | 182 active_tree, |
183 host_impl); | 183 host_impl); |
184 | 184 |
(...skipping 29 matching lines...) Expand all Loading... |
214 }; | 214 }; |
215 | 215 |
216 class BspTreePerfTest : public LayerSorterMainTest { | 216 class BspTreePerfTest : public LayerSorterMainTest { |
217 public: | 217 public: |
218 void RunSortLayers() { RunTest(false, false, false); } | 218 void RunSortLayers() { RunTest(false, false, false); } |
219 | 219 |
220 void SetNumberOfDuplicates(int num_duplicates) { | 220 void SetNumberOfDuplicates(int num_duplicates) { |
221 num_duplicates_ = num_duplicates; | 221 num_duplicates_ = num_duplicates; |
222 } | 222 } |
223 | 223 |
224 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 224 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
225 | 225 |
226 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 226 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
227 LayerTreeImpl* active_tree = host_impl->active_tree(); | 227 LayerTreeImpl* active_tree = host_impl->active_tree(); |
228 // First build the tree and then we'll start running tests on layersorter | 228 // First build the tree and then we'll start running tests on layersorter |
229 // itself | 229 // itself |
230 bool can_render_to_separate_surface = true; | 230 bool can_render_to_separate_surface = true; |
231 int max_texture_size = 8096; | 231 int max_texture_size = 8096; |
232 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, | 232 DoCalcDrawPropertiesImpl(can_render_to_separate_surface, |
233 max_texture_size, | 233 max_texture_size, |
234 active_tree, | 234 active_tree, |
235 host_impl); | 235 host_impl); |
236 | 236 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 TEST_F(BspTreePerfTest, BspTreeCubes_4) { | 352 TEST_F(BspTreePerfTest, BspTreeCubes_4) { |
353 SetTestName("bsp_tree_cubes_4"); | 353 SetTestName("bsp_tree_cubes_4"); |
354 SetNumberOfDuplicates(4); | 354 SetNumberOfDuplicates(4); |
355 ReadTestFile("layer_sort_cubes"); | 355 ReadTestFile("layer_sort_cubes"); |
356 RunSortLayers(); | 356 RunSortLayers(); |
357 } | 357 } |
358 | 358 |
359 } // namespace | 359 } // namespace |
360 } // namespace cc | 360 } // namespace cc |
OLD | NEW |