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

Side by Side Diff: cc/layers/picture_layer_impl_perftest.cc

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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/layers/picture_layer_impl.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/layers/picture_layer_impl.h"
6
7 #include "cc/debug/lap_timer.h"
8 #include "cc/resources/tiling_set_raster_queue_all.h"
9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h"
11 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/fake_picture_layer_impl.h"
13 #include "cc/test/fake_picture_pile_impl.h"
14 #include "cc/test/impl_side_painting_settings.h"
15 #include "cc/test/test_shared_bitmap_manager.h"
16 #include "cc/test/test_task_graph_runner.h"
17 #include "cc/trees/layer_tree_impl.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "testing/perf/perf_test.h"
20
21 namespace cc {
22 namespace {
23
24 static const int kTimeLimitMillis = 2000;
25 static const int kWarmupRuns = 5;
26 static const int kTimeCheckInterval = 10;
27
28 void AddTiling(float scale,
29 FakePictureLayerImpl* layer,
30 std::vector<Tile*>* all_tiles) {
31 PictureLayerTiling* tiling = layer->AddTiling(scale);
32
33 tiling->CreateAllTilesForTesting();
34 std::vector<Tile*> tiling_tiles = tiling->AllTilesForTesting();
35 std::copy(
36 tiling_tiles.begin(), tiling_tiles.end(), std::back_inserter(*all_tiles));
37 }
38
39 class PictureLayerImplPerfTest : public testing::Test {
40 public:
41 PictureLayerImplPerfTest()
42 : proxy_(base::MessageLoopProxy::current()),
43 host_impl_(ImplSidePaintingSettings(),
44 &proxy_,
45 &shared_bitmap_manager_,
46 &task_graph_runner_),
47 timer_(kWarmupRuns,
48 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
49 kTimeCheckInterval) {}
50
51 void SetUp() override {
52 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d());
53 }
54
55 void SetupPendingTree(const gfx::Size& layer_bounds,
56 const gfx::Size& tile_size) {
57 scoped_refptr<FakePicturePileImpl> pile =
58 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
59 host_impl_.CreatePendingTree();
60 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
61 pending_tree->DetachLayerTree();
62
63 scoped_ptr<FakePictureLayerImpl> pending_layer =
64 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, 7, pile);
65 pending_layer->SetDrawsContent(true);
66 pending_layer->SetHasRenderSurface(true);
67 pending_tree->SetRootLayer(pending_layer.Pass());
68
69 pending_layer_ = static_cast<FakePictureLayerImpl*>(
70 host_impl_.pending_tree()->LayerById(7));
71 }
72
73 void RunRasterQueueConstructAndIterateTest(const std::string& test_name,
74 int num_tiles,
75 const gfx::Size& viewport_size) {
76 host_impl_.SetViewportSize(viewport_size);
77 bool update_lcd_text = false;
78 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
79
80 timer_.Reset();
81 do {
82 int count = num_tiles;
83 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
84 pending_layer_->picture_layer_tiling_set(), false));
85 while (count--) {
86 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count;
87 ASSERT_TRUE(queue->Top() != nullptr) << "count: " << count;
88 queue->Pop();
89 }
90 timer_.NextLap();
91 } while (!timer_.HasTimeLimitExpired());
92
93 perf_test::PrintResult("tiling_set_raster_queue_construct_and_iterate", "",
94 test_name, timer_.LapsPerSecond(), "runs/s", true);
95 }
96
97 void RunRasterQueueConstructTest(const std::string& test_name,
98 const gfx::Rect& viewport) {
99 host_impl_.SetViewportSize(viewport.size());
100 pending_layer_->PushScrollOffsetFromMainThread(
101 gfx::ScrollOffset(viewport.x(), viewport.y()));
102 bool update_lcd_text = false;
103 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
104
105 timer_.Reset();
106 do {
107 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
108 pending_layer_->picture_layer_tiling_set(), false));
109 timer_.NextLap();
110 } while (!timer_.HasTimeLimitExpired());
111
112 perf_test::PrintResult("tiling_set_raster_queue_construct", "", test_name,
113 timer_.LapsPerSecond(), "runs/s", true);
114 }
115
116 void RunEvictionQueueConstructAndIterateTest(
117 const std::string& test_name,
118 int num_tiles,
119 const gfx::Size& viewport_size) {
120 host_impl_.SetViewportSize(viewport_size);
121 bool update_lcd_text = false;
122 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
123
124 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
125 SMOOTHNESS_TAKES_PRIORITY,
126 NEW_CONTENT_TAKES_PRIORITY};
127 int priority_count = 0;
128 timer_.Reset();
129 do {
130 int count = num_tiles;
131 scoped_ptr<TilingSetEvictionQueue> queue(
132 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set(),
133 priorities[priority_count], false));
134 while (count--) {
135 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count;
136 ASSERT_TRUE(queue->Top() != nullptr) << "count: " << count;
137 queue->Pop();
138 }
139 priority_count = (priority_count + 1) % arraysize(priorities);
140 timer_.NextLap();
141 } while (!timer_.HasTimeLimitExpired());
142
143 perf_test::PrintResult("tiling_set_eviction_queue_construct_and_iterate",
144 "", test_name, timer_.LapsPerSecond(), "runs/s",
145 true);
146 }
147
148 void RunEvictionQueueConstructTest(const std::string& test_name,
149 const gfx::Rect& viewport) {
150 host_impl_.SetViewportSize(viewport.size());
151 pending_layer_->PushScrollOffsetFromMainThread(
152 gfx::ScrollOffset(viewport.x(), viewport.y()));
153 bool update_lcd_text = false;
154 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
155
156 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
157 SMOOTHNESS_TAKES_PRIORITY,
158 NEW_CONTENT_TAKES_PRIORITY};
159 int priority_count = 0;
160 timer_.Reset();
161 do {
162 scoped_ptr<TilingSetEvictionQueue> queue(
163 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set(),
164 priorities[priority_count], false));
165 priority_count = (priority_count + 1) % arraysize(priorities);
166 timer_.NextLap();
167 } while (!timer_.HasTimeLimitExpired());
168
169 perf_test::PrintResult("tiling_set_eviction_queue_construct", "", test_name,
170 timer_.LapsPerSecond(), "runs/s", true);
171 }
172
173 protected:
174 TestSharedBitmapManager shared_bitmap_manager_;
175 TestTaskGraphRunner task_graph_runner_;
176 FakeImplProxy proxy_;
177 FakeLayerTreeHostImpl host_impl_;
178 FakePictureLayerImpl* pending_layer_;
179 LapTimer timer_;
180
181 private:
182 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest);
183 };
184
185 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) {
186 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256));
187
188 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
189
190 pending_layer_->AddTiling(low_res_factor);
191 pending_layer_->AddTiling(0.3f);
192 pending_layer_->AddTiling(0.7f);
193 pending_layer_->AddTiling(1.0f);
194 pending_layer_->AddTiling(2.0f);
195
196 RunRasterQueueConstructAndIterateTest("32_100x100", 32, gfx::Size(100, 100));
197 RunRasterQueueConstructAndIterateTest("32_500x500", 32, gfx::Size(500, 500));
198 RunRasterQueueConstructAndIterateTest("64_100x100", 64, gfx::Size(100, 100));
199 RunRasterQueueConstructAndIterateTest("64_500x500", 64, gfx::Size(500, 500));
200 }
201
202 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) {
203 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256));
204
205 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
206
207 pending_layer_->AddTiling(low_res_factor);
208 pending_layer_->AddTiling(0.3f);
209 pending_layer_->AddTiling(0.7f);
210 pending_layer_->AddTiling(1.0f);
211 pending_layer_->AddTiling(2.0f);
212
213 RunRasterQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
214 RunRasterQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100));
215 RunRasterQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100));
216 }
217
218 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) {
219 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256));
220
221 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
222
223 std::vector<Tile*> all_tiles;
224 AddTiling(low_res_factor, pending_layer_, &all_tiles);
225 AddTiling(0.3f, pending_layer_, &all_tiles);
226 AddTiling(0.7f, pending_layer_, &all_tiles);
227 AddTiling(1.0f, pending_layer_, &all_tiles);
228 AddTiling(2.0f, pending_layer_, &all_tiles);
229
230 ASSERT_TRUE(host_impl_.tile_manager() != nullptr);
231 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
232
233 RunEvictionQueueConstructAndIterateTest(
234 "32_100x100", 32, gfx::Size(100, 100));
235 RunEvictionQueueConstructAndIterateTest(
236 "32_500x500", 32, gfx::Size(500, 500));
237 RunEvictionQueueConstructAndIterateTest(
238 "64_100x100", 64, gfx::Size(100, 100));
239 RunEvictionQueueConstructAndIterateTest(
240 "64_500x500", 64, gfx::Size(500, 500));
241 }
242
243 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) {
244 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256));
245
246 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
247
248 std::vector<Tile*> all_tiles;
249 AddTiling(low_res_factor, pending_layer_, &all_tiles);
250 AddTiling(0.3f, pending_layer_, &all_tiles);
251 AddTiling(0.7f, pending_layer_, &all_tiles);
252 AddTiling(1.0f, pending_layer_, &all_tiles);
253 AddTiling(2.0f, pending_layer_, &all_tiles);
254
255 ASSERT_TRUE(host_impl_.tile_manager() != nullptr);
256 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
257
258 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
259 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100));
260 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100));
261 }
262
263 } // namespace
264 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698