| 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3156 } | 3156 } |
| 3157 } | 3157 } |
| 3158 | 3158 |
| 3159 // Sanity checks. | 3159 // Sanity checks. |
| 3160 EXPECT_EQ(17u, all_tiles.size()); | 3160 EXPECT_EQ(17u, all_tiles.size()); |
| 3161 EXPECT_EQ(17u, all_tiles_set.size()); | 3161 EXPECT_EQ(17u, all_tiles_set.size()); |
| 3162 EXPECT_GT(number_of_marked_tiles, 1u); | 3162 EXPECT_GT(number_of_marked_tiles, 1u); |
| 3163 EXPECT_GT(number_of_unmarked_tiles, 1u); | 3163 EXPECT_GT(number_of_unmarked_tiles, 1u); |
| 3164 | 3164 |
| 3165 // Tiles don't have resources yet. | 3165 // Tiles don't have resources yet. |
| 3166 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( | 3166 scoped_ptr<TilingSetEvictionQueue> queue( |
| 3167 pending_layer_->picture_layer_tiling_set(), false)); | 3167 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); |
| 3168 EXPECT_TRUE(queue->IsEmpty()); | 3168 EXPECT_TRUE(queue->IsEmpty()); |
| 3169 | 3169 |
| 3170 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3170 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 3171 | 3171 |
| 3172 std::set<Tile*> unique_tiles; | 3172 std::set<Tile*> unique_tiles; |
| 3173 float expected_scales[] = {low_res_factor, 1.f}; | 3173 float expected_scales[] = {low_res_factor, 1.f}; |
| 3174 size_t scale_index = 0; | 3174 size_t scale_index = 0; |
| 3175 bool reached_visible = false; | 3175 bool reached_visible = false; |
| 3176 Tile* last_tile = nullptr; | 3176 Tile* last_tile = nullptr; |
| 3177 size_t distance_decreasing = 0; | 3177 size_t distance_decreasing = 0; |
| 3178 size_t distance_increasing = 0; | 3178 size_t distance_increasing = 0; |
| 3179 queue.reset(new TilingSetEvictionQueue( | 3179 queue.reset( |
| 3180 pending_layer_->picture_layer_tiling_set(), false)); | 3180 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); |
| 3181 while (!queue->IsEmpty()) { | 3181 while (!queue->IsEmpty()) { |
| 3182 Tile* tile = queue->Top(); | 3182 Tile* tile = queue->Top(); |
| 3183 if (!last_tile) | 3183 if (!last_tile) |
| 3184 last_tile = tile; | 3184 last_tile = tile; |
| 3185 | 3185 |
| 3186 EXPECT_TRUE(tile); | 3186 EXPECT_TRUE(tile); |
| 3187 | 3187 |
| 3188 TilePriority priority = tile->priority(); | 3188 TilePriority priority = tile->priority(); |
| 3189 | 3189 |
| 3190 if (priority.priority_bin == TilePriority::NOW) { | 3190 if (priority.priority_bin == TilePriority::NOW) { |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 public: | 3961 public: |
| 3962 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } | 3962 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } |
| 3963 }; | 3963 }; |
| 3964 | 3964 |
| 3965 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3965 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
| 3966 public: | 3966 public: |
| 3967 OcclusionTrackingPictureLayerImplTest() | 3967 OcclusionTrackingPictureLayerImplTest() |
| 3968 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3968 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
| 3969 | 3969 |
| 3970 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3970 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
| 3971 FakePictureLayerImpl* twin_layer, | |
| 3972 WhichTree tree, | 3971 WhichTree tree, |
| 3973 size_t expected_occluded_tile_count, | 3972 size_t expected_occluded_tile_count, |
| 3974 int source_line) { | 3973 int source_line) { |
| 3975 size_t occluded_tile_count = 0u; | 3974 size_t occluded_tile_count = 0u; |
| 3976 Tile* last_tile = nullptr; | 3975 Tile* last_tile = nullptr; |
| 3977 | 3976 |
| 3978 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( | 3977 scoped_ptr<TilingSetEvictionQueue> queue( |
| 3979 layer->picture_layer_tiling_set(), layer && twin_layer)); | 3978 new TilingSetEvictionQueue(layer->picture_layer_tiling_set())); |
| 3980 while (!queue->IsEmpty()) { | 3979 while (!queue->IsEmpty()) { |
| 3981 Tile* tile = queue->Top(); | 3980 Tile* tile = queue->Top(); |
| 3982 if (!last_tile) | 3981 if (!last_tile) |
| 3983 last_tile = tile; | 3982 last_tile = tile; |
| 3984 | 3983 |
| 3985 // The only way we will encounter an occluded tile after an unoccluded | 3984 // The only way we will encounter an occluded tile after an unoccluded |
| 3986 // tile is if the priorty bin decreased, the tile is required for | 3985 // tile is if the priorty bin decreased, the tile is required for |
| 3987 // activation, or the scale changed. | 3986 // activation, or the scale changed. |
| 3988 bool tile_is_occluded = tile->is_occluded(); | 3987 bool tile_is_occluded = tile->is_occluded(); |
| 3989 if (tile_is_occluded) { | 3988 if (tile_is_occluded) { |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4525 } | 4524 } |
| 4526 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4525 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4527 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4526 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4528 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4527 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4529 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); | 4528 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
| 4530 } | 4529 } |
| 4531 | 4530 |
| 4532 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 4531 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 4533 | 4532 |
| 4534 VerifyEvictionConsidersOcclusion( | 4533 VerifyEvictionConsidersOcclusion( |
| 4535 pending_layer_, active_layer_, PENDING_TREE, | 4534 pending_layer_, PENDING_TREE, |
| 4536 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); | 4535 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4537 VerifyEvictionConsidersOcclusion( | 4536 VerifyEvictionConsidersOcclusion( |
| 4538 active_layer_, pending_layer_, ACTIVE_TREE, | 4537 active_layer_, ACTIVE_TREE, |
| 4539 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); | 4538 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4540 | 4539 |
| 4541 // Repeat the tests without valid active tree priorities. | 4540 // Repeat the tests without valid active tree priorities. |
| 4542 active_layer_->set_has_valid_tile_priorities(false); | 4541 active_layer_->set_has_valid_tile_priorities(false); |
| 4543 VerifyEvictionConsidersOcclusion( | 4542 VerifyEvictionConsidersOcclusion( |
| 4544 pending_layer_, active_layer_, PENDING_TREE, | 4543 pending_layer_, PENDING_TREE, |
| 4545 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); | 4544 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4546 VerifyEvictionConsidersOcclusion( | 4545 VerifyEvictionConsidersOcclusion( |
| 4547 active_layer_, pending_layer_, ACTIVE_TREE, | 4546 active_layer_, ACTIVE_TREE, |
| 4548 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); | 4547 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4549 active_layer_->set_has_valid_tile_priorities(true); | 4548 active_layer_->set_has_valid_tile_priorities(true); |
| 4550 | 4549 |
| 4551 // Repeat the tests without valid pending tree priorities. | 4550 // Repeat the tests without valid pending tree priorities. |
| 4552 pending_layer_->set_has_valid_tile_priorities(false); | 4551 pending_layer_->set_has_valid_tile_priorities(false); |
| 4553 VerifyEvictionConsidersOcclusion( | 4552 VerifyEvictionConsidersOcclusion( |
| 4554 active_layer_, pending_layer_, ACTIVE_TREE, | 4553 active_layer_, ACTIVE_TREE, |
| 4555 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); | 4554 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4556 VerifyEvictionConsidersOcclusion( | 4555 VerifyEvictionConsidersOcclusion( |
| 4557 pending_layer_, active_layer_, PENDING_TREE, | 4556 pending_layer_, PENDING_TREE, |
| 4558 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); | 4557 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4559 pending_layer_->set_has_valid_tile_priorities(true); | 4558 pending_layer_->set_has_valid_tile_priorities(true); |
| 4560 } | 4559 } |
| 4561 | 4560 |
| 4562 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { | 4561 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { |
| 4563 gfx::Size tile_size(102, 102); | 4562 gfx::Size tile_size(102, 102); |
| 4564 gfx::Size layer_bounds(1000, 1000); | 4563 gfx::Size layer_bounds(1000, 1000); |
| 4565 | 4564 |
| 4566 scoped_refptr<FakePicturePileImpl> pile = | 4565 scoped_refptr<FakePicturePileImpl> pile = |
| 4567 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4566 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5026 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 5025 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 5027 EXPECT_EQ(result.width(), 448); | 5026 EXPECT_EQ(result.width(), 448); |
| 5028 EXPECT_EQ(result.height(), 448); | 5027 EXPECT_EQ(result.height(), 448); |
| 5029 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 5028 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 5030 EXPECT_EQ(result.width(), 512); | 5029 EXPECT_EQ(result.width(), 512); |
| 5031 EXPECT_EQ(result.height(), 500 + 2); | 5030 EXPECT_EQ(result.height(), 500 + 2); |
| 5032 } | 5031 } |
| 5033 | 5032 |
| 5034 } // namespace | 5033 } // namespace |
| 5035 } // namespace cc | 5034 } // namespace cc |
| OLD | NEW |