| 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 "cc/resources/eviction_tile_priority_queue.h" | 5 #include "cc/resources/eviction_tile_priority_queue.h" |
| 6 #include "cc/resources/raster_tile_priority_queue.h" | 6 #include "cc/resources/raster_tile_priority_queue.h" |
| 7 #include "cc/resources/tile.h" | 7 #include "cc/resources/tile.h" |
| 8 #include "cc/resources/tile_priority.h" | 8 #include "cc/resources/tile_priority.h" |
| 9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
| 10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 71 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 72 scoped_refptr<FakePicturePileImpl> active_pile = | 72 scoped_refptr<FakePicturePileImpl> active_pile = |
| 73 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 73 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 74 | 74 |
| 75 SetupTrees(pending_pile, active_pile); | 75 SetupTrees(pending_pile, active_pile); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void ActivateTree() { | 78 void ActivateTree() { |
| 79 host_impl_.ActivateSyncTree(); | 79 host_impl_.ActivateSyncTree(); |
| 80 CHECK(!host_impl_.pending_tree()); | 80 CHECK(!host_impl_.pending_tree()); |
| 81 pending_layer_ = NULL; | 81 pending_layer_ = nullptr; |
| 82 active_layer_ = static_cast<FakePictureLayerImpl*>( | 82 active_layer_ = static_cast<FakePictureLayerImpl*>( |
| 83 host_impl_.active_tree()->LayerById(id_)); | 83 host_impl_.active_tree()->LayerById(id_)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 86 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
| 87 const gfx::Size& tile_size) { | 87 const gfx::Size& tile_size) { |
| 88 SetupDefaultTrees(layer_bounds); | 88 SetupDefaultTrees(layer_bounds); |
| 89 pending_layer_->set_fixed_tile_size(tile_size); | 89 pending_layer_->set_fixed_tile_size(tile_size); |
| 90 active_layer_->set_fixed_tile_size(tile_size); | 90 active_layer_->set_fixed_tile_size(tile_size); |
| 91 } | 91 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 std::vector<Tile*> active_high_res_tiles = | 211 std::vector<Tile*> active_high_res_tiles = |
| 212 active_layer_->HighResTiling()->AllTilesForTesting(); | 212 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 213 for (size_t i = 0; i < active_high_res_tiles.size(); ++i) | 213 for (size_t i = 0; i < active_high_res_tiles.size(); ++i) |
| 214 all_tiles.insert(active_high_res_tiles[i]); | 214 all_tiles.insert(active_high_res_tiles[i]); |
| 215 | 215 |
| 216 std::vector<Tile*> active_low_res_tiles = | 216 std::vector<Tile*> active_low_res_tiles = |
| 217 active_layer_->LowResTiling()->AllTilesForTesting(); | 217 active_layer_->LowResTiling()->AllTilesForTesting(); |
| 218 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) | 218 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) |
| 219 all_tiles.insert(active_low_res_tiles[i]); | 219 all_tiles.insert(active_low_res_tiles[i]); |
| 220 | 220 |
| 221 Tile* last_tile = NULL; | 221 Tile* last_tile = nullptr; |
| 222 smoothness_tiles.clear(); | 222 smoothness_tiles.clear(); |
| 223 tile_count = 0; | 223 tile_count = 0; |
| 224 size_t increasing_distance_tiles = 0u; | 224 size_t increasing_distance_tiles = 0u; |
| 225 // Here we expect to get increasing ACTIVE_TREE priority_bin. | 225 // Here we expect to get increasing ACTIVE_TREE priority_bin. |
| 226 queue.Reset(); | 226 queue.Reset(); |
| 227 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); | 227 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); |
| 228 while (!queue.IsEmpty()) { | 228 while (!queue.IsEmpty()) { |
| 229 Tile* tile = queue.Top(); | 229 Tile* tile = queue.Top(); |
| 230 EXPECT_TRUE(tile); | 230 EXPECT_TRUE(tile); |
| 231 | 231 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 254 queue.Pop(); | 254 queue.Pop(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 257 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
| 258 EXPECT_EQ(all_tiles, smoothness_tiles); | 258 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 259 // Since we don't guarantee increasing distance due to spiral iterator, we | 259 // Since we don't guarantee increasing distance due to spiral iterator, we |
| 260 // should check that we're _mostly_ right. | 260 // should check that we're _mostly_ right. |
| 261 EXPECT_GT(increasing_distance_tiles, 3 * tile_count / 4); | 261 EXPECT_GT(increasing_distance_tiles, 3 * tile_count / 4); |
| 262 | 262 |
| 263 std::set<Tile*> new_content_tiles; | 263 std::set<Tile*> new_content_tiles; |
| 264 last_tile = NULL; | 264 last_tile = nullptr; |
| 265 increasing_distance_tiles = 0u; | 265 increasing_distance_tiles = 0u; |
| 266 // Here we expect to get increasing PENDING_TREE priority_bin. | 266 // Here we expect to get increasing PENDING_TREE priority_bin. |
| 267 queue.Reset(); | 267 queue.Reset(); |
| 268 host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY); | 268 host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY); |
| 269 while (!queue.IsEmpty()) { | 269 while (!queue.IsEmpty()) { |
| 270 Tile* tile = queue.Top(); | 270 Tile* tile = queue.Top(); |
| 271 EXPECT_TRUE(tile); | 271 EXPECT_TRUE(tile); |
| 272 | 272 |
| 273 if (!last_tile) | 273 if (!last_tile) |
| 274 last_tile = tile; | 274 last_tile = tile; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 all_tiles.insert(active_high_res_tiles[i]); | 389 all_tiles.insert(active_high_res_tiles[i]); |
| 390 | 390 |
| 391 std::vector<Tile*> active_low_res_tiles = | 391 std::vector<Tile*> active_low_res_tiles = |
| 392 active_layer_->LowResTiling()->AllTilesForTesting(); | 392 active_layer_->LowResTiling()->AllTilesForTesting(); |
| 393 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) | 393 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) |
| 394 all_tiles.insert(active_low_res_tiles[i]); | 394 all_tiles.insert(active_low_res_tiles[i]); |
| 395 | 395 |
| 396 tile_manager()->InitializeTilesWithResourcesForTesting( | 396 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 397 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 397 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 398 | 398 |
| 399 Tile* last_tile = NULL; | 399 Tile* last_tile = nullptr; |
| 400 smoothness_tiles.clear(); | 400 smoothness_tiles.clear(); |
| 401 tile_count = 0; | 401 tile_count = 0; |
| 402 // Here we expect to get increasing ACTIVE_TREE priority_bin. | 402 // Here we expect to get increasing ACTIVE_TREE priority_bin. |
| 403 queue.Reset(); | 403 queue.Reset(); |
| 404 host_impl_.BuildEvictionQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); | 404 host_impl_.BuildEvictionQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); |
| 405 while (!queue.IsEmpty()) { | 405 while (!queue.IsEmpty()) { |
| 406 Tile* tile = queue.Top(); | 406 Tile* tile = queue.Top(); |
| 407 EXPECT_TRUE(tile); | 407 EXPECT_TRUE(tile); |
| 408 EXPECT_TRUE(tile->HasResources()); | 408 EXPECT_TRUE(tile->HasResources()); |
| 409 | 409 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 426 last_tile = tile; | 426 last_tile = tile; |
| 427 ++tile_count; | 427 ++tile_count; |
| 428 smoothness_tiles.insert(tile); | 428 smoothness_tiles.insert(tile); |
| 429 queue.Pop(); | 429 queue.Pop(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 432 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
| 433 EXPECT_EQ(all_tiles, smoothness_tiles); | 433 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 434 | 434 |
| 435 std::set<Tile*> new_content_tiles; | 435 std::set<Tile*> new_content_tiles; |
| 436 last_tile = NULL; | 436 last_tile = nullptr; |
| 437 // Here we expect to get increasing PENDING_TREE priority_bin. | 437 // Here we expect to get increasing PENDING_TREE priority_bin. |
| 438 queue.Reset(); | 438 queue.Reset(); |
| 439 host_impl_.BuildEvictionQueue(&queue, NEW_CONTENT_TAKES_PRIORITY); | 439 host_impl_.BuildEvictionQueue(&queue, NEW_CONTENT_TAKES_PRIORITY); |
| 440 while (!queue.IsEmpty()) { | 440 while (!queue.IsEmpty()) { |
| 441 Tile* tile = queue.Top(); | 441 Tile* tile = queue.Top(); |
| 442 EXPECT_TRUE(tile); | 442 EXPECT_TRUE(tile); |
| 443 | 443 |
| 444 if (!last_tile) | 444 if (!last_tile) |
| 445 last_tile = tile; | 445 last_tile = tile; |
| 446 | 446 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 pending_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); | 536 pending_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); |
| 537 all_tiles.insert(pending_child_low_res_tiles.begin(), | 537 all_tiles.insert(pending_child_low_res_tiles.begin(), |
| 538 pending_child_low_res_tiles.end()); | 538 pending_child_low_res_tiles.end()); |
| 539 | 539 |
| 540 tile_manager()->InitializeTilesWithResourcesForTesting( | 540 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 541 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 541 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 542 | 542 |
| 543 // Verify occlusion is considered by EvictionTilePriorityQueue. | 543 // Verify occlusion is considered by EvictionTilePriorityQueue. |
| 544 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; | 544 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
| 545 size_t occluded_count = 0u; | 545 size_t occluded_count = 0u; |
| 546 Tile* last_tile = NULL; | 546 Tile* last_tile = nullptr; |
| 547 EvictionTilePriorityQueue queue; | 547 EvictionTilePriorityQueue queue; |
| 548 host_impl_.BuildEvictionQueue(&queue, tree_priority); | 548 host_impl_.BuildEvictionQueue(&queue, tree_priority); |
| 549 while (!queue.IsEmpty()) { | 549 while (!queue.IsEmpty()) { |
| 550 Tile* tile = queue.Top(); | 550 Tile* tile = queue.Top(); |
| 551 if (!last_tile) | 551 if (!last_tile) |
| 552 last_tile = tile; | 552 last_tile = tile; |
| 553 | 553 |
| 554 bool tile_is_occluded = tile->is_occluded_for_tree_priority(tree_priority); | 554 bool tile_is_occluded = tile->is_occluded_for_tree_priority(tree_priority); |
| 555 | 555 |
| 556 // The only way we will encounter an occluded tile after an unoccluded | 556 // The only way we will encounter an occluded tile after an unoccluded |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 all_tiles.insert(queue.Top()); | 671 all_tiles.insert(queue.Top()); |
| 672 ++tile_count; | 672 ++tile_count; |
| 673 queue.Pop(); | 673 queue.Pop(); |
| 674 } | 674 } |
| 675 EXPECT_EQ(tile_count, all_tiles.size()); | 675 EXPECT_EQ(tile_count, all_tiles.size()); |
| 676 EXPECT_EQ(17u, tile_count); | 676 EXPECT_EQ(17u, tile_count); |
| 677 } | 677 } |
| 678 | 678 |
| 679 } // namespace | 679 } // namespace |
| 680 } // namespace cc | 680 } // namespace cc |
| OLD | NEW |