| Index: cc/resources/tile_manager_unittest.cc
|
| diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc
|
| index 4a4c8b4f1c1b33669f9348c6871a2fec10a8802e..a25367201771d0837ceb54feffc1826dfa29fcaf 100644
|
| --- a/cc/resources/tile_manager_unittest.cc
|
| +++ b/cc/resources/tile_manager_unittest.cc
|
| @@ -669,6 +669,104 @@ TEST_F(TileManagerTilePriorityQueueTest,
|
| EXPECT_EQ(expected_occluded_count, occluded_count);
|
| }
|
|
|
| +TEST_F(TileManagerTilePriorityQueueTest,
|
| + EvictionTilePriorityQueueWithTransparentLayer) {
|
| + gfx::Size tile_size(102, 102);
|
| + gfx::Size layer_bounds(1000, 1000);
|
| +
|
| + scoped_refptr<FakePicturePileImpl> pending_pile =
|
| + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| + SetupPendingTree(pending_pile);
|
| + pending_layer_->CreateDefaultTilingsAndTiles();
|
| +
|
| + scoped_ptr<FakePictureLayerImpl> pending_child =
|
| + FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2,
|
| + pending_pile);
|
| + pending_layer_->AddChild(pending_child.Pass());
|
| +
|
| + // Create a fully transparent child layer so that its tile priorities are not
|
| + // considered to be valid.
|
| + FakePictureLayerImpl* pending_child_layer =
|
| + static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
|
| + pending_child_layer->SetDrawsContent(true);
|
| + pending_child_layer->CreateDefaultTilingsAndTiles();
|
| + pending_child_layer->SetOpacity(0.0);
|
| + pending_child_layer->layer_tree_impl()->UpdateDrawProperties();
|
| + pending_child_layer->DoPostCommitInitializationIfNeeded();
|
| +
|
| + // Renew all of the tile priorities.
|
| + gfx::Rect viewport(layer_bounds);
|
| + pending_layer_->HighResTiling()->ComputeTilePriorityRects(
|
| + PENDING_TREE, viewport, 1.0f, 1.0, Occlusion());
|
| + pending_layer_->LowResTiling()->ComputeTilePriorityRects(
|
| + PENDING_TREE, viewport, 1.0f, 1.0, Occlusion());
|
| + pending_child_layer->HighResTiling()->ComputeTilePriorityRects(
|
| + PENDING_TREE, viewport, 1.0f, 1.0, Occlusion());
|
| + pending_child_layer->LowResTiling()->ComputeTilePriorityRects(
|
| + PENDING_TREE, viewport, 1.0f, 1.0, Occlusion());
|
| +
|
| + // Populate all tiles directly from the tilings.
|
| + std::set<Tile*> all_pending_tiles;
|
| + std::vector<Tile*> pending_high_res_tiles =
|
| + pending_layer_->HighResTiling()->AllTilesForTesting();
|
| + all_pending_tiles.insert(pending_high_res_tiles.begin(),
|
| + pending_high_res_tiles.end());
|
| + EXPECT_EQ(16u, pending_high_res_tiles.size());
|
| +
|
| + std::vector<Tile*> pending_low_res_tiles =
|
| + pending_layer_->LowResTiling()->AllTilesForTesting();
|
| + all_pending_tiles.insert(pending_low_res_tiles.begin(),
|
| + pending_low_res_tiles.end());
|
| + EXPECT_EQ(1u, pending_low_res_tiles.size());
|
| +
|
| + std::set<Tile*> all_pending_child_tiles;
|
| + std::vector<Tile*> pending_child_high_res_tiles =
|
| + pending_child_layer->HighResTiling()->AllTilesForTesting();
|
| + all_pending_child_tiles.insert(pending_child_high_res_tiles.begin(),
|
| + pending_child_high_res_tiles.end());
|
| + EXPECT_EQ(16u, pending_child_high_res_tiles.size());
|
| +
|
| + std::vector<Tile*> pending_child_low_res_tiles =
|
| + pending_child_layer->LowResTiling()->AllTilesForTesting();
|
| + all_pending_child_tiles.insert(pending_child_low_res_tiles.begin(),
|
| + pending_child_low_res_tiles.end());
|
| + EXPECT_EQ(1u, pending_child_low_res_tiles.size());
|
| +
|
| + std::set<Tile*> all_tiles = all_pending_tiles;
|
| + all_tiles.insert(all_pending_child_tiles.begin(),
|
| + all_pending_child_tiles.end());
|
| +
|
| + tile_manager()->InitializeTilesWithResourcesForTesting(
|
| + std::vector<Tile*>(all_tiles.begin(), all_tiles.end()));
|
| +
|
| + EXPECT_TRUE(pending_layer_->HasValidTilePriorities());
|
| + EXPECT_FALSE(pending_child_layer->HasValidTilePriorities());
|
| +
|
| + // Verify that eviction queue returns tiles also from layers without valid
|
| + // tile priorities and that the tile priority bin of those tiles is (at most)
|
| + // EVENTUALLY.
|
| + TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY;
|
| + std::set<Tile*> new_content_tiles;
|
| + size_t tile_count = 0;
|
| + EvictionTilePriorityQueue queue;
|
| + host_impl_.BuildEvictionQueue(&queue, tree_priority);
|
| + while (!queue.IsEmpty()) {
|
| + Tile* tile = queue.Top();
|
| + const TilePriority& pending_priority = tile->priority(PENDING_TREE);
|
| + EXPECT_NE(std::numeric_limits<float>::infinity(),
|
| + pending_priority.distance_to_visible);
|
| + if (all_pending_child_tiles.find(tile) != all_pending_child_tiles.end())
|
| + EXPECT_EQ(TilePriority::EVENTUALLY, pending_priority.priority_bin);
|
| + else
|
| + EXPECT_EQ(TilePriority::NOW, pending_priority.priority_bin);
|
| + new_content_tiles.insert(tile);
|
| + ++tile_count;
|
| + queue.Pop();
|
| + }
|
| + EXPECT_EQ(tile_count, new_content_tiles.size());
|
| + EXPECT_EQ(all_tiles, new_content_tiles);
|
| +}
|
| +
|
| TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) {
|
| SetupDefaultTrees(gfx::Size(1000, 1000));
|
|
|
|
|