| 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 "cc/debug/lap_timer.h" | 7 #include "cc/debug/lap_timer.h" |
| 8 #include "cc/test/fake_impl_proxy.h" | 8 #include "cc/test/fake_impl_proxy.h" |
| 9 #include "cc/test/fake_layer_tree_host_impl.h" | 9 #include "cc/test/fake_layer_tree_host_impl.h" |
| 10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } while (!timer_.HasTimeLimitExpired()); | 108 } while (!timer_.HasTimeLimitExpired()); |
| 109 | 109 |
| 110 perf_test::PrintResult("layer_raster_tile_iterator_construct", | 110 perf_test::PrintResult("layer_raster_tile_iterator_construct", |
| 111 "", | 111 "", |
| 112 test_name, | 112 test_name, |
| 113 timer_.LapsPerSecond(), | 113 timer_.LapsPerSecond(), |
| 114 "runs/s", | 114 "runs/s", |
| 115 true); | 115 true); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void RunEvictionIteratorConstructAndIterateTest( | 118 void RunEvictionQueueConstructAndIterateTest( |
| 119 const std::string& test_name, | 119 const std::string& test_name, |
| 120 int num_tiles, | 120 int num_tiles, |
| 121 const gfx::Size& viewport_size) { | 121 const gfx::Size& viewport_size) { |
| 122 host_impl_.SetViewportSize(viewport_size); | 122 host_impl_.SetViewportSize(viewport_size); |
| 123 host_impl_.pending_tree()->UpdateDrawProperties(); | 123 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 124 | 124 |
| 125 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 125 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 126 SMOOTHNESS_TAKES_PRIORITY, | 126 SMOOTHNESS_TAKES_PRIORITY, |
| 127 NEW_CONTENT_TAKES_PRIORITY}; | 127 NEW_CONTENT_TAKES_PRIORITY}; |
| 128 int priority_count = 0; | 128 int priority_count = 0; |
| 129 timer_.Reset(); | 129 timer_.Reset(); |
| 130 do { | 130 do { |
| 131 int count = num_tiles; | 131 int count = num_tiles; |
| 132 PictureLayerImpl::LayerEvictionTileIterator it( | 132 scoped_ptr<TilingSetEvictionQueue> queue = |
| 133 pending_layer_, priorities[priority_count]); | 133 pending_layer_->CreateEvictionQueue(priorities[priority_count]); |
| 134 while (count--) { | 134 while (count--) { |
| 135 ASSERT_TRUE(it) << "count: " << count; | 135 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count; |
| 136 ASSERT_TRUE(*it != nullptr) << "count: " << count; | 136 ASSERT_TRUE(queue->Top() != nullptr) << "count: " << count; |
| 137 ++it; | 137 queue->Pop(); |
| 138 } | 138 } |
| 139 priority_count = (priority_count + 1) % arraysize(priorities); | 139 priority_count = (priority_count + 1) % arraysize(priorities); |
| 140 timer_.NextLap(); | 140 timer_.NextLap(); |
| 141 } while (!timer_.HasTimeLimitExpired()); | 141 } while (!timer_.HasTimeLimitExpired()); |
| 142 | 142 |
| 143 perf_test::PrintResult("layer_eviction_tile_iterator_construct_and_iterate", | 143 perf_test::PrintResult("layer_eviction_tile_iterator_construct_and_iterate", |
| 144 "", | 144 "", |
| 145 test_name, | 145 test_name, |
| 146 timer_.LapsPerSecond(), | 146 timer_.LapsPerSecond(), |
| 147 "runs/s", | 147 "runs/s", |
| 148 true); | 148 true); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void RunEvictionIteratorConstructTest(const std::string& test_name, | 151 void RunEvictionQueueConstructTest(const std::string& test_name, |
| 152 const gfx::Rect& viewport) { | 152 const gfx::Rect& viewport) { |
| 153 host_impl_.SetViewportSize(viewport.size()); | 153 host_impl_.SetViewportSize(viewport.size()); |
| 154 pending_layer_->SetScrollOffset( | 154 pending_layer_->SetScrollOffset( |
| 155 gfx::ScrollOffset(viewport.x(), viewport.y())); | 155 gfx::ScrollOffset(viewport.x(), viewport.y())); |
| 156 host_impl_.pending_tree()->UpdateDrawProperties(); | 156 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 157 | 157 |
| 158 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 158 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 159 SMOOTHNESS_TAKES_PRIORITY, | 159 SMOOTHNESS_TAKES_PRIORITY, |
| 160 NEW_CONTENT_TAKES_PRIORITY}; | 160 NEW_CONTENT_TAKES_PRIORITY}; |
| 161 int priority_count = 0; | 161 int priority_count = 0; |
| 162 timer_.Reset(); | 162 timer_.Reset(); |
| 163 do { | 163 do { |
| 164 PictureLayerImpl::LayerEvictionTileIterator it( | 164 scoped_ptr<TilingSetEvictionQueue> queue = |
| 165 pending_layer_, priorities[priority_count]); | 165 pending_layer_->CreateEvictionQueue(priorities[priority_count]); |
| 166 priority_count = (priority_count + 1) % arraysize(priorities); | 166 priority_count = (priority_count + 1) % arraysize(priorities); |
| 167 timer_.NextLap(); | 167 timer_.NextLap(); |
| 168 } while (!timer_.HasTimeLimitExpired()); | 168 } while (!timer_.HasTimeLimitExpired()); |
| 169 | 169 |
| 170 perf_test::PrintResult("layer_eviction_tile_iterator_construct", | 170 perf_test::PrintResult("layer_eviction_tile_iterator_construct", |
| 171 "", | 171 "", |
| 172 test_name, | 172 test_name, |
| 173 timer_.LapsPerSecond(), | 173 timer_.LapsPerSecond(), |
| 174 "runs/s", | 174 "runs/s", |
| 175 true); | 175 true); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 pending_layer_->AddTiling(1.0f); | 218 pending_layer_->AddTiling(1.0f); |
| 219 pending_layer_->AddTiling(2.0f); | 219 pending_layer_->AddTiling(2.0f); |
| 220 | 220 |
| 221 RunRasterIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); | 221 RunRasterIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
| 222 RunRasterIteratorConstructTest("5000_0_100x100", | 222 RunRasterIteratorConstructTest("5000_0_100x100", |
| 223 gfx::Rect(5000, 0, 100, 100)); | 223 gfx::Rect(5000, 0, 100, 100)); |
| 224 RunRasterIteratorConstructTest("9999_0_100x100", | 224 RunRasterIteratorConstructTest("9999_0_100x100", |
| 225 gfx::Rect(9999, 0, 100, 100)); | 225 gfx::Rect(9999, 0, 100, 100)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 // TODO(e_hakkinen): Rename these tests once the perf numbers are in. |
| 228 TEST_F(PictureLayerImplPerfTest, LayerEvictionTileIteratorConstructAndIterate) { | 229 TEST_F(PictureLayerImplPerfTest, LayerEvictionTileIteratorConstructAndIterate) { |
| 229 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); | 230 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); |
| 230 | 231 |
| 231 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 232 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 232 | 233 |
| 233 std::vector<Tile*> all_tiles; | 234 std::vector<Tile*> all_tiles; |
| 234 AddTiling(low_res_factor, pending_layer_, &all_tiles); | 235 AddTiling(low_res_factor, pending_layer_, &all_tiles); |
| 235 AddTiling(0.3f, pending_layer_, &all_tiles); | 236 AddTiling(0.3f, pending_layer_, &all_tiles); |
| 236 AddTiling(0.7f, pending_layer_, &all_tiles); | 237 AddTiling(0.7f, pending_layer_, &all_tiles); |
| 237 AddTiling(1.0f, pending_layer_, &all_tiles); | 238 AddTiling(1.0f, pending_layer_, &all_tiles); |
| 238 AddTiling(2.0f, pending_layer_, &all_tiles); | 239 AddTiling(2.0f, pending_layer_, &all_tiles); |
| 239 | 240 |
| 240 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); | 241 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); |
| 241 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 242 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 242 | 243 |
| 243 RunEvictionIteratorConstructAndIterateTest( | 244 RunEvictionQueueConstructAndIterateTest( |
| 244 "32_100x100", 32, gfx::Size(100, 100)); | 245 "32_100x100", 32, gfx::Size(100, 100)); |
| 245 RunEvictionIteratorConstructAndIterateTest( | 246 RunEvictionQueueConstructAndIterateTest( |
| 246 "32_500x500", 32, gfx::Size(500, 500)); | 247 "32_500x500", 32, gfx::Size(500, 500)); |
| 247 RunEvictionIteratorConstructAndIterateTest( | 248 RunEvictionQueueConstructAndIterateTest( |
| 248 "64_100x100", 64, gfx::Size(100, 100)); | 249 "64_100x100", 64, gfx::Size(100, 100)); |
| 249 RunEvictionIteratorConstructAndIterateTest( | 250 RunEvictionQueueConstructAndIterateTest( |
| 250 "64_500x500", 64, gfx::Size(500, 500)); | 251 "64_500x500", 64, gfx::Size(500, 500)); |
| 251 } | 252 } |
| 252 | 253 |
| 254 // TODO(e_hakkinen): Rename these tests once the perf numbers are in. |
| 253 TEST_F(PictureLayerImplPerfTest, LayerEvictionTileIteratorConstruct) { | 255 TEST_F(PictureLayerImplPerfTest, LayerEvictionTileIteratorConstruct) { |
| 254 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); | 256 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); |
| 255 | 257 |
| 256 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 258 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 257 | 259 |
| 258 std::vector<Tile*> all_tiles; | 260 std::vector<Tile*> all_tiles; |
| 259 AddTiling(low_res_factor, pending_layer_, &all_tiles); | 261 AddTiling(low_res_factor, pending_layer_, &all_tiles); |
| 260 AddTiling(0.3f, pending_layer_, &all_tiles); | 262 AddTiling(0.3f, pending_layer_, &all_tiles); |
| 261 AddTiling(0.7f, pending_layer_, &all_tiles); | 263 AddTiling(0.7f, pending_layer_, &all_tiles); |
| 262 AddTiling(1.0f, pending_layer_, &all_tiles); | 264 AddTiling(1.0f, pending_layer_, &all_tiles); |
| 263 AddTiling(2.0f, pending_layer_, &all_tiles); | 265 AddTiling(2.0f, pending_layer_, &all_tiles); |
| 264 | 266 |
| 265 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); | 267 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); |
| 266 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 268 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 267 | 269 |
| 268 RunEvictionIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); | 270 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
| 269 RunEvictionIteratorConstructTest("5000_0_100x100", | 271 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); |
| 270 gfx::Rect(5000, 0, 100, 100)); | 272 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); |
| 271 RunEvictionIteratorConstructTest("9999_0_100x100", | |
| 272 gfx::Rect(9999, 0, 100, 100)); | |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace | 275 } // namespace |
| 276 } // namespace cc | 276 } // namespace cc |
| OLD | NEW |