Chromium Code Reviews| 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 2258655dbf6f678b4858290e86c6d30abbfed1d8..c0572f0fd3dbc4265334c4b98eddadb23dc1a924 100644 |
| --- a/cc/layers/picture_layer_impl_unittest.cc |
| +++ b/cc/layers/picture_layer_impl_unittest.cc |
| @@ -3204,5 +3204,133 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { |
| } |
| } |
| } |
| + |
| +TEST_F(OcclusionTrackingPictureLayerImplTest, |
| + OccludedTilesConsideredDuringEviction) { |
| + gfx::Size tile_size(102, 102); |
| + gfx::Size layer_bounds(1000, 1000); |
| + gfx::Size viewport_size(500, 500); |
| + gfx::Point occluding_layer_position(310, 0); |
| + |
| + scoped_refptr<FakePicturePileImpl> pending_pile = |
| + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| + SetupPendingTree(pending_pile); |
| + pending_layer_->set_fixed_tile_size(tile_size); |
| + |
| + ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| + |
| + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| + |
| + std::vector<PictureLayerTiling*> tilings; |
| + tilings.push_back(pending_layer_->AddTiling(low_res_factor)); |
| + tilings.push_back(pending_layer_->AddTiling(0.3f)); |
| + tilings.push_back(pending_layer_->AddTiling(0.7f)); |
| + tilings.push_back(pending_layer_->AddTiling(1.0f)); |
| + tilings.push_back(pending_layer_->AddTiling(2.0f)); |
| + |
| + pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
| + LayerImpl* layer1 = pending_layer_->children()[0]; |
| + layer1->SetBounds(layer_bounds); |
| + layer1->SetContentBounds(layer_bounds); |
| + layer1->SetDrawsContent(true); |
| + |
| + // No occlusion. |
| + layer1->SetContentsOpaque(false); |
| + |
| + host_impl_.SetViewportSize(viewport_size); |
| + host_impl_.pending_tree()->UpdateDrawProperties(); |
| + |
| + std::vector<Tile*> all_tiles; |
| + for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
| + tilings.begin(); |
| + tiling_iterator != tilings.end(); |
| + ++tiling_iterator) { |
| + std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
| + std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); |
| + } |
| + |
| + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| + |
| + int occluded_tile_count = 0; |
| + Tile* last_tile = NULL; |
| + for (PictureLayerImpl::LayerEvictionTileIterator it = |
| + PictureLayerImpl::LayerEvictionTileIterator( |
| + pending_layer_, NEW_CONTENT_TAKES_PRIORITY); |
|
danakj
2014/07/09 17:38:40
what about the SAME_PRIORITY_FOR_BOTH_TREES case?
jbedley
2014/07/11 00:19:38
I added all 6 cases to the test (pending or active
|
| + it; |
| + ++it) { |
| + Tile* tile = *it; |
| + if (!last_tile) |
| + last_tile = tile; |
| + |
| + EXPECT_TRUE(tile); |
| + |
| + if (tile->is_occluded(PENDING_TREE)) { |
| + occluded_tile_count++; |
| + // Occluded tiles should be evicted first within each tiling. |
| + if (!last_tile->is_occluded(PENDING_TREE)) |
| + EXPECT_NE(tile->contents_scale(), last_tile->contents_scale()); |
| + } |
| + |
| + last_tile = tile; |
| + } |
| + EXPECT_EQ(occluded_tile_count, 0); |
| + |
| + // Partial occlusion. |
| + layer1->SetContentsOpaque(true); |
| + layer1->SetPosition(occluding_layer_position); |
| + |
| + host_impl_.pending_tree()->UpdateDrawProperties(); |
| + |
| + occluded_tile_count = 0; |
| + last_tile = NULL; |
| + for (PictureLayerImpl::LayerEvictionTileIterator it = |
| + PictureLayerImpl::LayerEvictionTileIterator( |
| + pending_layer_, NEW_CONTENT_TAKES_PRIORITY); |
| + it; |
| + ++it) { |
| + Tile* tile = *it; |
| + if (!last_tile) |
| + last_tile = tile; |
| + |
| + EXPECT_TRUE(tile); |
| + |
| + if (tile->is_occluded(PENDING_TREE)) { |
|
danakj
2014/07/09 17:38:40
Hm, this verifies that we don't evict an occluded
jbedley
2014/07/11 00:19:38
Done.
|
| + occluded_tile_count++; |
| + if (!last_tile->is_occluded(PENDING_TREE)) |
| + EXPECT_NE(tile->contents_scale(), last_tile->contents_scale()); |
| + } |
| + |
| + last_tile = tile; |
| + } |
| + EXPECT_EQ(occluded_tile_count, 43); |
| + |
| + // Back to no occlusion. |
| + layer1->SetContentsOpaque(false); |
| + |
| + host_impl_.pending_tree()->UpdateDrawProperties(); |
| + |
| + occluded_tile_count = 0; |
| + last_tile = NULL; |
| + for (PictureLayerImpl::LayerEvictionTileIterator it = |
| + PictureLayerImpl::LayerEvictionTileIterator( |
| + pending_layer_, NEW_CONTENT_TAKES_PRIORITY); |
| + it; |
| + ++it) { |
| + Tile* tile = *it; |
| + if (!last_tile) |
| + last_tile = tile; |
| + |
| + EXPECT_TRUE(tile); |
| + |
| + if (tile->is_occluded(PENDING_TREE)) { |
| + occluded_tile_count++; |
| + if (!last_tile->is_occluded(PENDING_TREE)) |
| + EXPECT_NE(tile->contents_scale(), last_tile->contents_scale()); |
| + } |
| + |
| + last_tile = tile; |
| + } |
| + EXPECT_EQ(occluded_tile_count, 0); |
| +} |
| } // namespace |
| } // namespace cc |