Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: cc/trees/layer_tree_host_common_perftest.cc

Issue 416273002: BSP Tree perf tests to match LayerSorter perf tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/quads/draw_polygon.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_deque.h"
17 #include "cc/base/scoped_ptr_vector.h"
15 #include "cc/debug/lap_timer.h" 18 #include "cc/debug/lap_timer.h"
16 #include "cc/layers/layer.h" 19 #include "cc/layers/layer.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"
24 #include "testing/perf/perf_test.h" 30 #include "testing/perf/perf_test.h"
25 31
26 namespace cc { 32 namespace cc {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } while (!timer_.HasTimeLimitExpired()); 196 } while (!timer_.HasTimeLimitExpired());
191 197
192 EndTest(); 198 EndTest();
193 } 199 }
194 200
195 void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) { 201 void BuildLayerImplList(LayerImpl* layer, LayerImplList* list) {
196 if (layer->Is3dSorted()) { 202 if (layer->Is3dSorted()) {
197 list->push_back(layer); 203 list->push_back(layer);
198 } 204 }
199 205
200 for (unsigned int i = 0; i < layer->children().size(); i++) { 206 for (size_t i = 0; i < layer->children().size(); i++) {
201 BuildLayerImplList(layer->children()[i], list); 207 BuildLayerImplList(layer->children()[i], list);
202 } 208 }
203 } 209 }
204 210
205 private: 211 private:
206 LayerImplList base_list_; 212 LayerImplList base_list_;
207 LayerSorter layer_sorter_; 213 LayerSorter layer_sorter_;
208 }; 214 };
209 215
216 class BspTreePerfTest : public LayerSorterMainTest {
217 public:
218 void RunSortLayers() { RunTest(false, false, false); }
219
220 void SetNumberOfDuplicates(int num_duplicates) {
221 num_duplicates_ = num_duplicates;
222 }
223
224 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
225
226 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
227 LayerTreeImpl* active_tree = host_impl->active_tree();
228 // First build the tree and then we'll start running tests on layersorter
229 // itself
230 bool can_render_to_separate_surface = true;
231 int max_texture_size = 8096;
232 DoCalcDrawPropertiesImpl(can_render_to_separate_surface,
233 max_texture_size,
234 active_tree,
235 host_impl);
236
237 LayerImplList base_list;
238 BuildLayerImplList(active_tree->root_layer(), &base_list);
239
240 int polygon_counter = 0;
241 ScopedPtrVector<DrawPolygon> polygon_list;
242 for (LayerImplList::iterator it = base_list.begin(); it != base_list.end();
243 ++it) {
244 DrawPolygon* draw_polygon = new DrawPolygon(NULL,
245 gfx::RectF((*it)->bounds()),
enne (OOO) 2014/07/31 00:18:04 I lied. This should be content bounds and not nor
troyhildebrandt 2014/07/31 18:32:38 Done.
246 (*it)->draw_transform(),
247 polygon_counter++);
248 polygon_list.push_back(scoped_ptr<DrawPolygon>(draw_polygon));
249 }
250
251 timer_.Reset();
252 do {
253 ScopedPtrDeque<DrawPolygon> test_list;
254 for (int i = 0; i < num_duplicates_; i++) {
255 for (size_t i = 0; i < polygon_list.size(); i++) {
256 test_list.push_back(polygon_list[i]->CreateCopy());
257 }
258 }
259 BspTree bsp_tree(&test_list);
260 timer_.NextLap();
261 } while (!timer_.HasTimeLimitExpired());
262
263 EndTest();
264 }
265
266 private:
267 int num_duplicates_;
268 };
269
210 TEST_F(CalcDrawPropsMainTest, TenTen) { 270 TEST_F(CalcDrawPropsMainTest, TenTen) {
211 SetTestName("10_10_main_thread"); 271 SetTestName("10_10_main_thread");
212 ReadTestFile("10_10_layer_tree"); 272 ReadTestFile("10_10_layer_tree");
213 RunCalcDrawProps(); 273 RunCalcDrawProps();
214 } 274 }
215 275
216 TEST_F(CalcDrawPropsMainTest, HeavyPage) { 276 TEST_F(CalcDrawPropsMainTest, HeavyPage) {
217 SetTestName("heavy_page_main_thread"); 277 SetTestName("heavy_page_main_thread");
218 ReadTestFile("heavy_layer_tree"); 278 ReadTestFile("heavy_layer_tree");
219 RunCalcDrawProps(); 279 RunCalcDrawProps();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 ReadTestFile("layer_sort_cubes"); 320 ReadTestFile("layer_sort_cubes");
261 RunSortLayers(); 321 RunSortLayers();
262 } 322 }
263 323
264 TEST_F(LayerSorterMainTest, LayerSorterRubik) { 324 TEST_F(LayerSorterMainTest, LayerSorterRubik) {
265 SetTestName("layer_sort_rubik"); 325 SetTestName("layer_sort_rubik");
266 ReadTestFile("layer_sort_rubik"); 326 ReadTestFile("layer_sort_rubik");
267 RunSortLayers(); 327 RunSortLayers();
268 } 328 }
269 329
330 TEST_F(BspTreePerfTest, BspTreeCubes) {
331 SetTestName("bsp_tree_cubes");
332 SetNumberOfDuplicates(1);
333 ReadTestFile("layer_sort_cubes");
334 RunSortLayers();
335 }
336
337 TEST_F(BspTreePerfTest, BspTreeRubik) {
338 SetTestName("bsp_tree_rubik");
339 SetNumberOfDuplicates(1);
340 ReadTestFile("layer_sort_rubik");
341 RunSortLayers();
342 }
343
344 TEST_F(BspTreePerfTest, BspTreeCubes_2) {
345 SetTestName("bsp_tree_cubes_2");
346 SetNumberOfDuplicates(2);
347 ReadTestFile("layer_sort_cubes");
348 RunSortLayers();
349 }
350
351 TEST_F(BspTreePerfTest, BspTreeCubes_4) {
352 SetTestName("bsp_tree_cubes_4");
353 SetNumberOfDuplicates(4);
354 ReadTestFile("layer_sort_cubes");
355 RunSortLayers();
356 }
357
270 } // namespace 358 } // namespace
271 } // namespace cc 359 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/draw_polygon.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698