OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "cc/debug/lap_timer.h" | 8 #include "cc/debug/lap_timer.h" |
| 9 #include "cc/test/fake_display_list_raster_source.h" |
9 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
11 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_picture_layer_impl.h" | 13 #include "cc/test/fake_picture_layer_impl.h" |
13 #include "cc/test/fake_picture_pile_impl.h" | |
14 #include "cc/test/test_shared_bitmap_manager.h" | 14 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "cc/test/test_task_graph_runner.h" | 15 #include "cc/test/test_task_graph_runner.h" |
16 #include "cc/tiles/tiling_set_raster_queue_all.h" | 16 #include "cc/tiles/tiling_set_raster_queue_all.h" |
17 #include "cc/trees/layer_tree_impl.h" | 17 #include "cc/trees/layer_tree_impl.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "testing/perf/perf_test.h" | 19 #include "testing/perf/perf_test.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 namespace { | 22 namespace { |
23 | 23 |
(...skipping 22 matching lines...) Expand all Loading... |
46 &shared_bitmap_manager_, | 46 &shared_bitmap_manager_, |
47 &task_graph_runner_), | 47 &task_graph_runner_), |
48 timer_(kWarmupRuns, | 48 timer_(kWarmupRuns, |
49 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 49 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
50 kTimeCheckInterval) {} | 50 kTimeCheckInterval) {} |
51 | 51 |
52 void SetUp() override { | 52 void SetUp() override { |
53 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 53 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
54 } | 54 } |
55 | 55 |
56 void SetupActiveTree(const gfx::Size& layer_bounds, | 56 void SetupActiveTree(const gfx::Size& layer_bounds) { |
57 const gfx::Size& tile_size) { | 57 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
58 scoped_refptr<FakePicturePileImpl> pile = | 58 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
59 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
60 LayerTreeImpl* active_tree = host_impl_.active_tree(); | 59 LayerTreeImpl* active_tree = host_impl_.active_tree(); |
61 active_tree->DetachLayerTree(); | 60 active_tree->DetachLayerTree(); |
62 | 61 |
63 scoped_ptr<FakePictureLayerImpl> active_layer = | 62 scoped_ptr<FakePictureLayerImpl> active_layer = |
64 FakePictureLayerImpl::CreateWithRasterSource(active_tree, 7, pile); | 63 FakePictureLayerImpl::CreateWithRasterSource(active_tree, 7, |
| 64 raster_source); |
65 active_layer->SetDrawsContent(true); | 65 active_layer->SetDrawsContent(true); |
66 active_layer->SetHasRenderSurface(true); | 66 active_layer->SetHasRenderSurface(true); |
67 active_tree->SetRootLayer(active_layer.Pass()); | 67 active_tree->SetRootLayer(active_layer.Pass()); |
68 | 68 |
69 active_layer_ = static_cast<FakePictureLayerImpl*>( | 69 active_layer_ = static_cast<FakePictureLayerImpl*>( |
70 host_impl_.active_tree()->LayerById(7)); | 70 host_impl_.active_tree()->LayerById(7)); |
71 } | 71 } |
72 | 72 |
73 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, | 73 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, |
74 int num_tiles, | 74 int num_tiles, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 FakeImplProxy proxy_; | 166 FakeImplProxy proxy_; |
167 FakeLayerTreeHostImpl host_impl_; | 167 FakeLayerTreeHostImpl host_impl_; |
168 FakePictureLayerImpl* active_layer_; | 168 FakePictureLayerImpl* active_layer_; |
169 LapTimer timer_; | 169 LapTimer timer_; |
170 | 170 |
171 private: | 171 private: |
172 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); | 172 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); |
173 }; | 173 }; |
174 | 174 |
175 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) { | 175 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) { |
176 SetupActiveTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); | 176 SetupActiveTree(gfx::Size(10000, 10000)); |
177 | 177 |
178 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 178 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
179 | 179 |
180 active_layer_->AddTiling(low_res_factor); | 180 active_layer_->AddTiling(low_res_factor); |
181 active_layer_->AddTiling(0.3f); | 181 active_layer_->AddTiling(0.3f); |
182 active_layer_->AddTiling(0.7f); | 182 active_layer_->AddTiling(0.7f); |
183 active_layer_->AddTiling(1.0f); | 183 active_layer_->AddTiling(1.0f); |
184 active_layer_->AddTiling(2.0f); | 184 active_layer_->AddTiling(2.0f); |
185 | 185 |
186 RunRasterQueueConstructAndIterateTest("32_100x100", 32, gfx::Size(100, 100)); | 186 RunRasterQueueConstructAndIterateTest("32_100x100", 32, gfx::Size(100, 100)); |
187 RunRasterQueueConstructAndIterateTest("32_500x500", 32, gfx::Size(500, 500)); | 187 RunRasterQueueConstructAndIterateTest("32_500x500", 32, gfx::Size(500, 500)); |
188 RunRasterQueueConstructAndIterateTest("64_100x100", 64, gfx::Size(100, 100)); | 188 RunRasterQueueConstructAndIterateTest("64_100x100", 64, gfx::Size(100, 100)); |
189 RunRasterQueueConstructAndIterateTest("64_500x500", 64, gfx::Size(500, 500)); | 189 RunRasterQueueConstructAndIterateTest("64_500x500", 64, gfx::Size(500, 500)); |
190 } | 190 } |
191 | 191 |
192 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) { | 192 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) { |
193 SetupActiveTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); | 193 SetupActiveTree(gfx::Size(10000, 10000)); |
194 | 194 |
195 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 195 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
196 | 196 |
197 active_layer_->AddTiling(low_res_factor); | 197 active_layer_->AddTiling(low_res_factor); |
198 active_layer_->AddTiling(0.3f); | 198 active_layer_->AddTiling(0.3f); |
199 active_layer_->AddTiling(0.7f); | 199 active_layer_->AddTiling(0.7f); |
200 active_layer_->AddTiling(1.0f); | 200 active_layer_->AddTiling(1.0f); |
201 active_layer_->AddTiling(2.0f); | 201 active_layer_->AddTiling(2.0f); |
202 | 202 |
203 RunRasterQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); | 203 RunRasterQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
204 RunRasterQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); | 204 RunRasterQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); |
205 RunRasterQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); | 205 RunRasterQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); |
206 } | 206 } |
207 | 207 |
208 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) { | 208 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) { |
209 SetupActiveTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); | 209 SetupActiveTree(gfx::Size(10000, 10000)); |
210 | 210 |
211 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 211 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
212 | 212 |
213 std::vector<Tile*> all_tiles; | 213 std::vector<Tile*> all_tiles; |
214 AddTiling(low_res_factor, active_layer_, &all_tiles); | 214 AddTiling(low_res_factor, active_layer_, &all_tiles); |
215 AddTiling(0.3f, active_layer_, &all_tiles); | 215 AddTiling(0.3f, active_layer_, &all_tiles); |
216 AddTiling(0.7f, active_layer_, &all_tiles); | 216 AddTiling(0.7f, active_layer_, &all_tiles); |
217 AddTiling(1.0f, active_layer_, &all_tiles); | 217 AddTiling(1.0f, active_layer_, &all_tiles); |
218 AddTiling(2.0f, active_layer_, &all_tiles); | 218 AddTiling(2.0f, active_layer_, &all_tiles); |
219 | 219 |
220 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); | 220 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); |
221 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 221 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
222 | 222 |
223 RunEvictionQueueConstructAndIterateTest( | 223 RunEvictionQueueConstructAndIterateTest( |
224 "32_100x100", 32, gfx::Size(100, 100)); | 224 "32_100x100", 32, gfx::Size(100, 100)); |
225 RunEvictionQueueConstructAndIterateTest( | 225 RunEvictionQueueConstructAndIterateTest( |
226 "32_500x500", 32, gfx::Size(500, 500)); | 226 "32_500x500", 32, gfx::Size(500, 500)); |
227 RunEvictionQueueConstructAndIterateTest( | 227 RunEvictionQueueConstructAndIterateTest( |
228 "64_100x100", 64, gfx::Size(100, 100)); | 228 "64_100x100", 64, gfx::Size(100, 100)); |
229 RunEvictionQueueConstructAndIterateTest( | 229 RunEvictionQueueConstructAndIterateTest( |
230 "64_500x500", 64, gfx::Size(500, 500)); | 230 "64_500x500", 64, gfx::Size(500, 500)); |
231 } | 231 } |
232 | 232 |
233 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) { | 233 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) { |
234 SetupActiveTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); | 234 SetupActiveTree(gfx::Size(10000, 10000)); |
235 | 235 |
236 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 236 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
237 | 237 |
238 std::vector<Tile*> all_tiles; | 238 std::vector<Tile*> all_tiles; |
239 AddTiling(low_res_factor, active_layer_, &all_tiles); | 239 AddTiling(low_res_factor, active_layer_, &all_tiles); |
240 AddTiling(0.3f, active_layer_, &all_tiles); | 240 AddTiling(0.3f, active_layer_, &all_tiles); |
241 AddTiling(0.7f, active_layer_, &all_tiles); | 241 AddTiling(0.7f, active_layer_, &all_tiles); |
242 AddTiling(1.0f, active_layer_, &all_tiles); | 242 AddTiling(1.0f, active_layer_, &all_tiles); |
243 AddTiling(2.0f, active_layer_, &all_tiles); | 243 AddTiling(2.0f, active_layer_, &all_tiles); |
244 | 244 |
245 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); | 245 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); |
246 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 246 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
247 | 247 |
248 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); | 248 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
249 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); | 249 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); |
250 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); | 250 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); |
251 } | 251 } |
252 | 252 |
253 } // namespace | 253 } // namespace |
254 } // namespace cc | 254 } // namespace cc |
OLD | NEW |