| 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 "base/time/time.h" | 5 #include "base/time/time.h" |
| 6 #include "cc/debug/lap_timer.h" | 6 #include "cc/debug/lap_timer.h" |
| 7 #include "cc/resources/raster_buffer.h" | 7 #include "cc/resources/raster_buffer.h" |
| 8 #include "cc/resources/tile.h" | 8 #include "cc/resources/tile.h" |
| 9 #include "cc/resources/tile_priority.h" | 9 #include "cc/resources/tile_priority.h" |
| 10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 181 } |
| 182 | 182 |
| 183 void RunRasterQueueConstructTest(const std::string& test_name, | 183 void RunRasterQueueConstructTest(const std::string& test_name, |
| 184 int layer_count) { | 184 int layer_count) { |
| 185 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 185 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 186 SMOOTHNESS_TAKES_PRIORITY, | 186 SMOOTHNESS_TAKES_PRIORITY, |
| 187 NEW_CONTENT_TAKES_PRIORITY}; | 187 NEW_CONTENT_TAKES_PRIORITY}; |
| 188 int priority_count = 0; | 188 int priority_count = 0; |
| 189 | 189 |
| 190 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 10); | 190 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 10); |
| 191 for (unsigned i = 0; i < layers.size(); ++i) | 191 bool draw_properties_valid_for_tile_priority = true; |
| 192 layers[i]->UpdateTiles(Occlusion()); | 192 for (unsigned i = 0; i < layers.size(); ++i) { |
| 193 layers[i]->UpdateTiles(Occlusion(), |
| 194 draw_properties_valid_for_tile_priority); |
| 195 } |
| 193 | 196 |
| 194 timer_.Reset(); | 197 timer_.Reset(); |
| 195 do { | 198 do { |
| 196 RasterTilePriorityQueue queue; | 199 RasterTilePriorityQueue queue; |
| 197 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); | 200 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); |
| 198 priority_count = (priority_count + 1) % arraysize(priorities); | 201 priority_count = (priority_count + 1) % arraysize(priorities); |
| 199 timer_.NextLap(); | 202 timer_.NextLap(); |
| 200 } while (!timer_.HasTimeLimitExpired()); | 203 } while (!timer_.HasTimeLimitExpired()); |
| 201 | 204 |
| 202 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", | 205 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", |
| 203 "", | 206 "", |
| 204 test_name, | 207 test_name, |
| 205 timer_.LapsPerSecond(), | 208 timer_.LapsPerSecond(), |
| 206 "runs/s", | 209 "runs/s", |
| 207 true); | 210 true); |
| 208 } | 211 } |
| 209 | 212 |
| 210 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, | 213 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, |
| 211 int layer_count, | 214 int layer_count, |
| 212 unsigned tile_count) { | 215 unsigned tile_count) { |
| 213 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 216 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 214 SMOOTHNESS_TAKES_PRIORITY, | 217 SMOOTHNESS_TAKES_PRIORITY, |
| 215 NEW_CONTENT_TAKES_PRIORITY}; | 218 NEW_CONTENT_TAKES_PRIORITY}; |
| 216 | 219 |
| 217 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 100); | 220 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 100); |
| 218 for (unsigned i = 0; i < layers.size(); ++i) | 221 bool draw_properties_valid_for_tile_priority = true; |
| 219 layers[i]->UpdateTiles(Occlusion()); | 222 for (unsigned i = 0; i < layers.size(); ++i) { |
| 223 layers[i]->UpdateTiles(Occlusion(), |
| 224 draw_properties_valid_for_tile_priority); |
| 225 } |
| 220 | 226 |
| 221 int priority_count = 0; | 227 int priority_count = 0; |
| 222 timer_.Reset(); | 228 timer_.Reset(); |
| 223 do { | 229 do { |
| 224 int count = tile_count; | 230 int count = tile_count; |
| 225 RasterTilePriorityQueue queue; | 231 RasterTilePriorityQueue queue; |
| 226 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); | 232 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); |
| 227 while (count--) { | 233 while (count--) { |
| 228 ASSERT_FALSE(queue.IsEmpty()); | 234 ASSERT_FALSE(queue.IsEmpty()); |
| 229 ASSERT_TRUE(queue.Top() != NULL); | 235 ASSERT_TRUE(queue.Top() != NULL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 243 } | 249 } |
| 244 | 250 |
| 245 void RunEvictionQueueConstructTest(const std::string& test_name, | 251 void RunEvictionQueueConstructTest(const std::string& test_name, |
| 246 int layer_count) { | 252 int layer_count) { |
| 247 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 253 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 248 SMOOTHNESS_TAKES_PRIORITY, | 254 SMOOTHNESS_TAKES_PRIORITY, |
| 249 NEW_CONTENT_TAKES_PRIORITY}; | 255 NEW_CONTENT_TAKES_PRIORITY}; |
| 250 int priority_count = 0; | 256 int priority_count = 0; |
| 251 | 257 |
| 252 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 10); | 258 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 10); |
| 259 bool draw_properties_valid_for_tile_priority = true; |
| 253 for (unsigned i = 0; i < layers.size(); ++i) { | 260 for (unsigned i = 0; i < layers.size(); ++i) { |
| 254 FakePictureLayerImpl* layer = | 261 FakePictureLayerImpl* layer = |
| 255 static_cast<FakePictureLayerImpl*>(layers[i]); | 262 static_cast<FakePictureLayerImpl*>(layers[i]); |
| 256 layer->UpdateTiles(Occlusion()); | 263 layer->UpdateTiles(Occlusion(), draw_properties_valid_for_tile_priority); |
| 257 for (size_t j = 0; j < layer->GetTilings()->num_tilings(); ++j) { | 264 for (size_t j = 0; j < layer->GetTilings()->num_tilings(); ++j) { |
| 258 tile_manager()->InitializeTilesWithResourcesForTesting( | 265 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 259 layer->GetTilings()->tiling_at(j)->AllTilesForTesting()); | 266 layer->GetTilings()->tiling_at(j)->AllTilesForTesting()); |
| 260 } | 267 } |
| 261 } | 268 } |
| 262 | 269 |
| 263 timer_.Reset(); | 270 timer_.Reset(); |
| 264 do { | 271 do { |
| 265 EvictionTilePriorityQueue queue; | 272 EvictionTilePriorityQueue queue; |
| 266 host_impl_.BuildEvictionQueue(&queue, priorities[priority_count]); | 273 host_impl_.BuildEvictionQueue(&queue, priorities[priority_count]); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 278 | 285 |
| 279 void RunEvictionQueueConstructAndIterateTest(const std::string& test_name, | 286 void RunEvictionQueueConstructAndIterateTest(const std::string& test_name, |
| 280 int layer_count, | 287 int layer_count, |
| 281 unsigned tile_count) { | 288 unsigned tile_count) { |
| 282 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 289 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 283 SMOOTHNESS_TAKES_PRIORITY, | 290 SMOOTHNESS_TAKES_PRIORITY, |
| 284 NEW_CONTENT_TAKES_PRIORITY}; | 291 NEW_CONTENT_TAKES_PRIORITY}; |
| 285 int priority_count = 0; | 292 int priority_count = 0; |
| 286 | 293 |
| 287 std::vector<LayerImpl*> layers = CreateLayers(layer_count, tile_count); | 294 std::vector<LayerImpl*> layers = CreateLayers(layer_count, tile_count); |
| 295 bool draw_properties_valid_for_tile_priority = true; |
| 288 for (unsigned i = 0; i < layers.size(); ++i) { | 296 for (unsigned i = 0; i < layers.size(); ++i) { |
| 289 FakePictureLayerImpl* layer = | 297 FakePictureLayerImpl* layer = |
| 290 static_cast<FakePictureLayerImpl*>(layers[i]); | 298 static_cast<FakePictureLayerImpl*>(layers[i]); |
| 291 layer->UpdateTiles(Occlusion()); | 299 layer->UpdateTiles(Occlusion(), draw_properties_valid_for_tile_priority); |
| 292 for (size_t j = 0; j < layer->GetTilings()->num_tilings(); ++j) { | 300 for (size_t j = 0; j < layer->GetTilings()->num_tilings(); ++j) { |
| 293 tile_manager()->InitializeTilesWithResourcesForTesting( | 301 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 294 layer->GetTilings()->tiling_at(j)->AllTilesForTesting()); | 302 layer->GetTilings()->tiling_at(j)->AllTilesForTesting()); |
| 295 } | 303 } |
| 296 } | 304 } |
| 297 | 305 |
| 298 timer_.Reset(); | 306 timer_.Reset(); |
| 299 do { | 307 do { |
| 300 int count = tile_count; | 308 int count = tile_count; |
| 301 EvictionTilePriorityQueue queue; | 309 EvictionTilePriorityQueue queue; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY; | 395 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY; |
| 388 return state; | 396 return state; |
| 389 } | 397 } |
| 390 | 398 |
| 391 void RunManageTilesTest(const std::string& test_name, | 399 void RunManageTilesTest(const std::string& test_name, |
| 392 int layer_count, | 400 int layer_count, |
| 393 int approximate_tile_count_per_layer) { | 401 int approximate_tile_count_per_layer) { |
| 394 std::vector<LayerImpl*> layers = | 402 std::vector<LayerImpl*> layers = |
| 395 CreateLayers(layer_count, approximate_tile_count_per_layer); | 403 CreateLayers(layer_count, approximate_tile_count_per_layer); |
| 396 timer_.Reset(); | 404 timer_.Reset(); |
| 405 bool draw_properties_valid_for_tile_priority = true; |
| 397 do { | 406 do { |
| 398 BeginFrameArgs args = CreateBeginFrameArgsForTesting(); | 407 BeginFrameArgs args = CreateBeginFrameArgsForTesting(); |
| 399 host_impl_.UpdateCurrentBeginFrameArgs(args); | 408 host_impl_.UpdateCurrentBeginFrameArgs(args); |
| 400 for (unsigned i = 0; i < layers.size(); ++i) | 409 for (unsigned i = 0; i < layers.size(); ++i) { |
| 401 layers[i]->UpdateTiles(Occlusion()); | 410 layers[i]->UpdateTiles(Occlusion(), |
| 411 draw_properties_valid_for_tile_priority); |
| 412 } |
| 402 | 413 |
| 403 GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest()); | 414 GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest()); |
| 404 tile_manager()->ManageTiles(global_state); | 415 tile_manager()->ManageTiles(global_state); |
| 405 tile_manager()->UpdateVisibleTiles(); | 416 tile_manager()->UpdateVisibleTiles(); |
| 406 timer_.NextLap(); | 417 timer_.NextLap(); |
| 407 host_impl_.ResetCurrentBeginFrameArgsForNextFrame(); | 418 host_impl_.ResetCurrentBeginFrameArgsForNextFrame(); |
| 408 } while (!timer_.HasTimeLimitExpired()); | 419 } while (!timer_.HasTimeLimitExpired()); |
| 409 | 420 |
| 410 perf_test::PrintResult( | 421 perf_test::PrintResult( |
| 411 "manage_tiles", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | 422 "manage_tiles", "", test_name, timer_.LapsPerSecond(), "runs/s", true); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); | 490 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); |
| 480 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); | 491 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); |
| 481 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); | 492 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); |
| 482 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); | 493 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); |
| 483 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); | 494 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); |
| 484 } | 495 } |
| 485 | 496 |
| 486 } // namespace | 497 } // namespace |
| 487 | 498 |
| 488 } // namespace cc | 499 } // namespace cc |
| OLD | NEW |