| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "cc/debug/lap_timer.h" | 12 #include "cc/debug/lap_timer.h" |
| 13 #include "cc/raster/raster_buffer.h" | 13 #include "cc/raster/raster_buffer.h" |
| 14 #include "cc/test/begin_frame_args_test.h" | 14 #include "cc/test/begin_frame_args_test.h" |
| 15 #include "cc/test/fake_impl_task_runner_provider.h" | 15 #include "cc/test/fake_impl_task_runner_provider.h" |
| 16 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" |
| 17 #include "cc/test/fake_output_surface.h" | 17 #include "cc/test/fake_output_surface.h" |
| 18 #include "cc/test/fake_output_surface_client.h" | 18 #include "cc/test/fake_output_surface_client.h" |
| 19 #include "cc/test/fake_picture_layer_impl.h" | 19 #include "cc/test/fake_picture_layer_impl.h" |
| 20 #include "cc/test/fake_raster_source.h" | 20 #include "cc/test/fake_raster_source.h" |
| 21 #include "cc/test/fake_tile_manager.h" | 21 #include "cc/test/fake_tile_manager.h" |
| 22 #include "cc/test/fake_tile_manager_client.h" | 22 #include "cc/test/fake_tile_manager_client.h" |
| 23 #include "cc/test/fake_tile_task_manager.h" | 23 #include "cc/test/fake_tile_task_manager.h" |
| 24 #include "cc/test/test_layer_tree_host_base.h" | |
| 25 #include "cc/test/test_shared_bitmap_manager.h" | 24 #include "cc/test/test_shared_bitmap_manager.h" |
| 26 #include "cc/test/test_task_graph_runner.h" | 25 #include "cc/test/test_task_graph_runner.h" |
| 27 #include "cc/test/test_tile_priorities.h" | 26 #include "cc/test/test_tile_priorities.h" |
| 28 #include "cc/tiles/tile.h" | 27 #include "cc/tiles/tile.h" |
| 29 #include "cc/tiles/tile_priority.h" | 28 #include "cc/tiles/tile_priority.h" |
| 30 #include "cc/trees/layer_tree_impl.h" | 29 #include "cc/trees/layer_tree_impl.h" |
| 31 | 30 |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "testing/perf/perf_test.h" | 32 #include "testing/perf/perf_test.h" |
| 34 | 33 |
| 35 namespace cc { | 34 namespace cc { |
| 36 namespace { | 35 namespace { |
| 37 | 36 |
| 38 static const int kTimeLimitMillis = 2000; | 37 static const int kTimeLimitMillis = 2000; |
| 39 static const int kWarmupRuns = 5; | 38 static const int kWarmupRuns = 5; |
| 40 static const int kTimeCheckInterval = 10; | 39 static const int kTimeCheckInterval = 10; |
| 41 | 40 |
| 42 base::LazyInstance<FakeTileTaskManagerImpl> g_fake_tile_task_manager = | 41 base::LazyInstance<FakeTileTaskManagerImpl> g_fake_tile_task_manager = |
| 43 LAZY_INSTANCE_INITIALIZER; | 42 LAZY_INSTANCE_INITIALIZER; |
| 44 | 43 |
| 45 class TileManagerPerfTest : public TestLayerTreeHostBase { | 44 class TileManagerPerfTest : public testing::Test { |
| 46 public: | 45 public: |
| 47 TileManagerPerfTest() | 46 TileManagerPerfTest() |
| 48 : timer_(kWarmupRuns, | 47 : memory_limit_policy_(ALLOW_ANYTHING), |
| 48 max_tiles_(10000), |
| 49 id_(7), |
| 50 task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), |
| 51 output_surface_(FakeOutputSurface::Create3d()), |
| 52 host_impl_(LayerTreeSettings(), |
| 53 &task_runner_provider_, |
| 54 &shared_bitmap_manager_, |
| 55 &task_graph_runner_), |
| 56 timer_(kWarmupRuns, |
| 49 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 57 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 50 kTimeCheckInterval) {} | 58 kTimeCheckInterval) {} |
| 51 | 59 |
| 52 void InitializeRenderer() override { | 60 void SetTreePriority(TreePriority tree_priority) { |
| 53 host_impl()->SetVisible(true); | 61 GlobalStateThatImpactsTilePriority state; |
| 54 host_impl()->InitializeRenderer(output_surface()); | 62 gfx::Size tile_size(256, 256); |
| 63 |
| 64 state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; |
| 65 state.num_resources_limit = max_tiles_; |
| 66 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; |
| 67 state.memory_limit_policy = memory_limit_policy_; |
| 68 state.tree_priority = tree_priority; |
| 69 |
| 70 global_state_ = state; |
| 71 host_impl_.resource_pool()->SetResourceUsageLimits( |
| 72 state.soft_memory_limit_in_bytes, state.num_resources_limit); |
| 73 host_impl_.tile_manager()->SetGlobalStateForTesting(state); |
| 74 } |
| 75 |
| 76 void SetUp() override { |
| 77 InitializeRenderer(); |
| 78 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 79 } |
| 80 |
| 81 virtual void InitializeRenderer() { |
| 82 host_impl_.SetVisible(true); |
| 83 host_impl_.InitializeRenderer(output_surface_.get()); |
| 55 tile_manager()->SetTileTaskManagerForTesting( | 84 tile_manager()->SetTileTaskManagerForTesting( |
| 56 g_fake_tile_task_manager.Pointer()); | 85 g_fake_tile_task_manager.Pointer()); |
| 57 } | 86 } |
| 58 | 87 |
| 59 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 88 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 60 const gfx::Size& tile_size) { | |
| 61 scoped_refptr<FakeRasterSource> pending_raster_source = | 89 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 62 FakeRasterSource::CreateFilled(layer_bounds); | 90 FakeRasterSource::CreateFilled(layer_bounds); |
| 63 scoped_refptr<FakeRasterSource> active_raster_source = | 91 scoped_refptr<FakeRasterSource> active_raster_source = |
| 64 FakeRasterSource::CreateFilled(layer_bounds); | 92 FakeRasterSource::CreateFilled(layer_bounds); |
| 65 | 93 |
| 66 SetupPendingTree(std::move(active_raster_source), tile_size, Region()); | 94 SetupTrees(pending_raster_source, active_raster_source); |
| 95 } |
| 96 |
| 97 void ActivateTree() { |
| 98 host_impl_.ActivateSyncTree(); |
| 99 CHECK(!host_impl_.pending_tree()); |
| 100 pending_root_layer_ = NULL; |
| 101 active_root_layer_ = static_cast<FakePictureLayerImpl*>( |
| 102 host_impl_.active_tree()->LayerById(id_)); |
| 103 } |
| 104 |
| 105 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
| 106 const gfx::Size& tile_size) { |
| 107 SetupDefaultTrees(layer_bounds); |
| 108 pending_root_layer_->set_fixed_tile_size(tile_size); |
| 109 active_root_layer_->set_fixed_tile_size(tile_size); |
| 110 } |
| 111 |
| 112 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, |
| 113 scoped_refptr<RasterSource> active_raster_source) { |
| 114 SetupPendingTree(active_raster_source); |
| 67 ActivateTree(); | 115 ActivateTree(); |
| 68 SetupPendingTree(std::move(pending_raster_source), tile_size, Region()); | 116 SetupPendingTree(pending_raster_source); |
| 117 } |
| 118 |
| 119 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
| 120 host_impl_.CreatePendingTree(); |
| 121 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 122 // Clear recycled tree. |
| 123 pending_tree->ClearLayers(); |
| 124 |
| 125 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
| 126 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, |
| 127 raster_source); |
| 128 pending_layer->SetDrawsContent(true); |
| 129 pending_layer->test_properties()->force_render_surface = true; |
| 130 pending_tree->SetRootLayer(std::move(pending_layer)); |
| 131 pending_tree->BuildPropertyTreesForTesting(); |
| 132 |
| 133 pending_root_layer_ = static_cast<FakePictureLayerImpl*>( |
| 134 host_impl_.pending_tree()->LayerById(id_)); |
| 69 } | 135 } |
| 70 | 136 |
| 71 void RunRasterQueueConstructTest(const std::string& test_name, | 137 void RunRasterQueueConstructTest(const std::string& test_name, |
| 72 int layer_count) { | 138 int layer_count) { |
| 73 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 139 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 74 SMOOTHNESS_TAKES_PRIORITY, | 140 SMOOTHNESS_TAKES_PRIORITY, |
| 75 NEW_CONTENT_TAKES_PRIORITY}; | 141 NEW_CONTENT_TAKES_PRIORITY}; |
| 76 int priority_count = 0; | 142 int priority_count = 0; |
| 77 | 143 |
| 78 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 10); | 144 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 10); |
| 79 for (const auto& layer : layers) | 145 for (const auto& layer : layers) |
| 80 layer->UpdateTiles(); | 146 layer->UpdateTiles(); |
| 81 | 147 |
| 82 timer_.Reset(); | 148 timer_.Reset(); |
| 83 do { | 149 do { |
| 84 std::unique_ptr<RasterTilePriorityQueue> queue( | 150 std::unique_ptr<RasterTilePriorityQueue> queue( |
| 85 host_impl()->BuildRasterQueue(priorities[priority_count], | 151 host_impl_.BuildRasterQueue(priorities[priority_count], |
| 86 RasterTilePriorityQueue::Type::ALL)); | 152 RasterTilePriorityQueue::Type::ALL)); |
| 87 priority_count = (priority_count + 1) % arraysize(priorities); | 153 priority_count = (priority_count + 1) % arraysize(priorities); |
| 88 timer_.NextLap(); | 154 timer_.NextLap(); |
| 89 } while (!timer_.HasTimeLimitExpired()); | 155 } while (!timer_.HasTimeLimitExpired()); |
| 90 | 156 |
| 91 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", | 157 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", |
| 92 "", | 158 "", |
| 93 test_name, | 159 test_name, |
| 94 timer_.LapsPerSecond(), | 160 timer_.LapsPerSecond(), |
| 95 "runs/s", | 161 "runs/s", |
| 96 true); | 162 true); |
| 97 } | 163 } |
| 98 | 164 |
| 99 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, | 165 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, |
| 100 int layer_count, | 166 int layer_count, |
| 101 int tile_count) { | 167 int tile_count) { |
| 102 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 168 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 103 SMOOTHNESS_TAKES_PRIORITY, | 169 SMOOTHNESS_TAKES_PRIORITY, |
| 104 NEW_CONTENT_TAKES_PRIORITY}; | 170 NEW_CONTENT_TAKES_PRIORITY}; |
| 105 | 171 |
| 106 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 100); | 172 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 100); |
| 107 for (const auto& layer : layers) | 173 for (const auto& layer : layers) |
| 108 layer->UpdateTiles(); | 174 layer->UpdateTiles(); |
| 109 | 175 |
| 110 int priority_count = 0; | 176 int priority_count = 0; |
| 111 timer_.Reset(); | 177 timer_.Reset(); |
| 112 do { | 178 do { |
| 113 int count = tile_count; | 179 int count = tile_count; |
| 114 std::unique_ptr<RasterTilePriorityQueue> queue( | 180 std::unique_ptr<RasterTilePriorityQueue> queue( |
| 115 host_impl()->BuildRasterQueue(priorities[priority_count], | 181 host_impl_.BuildRasterQueue(priorities[priority_count], |
| 116 RasterTilePriorityQueue::Type::ALL)); | 182 RasterTilePriorityQueue::Type::ALL)); |
| 117 while (count--) { | 183 while (count--) { |
| 118 ASSERT_FALSE(queue->IsEmpty()); | 184 ASSERT_FALSE(queue->IsEmpty()); |
| 119 ASSERT_TRUE(queue->Top().tile()); | 185 ASSERT_TRUE(queue->Top().tile()); |
| 120 queue->Pop(); | 186 queue->Pop(); |
| 121 } | 187 } |
| 122 priority_count = (priority_count + 1) % arraysize(priorities); | 188 priority_count = (priority_count + 1) % arraysize(priorities); |
| 123 timer_.NextLap(); | 189 timer_.NextLap(); |
| 124 } while (!timer_.HasTimeLimitExpired()); | 190 } while (!timer_.HasTimeLimitExpired()); |
| 125 | 191 |
| 126 perf_test::PrintResult( | 192 perf_test::PrintResult( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 144 layer->UpdateTiles(); | 210 layer->UpdateTiles(); |
| 145 for (size_t i = 0; i < layer->num_tilings(); ++i) { | 211 for (size_t i = 0; i < layer->num_tilings(); ++i) { |
| 146 tile_manager()->InitializeTilesWithResourcesForTesting( | 212 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 147 layer->tilings()->tiling_at(i)->AllTilesForTesting()); | 213 layer->tilings()->tiling_at(i)->AllTilesForTesting()); |
| 148 } | 214 } |
| 149 } | 215 } |
| 150 | 216 |
| 151 timer_.Reset(); | 217 timer_.Reset(); |
| 152 do { | 218 do { |
| 153 std::unique_ptr<EvictionTilePriorityQueue> queue( | 219 std::unique_ptr<EvictionTilePriorityQueue> queue( |
| 154 host_impl()->BuildEvictionQueue(priorities[priority_count])); | 220 host_impl_.BuildEvictionQueue(priorities[priority_count])); |
| 155 priority_count = (priority_count + 1) % arraysize(priorities); | 221 priority_count = (priority_count + 1) % arraysize(priorities); |
| 156 timer_.NextLap(); | 222 timer_.NextLap(); |
| 157 } while (!timer_.HasTimeLimitExpired()); | 223 } while (!timer_.HasTimeLimitExpired()); |
| 158 | 224 |
| 159 perf_test::PrintResult("tile_manager_eviction_tile_queue_construct", | 225 perf_test::PrintResult("tile_manager_eviction_tile_queue_construct", |
| 160 "", | 226 "", |
| 161 test_name, | 227 test_name, |
| 162 timer_.LapsPerSecond(), | 228 timer_.LapsPerSecond(), |
| 163 "runs/s", | 229 "runs/s", |
| 164 true); | 230 true); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 179 for (size_t i = 0; i < layer->num_tilings(); ++i) { | 245 for (size_t i = 0; i < layer->num_tilings(); ++i) { |
| 180 tile_manager()->InitializeTilesWithResourcesForTesting( | 246 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 181 layer->tilings()->tiling_at(i)->AllTilesForTesting()); | 247 layer->tilings()->tiling_at(i)->AllTilesForTesting()); |
| 182 } | 248 } |
| 183 } | 249 } |
| 184 | 250 |
| 185 timer_.Reset(); | 251 timer_.Reset(); |
| 186 do { | 252 do { |
| 187 int count = tile_count; | 253 int count = tile_count; |
| 188 std::unique_ptr<EvictionTilePriorityQueue> queue( | 254 std::unique_ptr<EvictionTilePriorityQueue> queue( |
| 189 host_impl()->BuildEvictionQueue(priorities[priority_count])); | 255 host_impl_.BuildEvictionQueue(priorities[priority_count])); |
| 190 while (count--) { | 256 while (count--) { |
| 191 ASSERT_FALSE(queue->IsEmpty()); | 257 ASSERT_FALSE(queue->IsEmpty()); |
| 192 ASSERT_TRUE(queue->Top().tile()); | 258 ASSERT_TRUE(queue->Top().tile()); |
| 193 queue->Pop(); | 259 queue->Pop(); |
| 194 } | 260 } |
| 195 priority_count = (priority_count + 1) % arraysize(priorities); | 261 priority_count = (priority_count + 1) % arraysize(priorities); |
| 196 timer_.NextLap(); | 262 timer_.NextLap(); |
| 197 } while (!timer_.HasTimeLimitExpired()); | 263 } while (!timer_.HasTimeLimitExpired()); |
| 198 | 264 |
| 199 perf_test::PrintResult( | 265 perf_test::PrintResult( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 210 // Compute the width/height required for high res to get | 276 // Compute the width/height required for high res to get |
| 211 // tiles_per_layer_count tiles. | 277 // tiles_per_layer_count tiles. |
| 212 float width = std::sqrt(static_cast<float>(tiles_per_layer_count)); | 278 float width = std::sqrt(static_cast<float>(tiles_per_layer_count)); |
| 213 float height = tiles_per_layer_count / width; | 279 float height = tiles_per_layer_count / width; |
| 214 | 280 |
| 215 // Adjust the width and height to account for the fact that tiles | 281 // Adjust the width and height to account for the fact that tiles |
| 216 // are bigger than 1x1. Also, account for the fact that that we | 282 // are bigger than 1x1. Also, account for the fact that that we |
| 217 // will be creating one high res and one low res tiling. That is, | 283 // will be creating one high res and one low res tiling. That is, |
| 218 // width and height should be smaller by sqrt(1 + low_res_scale). | 284 // width and height should be smaller by sqrt(1 + low_res_scale). |
| 219 // This gives us _approximately_ correct counts. | 285 // This gives us _approximately_ correct counts. |
| 220 LayerTreeSettings settings; | 286 width *= settings_.default_tile_size.width() / |
| 221 width *= settings.default_tile_size.width() / | 287 std::sqrt(1 + settings_.low_res_contents_scale_factor); |
| 222 std::sqrt(1 + settings.low_res_contents_scale_factor); | 288 height *= settings_.default_tile_size.height() / |
| 223 height *= settings.default_tile_size.height() / | 289 std::sqrt(1 + settings_.low_res_contents_scale_factor); |
| 224 std::sqrt(1 + settings.low_res_contents_scale_factor); | |
| 225 | 290 |
| 226 // Ensure that we start with blank trees and no tiles. | 291 // Ensure that we start with blank trees and no tiles. |
| 227 host_impl()->ResetTreesForTesting(); | 292 host_impl_.ResetTreesForTesting(); |
| 228 tile_manager()->FreeResourcesAndCleanUpReleasedTilesForTesting(); | 293 tile_manager()->FreeResourcesAndCleanUpReleasedTilesForTesting(); |
| 229 | 294 |
| 230 gfx::Size layer_bounds(width, height); | 295 gfx::Size layer_bounds(width, height); |
| 231 gfx::Size viewport(width / 5, height / 5); | 296 gfx::Size viewport(width / 5, height / 5); |
| 232 host_impl()->SetViewportSize(viewport); | 297 host_impl_.SetViewportSize(viewport); |
| 233 SetupDefaultTreesWithFixedTileSize(layer_bounds, | 298 SetupDefaultTreesWithFixedTileSize(layer_bounds, |
| 234 settings.default_tile_size); | 299 settings_.default_tile_size); |
| 235 | 300 |
| 236 std::vector<FakePictureLayerImpl*> layers; | 301 std::vector<FakePictureLayerImpl*> layers; |
| 237 | 302 |
| 238 // Pending layer counts as one layer. | 303 // Pending layer counts as one layer. |
| 239 layers.push_back(pending_layer()); | 304 layers.push_back(pending_root_layer_); |
| 240 int next_id = layer_id() + 1; | 305 int next_id = id_ + 1; |
| 241 | 306 |
| 242 // Create the rest of the layers as children of the root layer. | 307 // Create the rest of the layers as children of the root layer. |
| 243 scoped_refptr<FakeRasterSource> raster_source = | 308 scoped_refptr<FakeRasterSource> raster_source = |
| 244 FakeRasterSource::CreateFilled(layer_bounds); | 309 FakeRasterSource::CreateFilled(layer_bounds); |
| 245 while (static_cast<int>(layers.size()) < layer_count) { | 310 while (static_cast<int>(layers.size()) < layer_count) { |
| 246 std::unique_ptr<FakePictureLayerImpl> child_layer = | 311 std::unique_ptr<FakePictureLayerImpl> layer = |
| 247 FakePictureLayerImpl::CreateWithRasterSource( | 312 FakePictureLayerImpl::CreateWithRasterSource( |
| 248 host_impl()->pending_tree(), next_id, raster_source); | 313 host_impl_.pending_tree(), next_id, raster_source); |
| 249 child_layer->SetBounds(layer_bounds); | 314 layer->SetBounds(layer_bounds); |
| 250 child_layer->SetDrawsContent(true); | 315 layer->SetDrawsContent(true); |
| 251 layers.push_back(child_layer.get()); | 316 layers.push_back(layer.get()); |
| 252 pending_layer()->AddChild(std::move(child_layer)); | 317 pending_root_layer_->AddChild(std::move(layer)); |
| 253 ++next_id; | 318 ++next_id; |
| 254 } | 319 } |
| 255 | 320 |
| 256 // Property trees need to be rebuilt because layers were added above. | 321 // Property trees need to be rebuilt because layers were added above. |
| 257 host_impl()->pending_tree()->property_trees()->needs_rebuild = true; | 322 host_impl_.pending_tree()->property_trees()->needs_rebuild = true; |
| 258 host_impl()->pending_tree()->BuildPropertyTreesForTesting(); | 323 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); |
| 259 bool update_lcd_text = false; | 324 bool update_lcd_text = false; |
| 260 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 325 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 261 for (FakePictureLayerImpl* layer : layers) | 326 for (FakePictureLayerImpl* layer : layers) |
| 262 layer->CreateAllTiles(); | 327 layer->CreateAllTiles(); |
| 263 | 328 |
| 264 return layers; | 329 return layers; |
| 265 } | 330 } |
| 266 | 331 |
| 267 GlobalStateThatImpactsTilePriority GlobalStateForTest() { | 332 GlobalStateThatImpactsTilePriority GlobalStateForTest() { |
| 268 GlobalStateThatImpactsTilePriority state; | 333 GlobalStateThatImpactsTilePriority state; |
| 269 gfx::Size tile_size = LayerTreeSettings().default_tile_size; | 334 gfx::Size tile_size = settings_.default_tile_size; |
| 270 state.soft_memory_limit_in_bytes = | 335 state.soft_memory_limit_in_bytes = |
| 271 10000u * 4u * | 336 10000u * 4u * |
| 272 static_cast<size_t>(tile_size.width() * tile_size.height()); | 337 static_cast<size_t>(tile_size.width() * tile_size.height()); |
| 273 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes; | 338 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes; |
| 274 state.num_resources_limit = 10000; | 339 state.num_resources_limit = 10000; |
| 275 state.memory_limit_policy = ALLOW_ANYTHING; | 340 state.memory_limit_policy = ALLOW_ANYTHING; |
| 276 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY; | 341 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY; |
| 277 return state; | 342 return state; |
| 278 } | 343 } |
| 279 | 344 |
| 280 void RunPrepareTilesTest(const std::string& test_name, | 345 void RunPrepareTilesTest(const std::string& test_name, |
| 281 int layer_count, | 346 int layer_count, |
| 282 int approximate_tile_count_per_layer) { | 347 int approximate_tile_count_per_layer) { |
| 283 std::vector<FakePictureLayerImpl*> layers = | 348 std::vector<FakePictureLayerImpl*> layers = |
| 284 CreateLayers(layer_count, approximate_tile_count_per_layer); | 349 CreateLayers(layer_count, approximate_tile_count_per_layer); |
| 285 | 350 |
| 286 timer_.Reset(); | 351 timer_.Reset(); |
| 287 do { | 352 do { |
| 288 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 353 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 289 for (const auto& layer : layers) | 354 for (const auto& layer : layers) |
| 290 layer->UpdateTiles(); | 355 layer->UpdateTiles(); |
| 291 | 356 |
| 292 GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest()); | 357 GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest()); |
| 293 tile_manager()->PrepareTiles(global_state); | 358 tile_manager()->PrepareTiles(global_state); |
| 294 tile_manager()->Flush(); | 359 tile_manager()->Flush(); |
| 295 timer_.NextLap(); | 360 timer_.NextLap(); |
| 296 } while (!timer_.HasTimeLimitExpired()); | 361 } while (!timer_.HasTimeLimitExpired()); |
| 297 | 362 |
| 298 perf_test::PrintResult("prepare_tiles", "", test_name, | 363 perf_test::PrintResult("prepare_tiles", "", test_name, |
| 299 timer_.LapsPerSecond(), "runs/s", true); | 364 timer_.LapsPerSecond(), "runs/s", true); |
| 300 } | 365 } |
| 301 | 366 |
| 302 TileManager* tile_manager() { return host_impl()->tile_manager(); } | 367 TileManager* tile_manager() { return host_impl_.tile_manager(); } |
| 303 | 368 |
| 304 protected: | 369 protected: |
| 370 GlobalStateThatImpactsTilePriority global_state_; |
| 371 |
| 372 TestSharedBitmapManager shared_bitmap_manager_; |
| 373 TestTaskGraphRunner task_graph_runner_; |
| 374 TileMemoryLimitPolicy memory_limit_policy_; |
| 375 int max_tiles_; |
| 376 int id_; |
| 377 FakeImplTaskRunnerProvider task_runner_provider_; |
| 378 std::unique_ptr<OutputSurface> output_surface_; |
| 379 FakeLayerTreeHostImpl host_impl_; |
| 380 FakePictureLayerImpl* pending_root_layer_; |
| 381 FakePictureLayerImpl* active_root_layer_; |
| 305 LapTimer timer_; | 382 LapTimer timer_; |
| 383 LayerTreeSettings settings_; |
| 306 }; | 384 }; |
| 307 | 385 |
| 308 TEST_F(TileManagerPerfTest, PrepareTiles) { | 386 TEST_F(TileManagerPerfTest, PrepareTiles) { |
| 309 RunPrepareTilesTest("2_100", 2, 100); | 387 RunPrepareTilesTest("2_100", 2, 100); |
| 310 RunPrepareTilesTest("2_500", 2, 500); | 388 RunPrepareTilesTest("2_500", 2, 500); |
| 311 RunPrepareTilesTest("2_1000", 2, 1000); | 389 RunPrepareTilesTest("2_1000", 2, 1000); |
| 312 RunPrepareTilesTest("10_100", 10, 100); | 390 RunPrepareTilesTest("10_100", 10, 100); |
| 313 RunPrepareTilesTest("10_500", 10, 500); | 391 RunPrepareTilesTest("10_500", 10, 500); |
| 314 RunPrepareTilesTest("10_1000", 10, 1000); | 392 RunPrepareTilesTest("10_1000", 10, 1000); |
| 315 RunPrepareTilesTest("50_100", 100, 100); | 393 RunPrepareTilesTest("50_100", 100, 100); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 RunEvictionQueueConstructAndIterateTest("10_64", 10, 64); | 432 RunEvictionQueueConstructAndIterateTest("10_64", 10, 64); |
| 355 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); | 433 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); |
| 356 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); | 434 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); |
| 357 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); | 435 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); |
| 358 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); | 436 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); |
| 359 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); | 437 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); |
| 360 } | 438 } |
| 361 | 439 |
| 362 } // namespace | 440 } // namespace |
| 363 } // namespace cc | 441 } // namespace cc |
| OLD | NEW |