| Index: cc/layers/picture_layer_impl_unittest.cc
|
| diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
|
| index bd0585e52bab399da9b8245dd2d398d2a668225c..c78602ba8c5563ff7e5e6d45140611f5b5d2a0b9 100644
|
| --- a/cc/layers/picture_layer_impl_unittest.cc
|
| +++ b/cc/layers/picture_layer_impl_unittest.cc
|
| @@ -2960,6 +2960,8 @@ TEST_F(PictureLayerImplTest, LayerEvictionTileIterator) {
|
| size_t scale_index = 0;
|
| bool reached_visible = false;
|
| Tile* last_tile = nullptr;
|
| + int distance_decreasing = 0;
|
| + int distance_increasing = 0;
|
| for (it = PictureLayerImpl::LayerEvictionTileIterator(
|
| pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES);
|
| it;
|
| @@ -2989,21 +2991,26 @@ TEST_F(PictureLayerImplTest, LayerEvictionTileIterator) {
|
| EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]);
|
| unique_tiles.insert(tile);
|
|
|
| - // If the tile is the same rough bin as last tile (same activation, bin, and
|
| - // scale), then distance should be decreasing.
|
| if (tile->required_for_activation() ==
|
| last_tile->required_for_activation() &&
|
| priority.priority_bin ==
|
| last_tile->priority(PENDING_TREE).priority_bin &&
|
| std::abs(tile->contents_scale() - last_tile->contents_scale()) <
|
| std::numeric_limits<float>::epsilon()) {
|
| - EXPECT_LE(priority.distance_to_visible,
|
| - last_tile->priority(PENDING_TREE).distance_to_visible);
|
| + if (priority.distance_to_visible <=
|
| + last_tile->priority(PENDING_TREE).distance_to_visible) {
|
| + ++distance_decreasing;
|
| + } else {
|
| + ++distance_increasing;
|
| + }
|
| }
|
|
|
| last_tile = tile;
|
| }
|
|
|
| + EXPECT_EQ(7, distance_increasing);
|
| + EXPECT_EQ(55, distance_decreasing);
|
| +
|
| EXPECT_TRUE(reached_visible);
|
| EXPECT_EQ(65u, unique_tiles.size());
|
|
|
| @@ -3812,40 +3819,41 @@ class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest {
|
| OcclusionTrackingPictureLayerImplTest()
|
| : PictureLayerImplTest(OcclusionTrackingSettings()) {}
|
|
|
| - void VerifyEvictionConsidersOcclusion(
|
| - PictureLayerImpl* layer,
|
| - size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) {
|
| + void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer,
|
| + FakePictureLayerImpl* twin_layer,
|
| + WhichTree tree,
|
| + size_t expected_occluded_tile_count) {
|
| + twin_layer->set_has_valid_tile_priorities(false);
|
| for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES;
|
| ++priority_count) {
|
| TreePriority tree_priority = static_cast<TreePriority>(priority_count);
|
| size_t occluded_tile_count = 0u;
|
| Tile* last_tile = nullptr;
|
| + std::set<Tile*> shared_tiles;
|
|
|
| for (PictureLayerImpl::LayerEvictionTileIterator it =
|
| PictureLayerImpl::LayerEvictionTileIterator(layer,
|
| tree_priority);
|
| - it;
|
| - ++it) {
|
| + it; ++it) {
|
| Tile* tile = *it;
|
| if (!last_tile)
|
| last_tile = tile;
|
| + if (tile->is_shared())
|
| + EXPECT_TRUE(shared_tiles.insert(tile).second);
|
|
|
| // The only way we will encounter an occluded tile after an unoccluded
|
| // tile is if the priorty bin decreased, the tile is required for
|
| // activation, or the scale changed.
|
| - bool tile_is_occluded =
|
| - tile->is_occluded_for_tree_priority(tree_priority);
|
| + bool tile_is_occluded = tile->is_occluded(tree);
|
| if (tile_is_occluded) {
|
| occluded_tile_count++;
|
|
|
| - bool last_tile_is_occluded =
|
| - last_tile->is_occluded_for_tree_priority(tree_priority);
|
| + bool last_tile_is_occluded = last_tile->is_occluded(tree);
|
| if (!last_tile_is_occluded) {
|
| TilePriority::PriorityBin tile_priority_bin =
|
| - tile->priority_for_tree_priority(tree_priority).priority_bin;
|
| + tile->priority(tree).priority_bin;
|
| TilePriority::PriorityBin last_tile_priority_bin =
|
| - last_tile->priority_for_tree_priority(tree_priority)
|
| - .priority_bin;
|
| + last_tile->priority(tree).priority_bin;
|
|
|
| EXPECT_TRUE(
|
| (tile_priority_bin < last_tile_priority_bin) ||
|
| @@ -3855,9 +3863,21 @@ class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest {
|
| }
|
| last_tile = tile;
|
| }
|
| - EXPECT_EQ(expected_occluded_tile_count[priority_count],
|
| - occluded_tile_count);
|
| + for (PictureLayerImpl::LayerEvictionTileIterator it =
|
| + PictureLayerImpl::LayerEvictionTileIterator(twin_layer,
|
| + tree_priority);
|
| + it; ++it) {
|
| + Tile* tile = *it;
|
| + if (tile->is_shared())
|
| + EXPECT_TRUE(shared_tiles.insert(tile).second);
|
| + else
|
| + continue;
|
| + if (tile->is_occluded(tree))
|
| + ++occluded_tile_count;
|
| + }
|
| + EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count);
|
| }
|
| + twin_layer->set_has_valid_tile_priorities(true);
|
| }
|
| };
|
|
|
| @@ -4330,11 +4350,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest,
|
| size_t expected_occluded_tile_count_on_active[] = {30u, 5u, 4u, 2u, 2u};
|
| size_t expected_occluded_tile_count_on_pending[] = {30u, 5u, 4u, 2u, 2u};
|
|
|
| - // The total expected number of occluded tiles on all tilings for each of the
|
| - // 3 tree priorities.
|
| - size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u};
|
| -
|
| - ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES);
|
| + size_t total_expected_occluded_count_on_trees[] = {43u, 43u};
|
|
|
| // Verify number of occluded tiles on the pending layer for each tiling.
|
| for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
|
| @@ -4417,10 +4433,12 @@ TEST_F(OcclusionTrackingPictureLayerImplTest,
|
|
|
| host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
|
|
|
| - VerifyEvictionConsidersOcclusion(pending_layer_,
|
| - total_expected_occluded_tile_count);
|
| - VerifyEvictionConsidersOcclusion(active_layer_,
|
| - total_expected_occluded_tile_count);
|
| + VerifyEvictionConsidersOcclusion(
|
| + pending_layer_, active_layer_, PENDING_TREE,
|
| + total_expected_occluded_count_on_trees[PENDING_TREE]);
|
| + VerifyEvictionConsidersOcclusion(
|
| + active_layer_, pending_layer_, ACTIVE_TREE,
|
| + total_expected_occluded_count_on_trees[ACTIVE_TREE]);
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) {
|
|
|