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 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3118 } | 3118 } |
3119 } | 3119 } |
3120 | 3120 |
3121 // Sanity checks. | 3121 // Sanity checks. |
3122 EXPECT_EQ(17u, all_tiles.size()); | 3122 EXPECT_EQ(17u, all_tiles.size()); |
3123 EXPECT_EQ(17u, all_tiles_set.size()); | 3123 EXPECT_EQ(17u, all_tiles_set.size()); |
3124 EXPECT_GT(number_of_marked_tiles, 1u); | 3124 EXPECT_GT(number_of_marked_tiles, 1u); |
3125 EXPECT_GT(number_of_unmarked_tiles, 1u); | 3125 EXPECT_GT(number_of_unmarked_tiles, 1u); |
3126 | 3126 |
3127 // Tiles don't have resources yet. | 3127 // Tiles don't have resources yet. |
3128 scoped_ptr<TilingSetEvictionQueue> queue( | 3128 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( |
3129 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set(), | 3129 pending_layer_->picture_layer_tiling_set(), false)); |
3130 SAME_PRIORITY_FOR_BOTH_TREES, false)); | |
3131 EXPECT_TRUE(queue->IsEmpty()); | 3130 EXPECT_TRUE(queue->IsEmpty()); |
3132 | 3131 |
3133 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3132 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
3134 | 3133 |
3135 std::set<Tile*> unique_tiles; | 3134 std::set<Tile*> unique_tiles; |
3136 float expected_scales[] = {low_res_factor, 1.f}; | 3135 float expected_scales[] = {low_res_factor, 1.f}; |
3137 size_t scale_index = 0; | 3136 size_t scale_index = 0; |
3138 bool reached_visible = false; | 3137 bool reached_visible = false; |
3139 Tile* last_tile = nullptr; | 3138 Tile* last_tile = nullptr; |
3140 size_t distance_decreasing = 0; | 3139 size_t distance_decreasing = 0; |
3141 size_t distance_increasing = 0; | 3140 size_t distance_increasing = 0; |
3142 queue.reset( | 3141 queue.reset(new TilingSetEvictionQueue( |
3143 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set(), | 3142 pending_layer_->picture_layer_tiling_set(), false)); |
3144 SAME_PRIORITY_FOR_BOTH_TREES, false)); | |
3145 while (!queue->IsEmpty()) { | 3143 while (!queue->IsEmpty()) { |
3146 Tile* tile = queue->Top(); | 3144 Tile* tile = queue->Top(); |
3147 if (!last_tile) | 3145 if (!last_tile) |
3148 last_tile = tile; | 3146 last_tile = tile; |
3149 | 3147 |
3150 EXPECT_TRUE(tile); | 3148 EXPECT_TRUE(tile); |
3151 | 3149 |
3152 TilePriority priority = tile->priority(PENDING_TREE); | 3150 TilePriority priority = tile->priority(PENDING_TREE); |
3153 | 3151 |
3154 if (priority.priority_bin == TilePriority::NOW) { | 3152 if (priority.priority_bin == TilePriority::NOW) { |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3915 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3913 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
3916 public: | 3914 public: |
3917 OcclusionTrackingPictureLayerImplTest() | 3915 OcclusionTrackingPictureLayerImplTest() |
3918 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3916 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
3919 | 3917 |
3920 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3918 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
3921 FakePictureLayerImpl* twin_layer, | 3919 FakePictureLayerImpl* twin_layer, |
3922 WhichTree tree, | 3920 WhichTree tree, |
3923 size_t expected_occluded_tile_count) { | 3921 size_t expected_occluded_tile_count) { |
3924 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 3922 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; |
3925 for (int priority_count = 0; priority_count <= LAST_TREE_PRIORITY; | 3923 size_t occluded_tile_count = 0u; |
3926 ++priority_count) { | 3924 Tile* last_tile = nullptr; |
3927 TreePriority tree_priority = static_cast<TreePriority>(priority_count); | 3925 std::set<Tile*> shared_tiles; |
3928 size_t occluded_tile_count = 0u; | |
3929 Tile* last_tile = nullptr; | |
3930 std::set<Tile*> shared_tiles; | |
3931 | 3926 |
3932 scoped_ptr<TilingSetEvictionQueue> queue( | 3927 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( |
3933 new TilingSetEvictionQueue(layer->picture_layer_tiling_set(), | 3928 layer->picture_layer_tiling_set(), layer && twin_layer)); |
3934 tree_priority, layer && twin_layer)); | 3929 while (!queue->IsEmpty()) { |
3935 while (!queue->IsEmpty()) { | 3930 Tile* tile = queue->Top(); |
3936 Tile* tile = queue->Top(); | 3931 if (!last_tile) |
3937 if (!last_tile) | 3932 last_tile = tile; |
3938 last_tile = tile; | 3933 if (tile->is_shared()) |
3939 if (tile->is_shared()) | 3934 EXPECT_TRUE(shared_tiles.insert(tile).second); |
3940 EXPECT_TRUE(shared_tiles.insert(tile).second); | |
3941 | 3935 |
3942 // The only way we will encounter an occluded tile after an unoccluded | 3936 // The only way we will encounter an occluded tile after an unoccluded |
3943 // tile is if the priorty bin decreased, the tile is required for | 3937 // tile is if the priorty bin decreased, the tile is required for |
3944 // activation, or the scale changed. | 3938 // activation, or the scale changed. |
3945 bool tile_is_occluded = tile->is_occluded(tree); | 3939 bool tile_is_occluded = tile->is_occluded(tree); |
3946 if (tile_is_occluded) { | 3940 if (tile_is_occluded) { |
3947 occluded_tile_count++; | 3941 occluded_tile_count++; |
3948 | 3942 |
3949 bool last_tile_is_occluded = last_tile->is_occluded(tree); | 3943 bool last_tile_is_occluded = last_tile->is_occluded(tree); |
3950 if (!last_tile_is_occluded) { | 3944 if (!last_tile_is_occluded) { |
3951 TilePriority::PriorityBin tile_priority_bin = | 3945 TilePriority::PriorityBin tile_priority_bin = |
3952 tile->priority(tree).priority_bin; | 3946 tile->priority(tree).priority_bin; |
3953 TilePriority::PriorityBin last_tile_priority_bin = | 3947 TilePriority::PriorityBin last_tile_priority_bin = |
3954 last_tile->priority(tree).priority_bin; | 3948 last_tile->priority(tree).priority_bin; |
3955 | 3949 |
3956 EXPECT_TRUE( | 3950 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || |
3957 (tile_priority_bin < last_tile_priority_bin) || | 3951 tile->required_for_activation() || |
3958 tile->required_for_activation() || | 3952 tile->contents_scale() != last_tile->contents_scale()); |
3959 (tile->contents_scale() != last_tile->contents_scale())); | |
3960 } | |
3961 } | 3953 } |
3962 last_tile = tile; | |
3963 queue->Pop(); | |
3964 } | 3954 } |
3965 // Count also shared tiles which are occluded in the tree but which were | 3955 last_tile = tile; |
3966 // not returned by the tiling set eviction queue. Those shared tiles | 3956 queue->Pop(); |
3967 // shall be returned by the twin tiling set eviction queue. | 3957 } |
3968 queue.reset( | 3958 // Count also shared tiles which are occluded in the tree but which were |
3969 new TilingSetEvictionQueue(twin_layer->picture_layer_tiling_set(), | 3959 // not returned by the tiling set eviction queue. Those shared tiles |
3970 tree_priority, layer && twin_layer)); | 3960 // shall be returned by the twin tiling set eviction queue. |
3971 while (!queue->IsEmpty()) { | 3961 queue.reset(new TilingSetEvictionQueue( |
3972 Tile* tile = queue->Top(); | 3962 twin_layer->picture_layer_tiling_set(), layer && twin_layer)); |
3973 if (tile->is_shared()) { | 3963 while (!queue->IsEmpty()) { |
3974 EXPECT_TRUE(shared_tiles.insert(tile).second); | 3964 Tile* tile = queue->Top(); |
3975 if (tile->is_occluded(tree)) | 3965 if (tile->is_shared()) { |
3976 ++occluded_tile_count; | 3966 EXPECT_TRUE(shared_tiles.insert(tile).second); |
3977 // Check the reasons why the shared tile was not returned by | 3967 if (tile->is_occluded(tree)) |
3978 // the first tiling set eviction queue. | 3968 ++occluded_tile_count; |
3979 switch (tree_priority) { | 3969 // Check the reasons why the shared tile was not returned by |
3980 case SAME_PRIORITY_FOR_BOTH_TREES: { | 3970 // the first tiling set eviction queue. |
3981 const TilePriority& priority = tile->priority(tree); | 3971 const TilePriority& combined_priority = tile->combined_priority(); |
3982 const TilePriority& priority_for_tree_priority = | 3972 const TilePriority& priority = tile->priority(tree); |
3983 tile->priority_for_tree_priority(tree_priority); | 3973 const TilePriority& twin_priority = tile->priority(twin_tree); |
3984 const TilePriority& twin_priority = tile->priority(twin_tree); | 3974 // Check if the shared tile was not returned by the first tiling |
3985 // Check if the shared tile was not returned by the first tiling | 3975 // set eviction queue because it was out of order for the first |
3986 // set eviction queue because it was out of order for the first | 3976 // tiling set eviction queue but not for the twin tiling set |
3987 // tiling set eviction queue but not for the twin tiling set | 3977 // eviction queue. |
3988 // eviction queue. | 3978 if (priority.priority_bin != twin_priority.priority_bin) { |
3989 if (priority.priority_bin != twin_priority.priority_bin) { | 3979 EXPECT_LT(combined_priority.priority_bin, priority.priority_bin); |
3990 EXPECT_LT(priority_for_tree_priority.priority_bin, | 3980 EXPECT_EQ(combined_priority.priority_bin, twin_priority.priority_bin); |
3991 priority.priority_bin); | 3981 } else if (tile->is_occluded(tree) != tile->is_occluded(twin_tree)) { |
3992 EXPECT_EQ(priority_for_tree_priority.priority_bin, | 3982 EXPECT_TRUE(tile->is_occluded(tree)); |
3993 twin_priority.priority_bin); | 3983 EXPECT_FALSE(tile->is_occluded(twin_tree)); |
3994 EXPECT_TRUE(priority_for_tree_priority.priority_bin < | 3984 EXPECT_FALSE(tile->is_occluded_combined()); |
3995 priority.priority_bin); | 3985 } else if (priority.distance_to_visible != |
3996 } else if (tile->is_occluded(tree) != | 3986 twin_priority.distance_to_visible) { |
3997 tile->is_occluded(twin_tree)) { | 3987 EXPECT_LT(combined_priority.distance_to_visible, |
3998 EXPECT_TRUE(tile->is_occluded(tree)); | 3988 priority.distance_to_visible); |
3999 EXPECT_FALSE(tile->is_occluded(twin_tree)); | 3989 EXPECT_EQ(combined_priority.distance_to_visible, |
4000 EXPECT_FALSE(tile->is_occluded_combined()); | 3990 twin_priority.distance_to_visible); |
4001 } else if (priority.distance_to_visible != | 3991 } else { |
4002 twin_priority.distance_to_visible) { | 3992 // Shared tiles having the same active and pending priorities |
4003 EXPECT_LT(priority_for_tree_priority.distance_to_visible, | 3993 // should be returned only by a pending tree eviction queue. |
4004 priority.distance_to_visible); | 3994 EXPECT_EQ(ACTIVE_TREE, tree); |
4005 EXPECT_EQ(priority_for_tree_priority.distance_to_visible, | |
4006 twin_priority.distance_to_visible); | |
4007 EXPECT_TRUE(priority_for_tree_priority.distance_to_visible < | |
4008 priority.distance_to_visible); | |
4009 } else { | |
4010 // Shared tiles having the same active and pending priorities | |
4011 // should be returned only by a pending tree eviction queue. | |
4012 EXPECT_EQ(ACTIVE_TREE, tree); | |
4013 } | |
4014 break; | |
4015 } | |
4016 case SMOOTHNESS_TAKES_PRIORITY: | |
4017 // Shared tiles should be returned only by an active tree | |
4018 // eviction queue. | |
4019 EXPECT_EQ(PENDING_TREE, tree); | |
4020 break; | |
4021 case NEW_CONTENT_TAKES_PRIORITY: | |
4022 // Shared tiles should be returned only by a pending tree | |
4023 // eviction queue. | |
4024 EXPECT_EQ(ACTIVE_TREE, tree); | |
4025 break; | |
4026 } | |
4027 } | 3995 } |
4028 queue->Pop(); | |
4029 } | 3996 } |
4030 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count); | 3997 queue->Pop(); |
4031 } | 3998 } |
| 3999 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count); |
4032 } | 4000 } |
4033 }; | 4001 }; |
4034 | 4002 |
4035 TEST_F(OcclusionTrackingPictureLayerImplTest, | 4003 TEST_F(OcclusionTrackingPictureLayerImplTest, |
4036 OccludedTilesSkippedDuringRasterization) { | 4004 OccludedTilesSkippedDuringRasterization) { |
4037 base::TimeTicks time_ticks; | 4005 base::TimeTicks time_ticks; |
4038 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4006 time_ticks += base::TimeDelta::FromMilliseconds(1); |
4039 host_impl_.SetCurrentBeginFrameArgs( | 4007 host_impl_.SetCurrentBeginFrameArgs( |
4040 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4008 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4041 | 4009 |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4969 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4937 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4970 EXPECT_EQ(result.width(), 448); | 4938 EXPECT_EQ(result.width(), 448); |
4971 EXPECT_EQ(result.height(), 448); | 4939 EXPECT_EQ(result.height(), 448); |
4972 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4940 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4973 EXPECT_EQ(result.width(), 512); | 4941 EXPECT_EQ(result.width(), 512); |
4974 EXPECT_EQ(result.height(), 500 + 2); | 4942 EXPECT_EQ(result.height(), 500 + 2); |
4975 } | 4943 } |
4976 | 4944 |
4977 } // namespace | 4945 } // namespace |
4978 } // namespace cc | 4946 } // namespace cc |
OLD | NEW |