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 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2937 EXPECT_EQ(91u, all_tiles_set.size()); | 2937 EXPECT_EQ(91u, all_tiles_set.size()); |
2938 EXPECT_GT(number_of_marked_tiles, 1u); | 2938 EXPECT_GT(number_of_marked_tiles, 1u); |
2939 EXPECT_GT(number_of_unmarked_tiles, 1u); | 2939 EXPECT_GT(number_of_unmarked_tiles, 1u); |
2940 | 2940 |
2941 // Empty iterator. | 2941 // Empty iterator. |
2942 PictureLayerImpl::LayerEvictionTileIterator it; | 2942 PictureLayerImpl::LayerEvictionTileIterator it; |
2943 EXPECT_FALSE(it); | 2943 EXPECT_FALSE(it); |
2944 | 2944 |
2945 // Tiles don't have resources yet. | 2945 // Tiles don't have resources yet. |
2946 it = PictureLayerImpl::LayerEvictionTileIterator( | 2946 it = PictureLayerImpl::LayerEvictionTileIterator( |
2947 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); | 2947 pending_layer_, nullptr, SAME_PRIORITY_FOR_BOTH_TREES); |
2948 EXPECT_FALSE(it); | 2948 EXPECT_FALSE(it); |
2949 | 2949 |
2950 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 2950 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
2951 | 2951 |
2952 std::set<Tile*> unique_tiles; | 2952 std::set<Tile*> unique_tiles; |
2953 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f}; | 2953 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f}; |
2954 size_t scale_index = 0; | 2954 size_t scale_index = 0; |
2955 bool reached_visible = false; | 2955 bool reached_visible = false; |
2956 Tile* last_tile = nullptr; | 2956 Tile* last_tile = nullptr; |
2957 for (it = PictureLayerImpl::LayerEvictionTileIterator( | 2957 for (it = PictureLayerImpl::LayerEvictionTileIterator( |
2958 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); | 2958 pending_layer_, nullptr, SAME_PRIORITY_FOR_BOTH_TREES); |
2959 it; | 2959 it; |
2960 ++it) { | 2960 ++it) { |
2961 Tile* tile = *it; | 2961 Tile* tile = *it; |
2962 if (!last_tile) | 2962 if (!last_tile) |
2963 last_tile = tile; | 2963 last_tile = tile; |
2964 | 2964 |
2965 EXPECT_TRUE(tile); | 2965 EXPECT_TRUE(tile); |
2966 | 2966 |
2967 TilePriority priority = tile->priority(PENDING_TREE); | 2967 TilePriority priority = tile->priority(PENDING_TREE); |
2968 | 2968 |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3800 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } | 3800 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } |
3801 }; | 3801 }; |
3802 | 3802 |
3803 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3803 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
3804 public: | 3804 public: |
3805 OcclusionTrackingPictureLayerImplTest() | 3805 OcclusionTrackingPictureLayerImplTest() |
3806 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3806 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
3807 | 3807 |
3808 void VerifyEvictionConsidersOcclusion( | 3808 void VerifyEvictionConsidersOcclusion( |
3809 PictureLayerImpl* layer, | 3809 PictureLayerImpl* layer, |
| 3810 const PictureLayerImpl* twin_layer, |
3810 size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) { | 3811 size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) { |
3811 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES; | 3812 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES; |
3812 ++priority_count) { | 3813 ++priority_count) { |
3813 TreePriority tree_priority = static_cast<TreePriority>(priority_count); | 3814 TreePriority tree_priority = static_cast<TreePriority>(priority_count); |
3814 size_t occluded_tile_count = 0u; | 3815 size_t occluded_tile_count = 0u; |
3815 Tile* last_tile = nullptr; | 3816 Tile* last_tile = nullptr; |
3816 | 3817 |
3817 for (PictureLayerImpl::LayerEvictionTileIterator it = | 3818 for (PictureLayerImpl::LayerEvictionTileIterator it = |
3818 PictureLayerImpl::LayerEvictionTileIterator(layer, | 3819 PictureLayerImpl::LayerEvictionTileIterator( |
3819 tree_priority); | 3820 layer, twin_layer, tree_priority); |
3820 it; | 3821 it; |
3821 ++it) { | 3822 ++it) { |
3822 Tile* tile = *it; | 3823 Tile* tile = *it; |
3823 if (!last_tile) | 3824 if (!last_tile) |
3824 last_tile = tile; | 3825 last_tile = tile; |
3825 | 3826 |
3826 // The only way we will encounter an occluded tile after an unoccluded | 3827 // The only way we will encounter an occluded tile after an unoccluded |
3827 // tile is if the priorty bin decreased, the tile is required for | 3828 // tile is if the priorty bin decreased, the tile is required for |
3828 // activation, or the scale changed. | 3829 // activation, or the scale changed. |
3829 bool tile_is_occluded = | 3830 bool tile_is_occluded = |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4403 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 4404 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
4404 tilings.begin(); | 4405 tilings.begin(); |
4405 tiling_iterator != tilings.end(); | 4406 tiling_iterator != tilings.end(); |
4406 ++tiling_iterator) { | 4407 ++tiling_iterator) { |
4407 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | 4408 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
4408 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | 4409 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); |
4409 } | 4410 } |
4410 | 4411 |
4411 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 4412 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
4412 | 4413 |
4413 VerifyEvictionConsidersOcclusion(pending_layer_, | 4414 VerifyEvictionConsidersOcclusion( |
4414 total_expected_occluded_tile_count); | 4415 pending_layer_, active_layer_, total_expected_occluded_tile_count); |
4415 VerifyEvictionConsidersOcclusion(active_layer_, | 4416 VerifyEvictionConsidersOcclusion( |
4416 total_expected_occluded_tile_count); | 4417 active_layer_, pending_layer_, total_expected_occluded_tile_count); |
4417 } | 4418 } |
4418 | 4419 |
4419 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { | 4420 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { |
4420 gfx::Size tile_size(102, 102); | 4421 gfx::Size tile_size(102, 102); |
4421 gfx::Size layer_bounds(1000, 1000); | 4422 gfx::Size layer_bounds(1000, 1000); |
4422 | 4423 |
4423 scoped_refptr<FakePicturePileImpl> pile = | 4424 scoped_refptr<FakePicturePileImpl> pile = |
4424 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4425 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4425 SetupPendingTree(pile); | 4426 SetupPendingTree(pile); |
4426 EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer()); | 4427 EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer()); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4736 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4737 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4737 EXPECT_EQ(result.width(), 448); | 4738 EXPECT_EQ(result.width(), 448); |
4738 EXPECT_EQ(result.height(), 448); | 4739 EXPECT_EQ(result.height(), 448); |
4739 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4740 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4740 EXPECT_EQ(result.width(), 512); | 4741 EXPECT_EQ(result.width(), 512); |
4741 EXPECT_EQ(result.height(), 500 + 2); | 4742 EXPECT_EQ(result.height(), 500 + 2); |
4742 } | 4743 } |
4743 | 4744 |
4744 } // namespace | 4745 } // namespace |
4745 } // namespace cc | 4746 } // namespace cc |
OLD | NEW |