| 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 d9fb69f214493329f789a5d8f2469dd0fbcdf64f..2d2e330bb45926ba2961014e793d24fa80268f8d 100644
|
| --- a/cc/layers/picture_layer_impl_unittest.cc
|
| +++ b/cc/layers/picture_layer_impl_unittest.cc
|
| @@ -288,19 +288,15 @@
|
| }
|
|
|
| void ResetTilingsAndRasterScales() {
|
| - if (pending_layer_) {
|
| - pending_layer_->ReleaseResources();
|
| - EXPECT_FALSE(pending_layer_->tilings());
|
| - pending_layer_->RecreateResources();
|
| - EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
|
| - }
|
| -
|
| - if (active_layer_) {
|
| - active_layer_->ReleaseResources();
|
| - EXPECT_FALSE(active_layer_->tilings());
|
| - active_layer_->RecreateResources();
|
| - EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
|
| - }
|
| + pending_layer_->ReleaseResources();
|
| + EXPECT_FALSE(pending_layer_->tilings());
|
| + pending_layer_->RecreateResources();
|
| + EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
|
| +
|
| + active_layer_->ReleaseResources();
|
| + EXPECT_FALSE(active_layer_->tilings());
|
| + active_layer_->RecreateResources();
|
| + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
|
| }
|
|
|
| size_t NumberOfTilesRequired(PictureLayerTiling* tiling) {
|
| @@ -420,7 +416,7 @@
|
| const PictureLayerTilingSet* tilings = pending_layer_->tilings();
|
| EXPECT_GT(tilings->num_tilings(), 0u);
|
| for (size_t i = 0; i < tilings->num_tilings(); ++i)
|
| - EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty());
|
| + VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) {
|
| @@ -671,7 +667,7 @@
|
|
|
| SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region());
|
| ActivateTree();
|
| - // Add a unique tiling on the active tree.
|
| + // Add a non-shared tiling on the active tree.
|
| PictureLayerTiling* tiling = active_layer_->AddTiling(3.f);
|
| tiling->CreateAllTilesForTesting();
|
|
|
| @@ -698,16 +694,9 @@
|
| gfx::Rect(tiling->tiling_size()));
|
| iter;
|
| ++iter) {
|
| - // We don't always have a tile, but when we do it's because it was
|
| - // invalidated and it has the latest raster source.
|
| - if (*iter) {
|
| - EXPECT_FALSE(iter.geometry_rect().IsEmpty());
|
| - EXPECT_EQ(pending_pile.get(), iter->raster_source());
|
| - EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation));
|
| - } else {
|
| - // We don't create tiles in non-invalidated regions.
|
| - EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation));
|
| - }
|
| + EXPECT_TRUE(*iter);
|
| + EXPECT_FALSE(iter.geometry_rect().IsEmpty());
|
| + EXPECT_EQ(pending_pile.get(), iter->raster_source());
|
| }
|
| }
|
|
|
| @@ -725,8 +714,12 @@
|
| ++iter) {
|
| EXPECT_TRUE(*iter);
|
| EXPECT_FALSE(iter.geometry_rect().IsEmpty());
|
| - // Pile will be updated upon activation.
|
| - EXPECT_EQ(active_pile.get(), iter->raster_source());
|
| + if (iter.geometry_rect().Intersects(content_invalidation))
|
| + EXPECT_EQ(active_pile.get(), iter->raster_source());
|
| + else if (!active_layer_->GetPendingOrActiveTwinTiling(tiling))
|
| + EXPECT_EQ(active_pile.get(), iter->raster_source());
|
| + else
|
| + EXPECT_EQ(pending_pile.get(), iter->raster_source());
|
| }
|
| }
|
| }
|
| @@ -1544,15 +1537,17 @@
|
| EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
|
| }
|
|
|
| -TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) {
|
| +TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) {
|
| // The default max tile size is larger than 400x400.
|
| gfx::Size tile_size(400, 400);
|
| gfx::Size layer_bounds(5000, 5000);
|
|
|
| scoped_refptr<FakePicturePileImpl> pending_pile =
|
| FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| -
|
| - SetupPendingTree(pending_pile);
|
| + scoped_refptr<FakePicturePileImpl> active_pile =
|
| + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| +
|
| + SetupTrees(pending_pile, active_pile);
|
| EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u);
|
|
|
| pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
|
| @@ -1597,16 +1592,16 @@
|
| FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
|
|
| SetupTrees(pending_pile, active_pile);
|
| - EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u);
|
| -
|
| - active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
|
| + EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u);
|
| +
|
| + pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
|
|
|
| // The default value. The layer is smaller than this.
|
| EXPECT_EQ(gfx::Size(512, 512).ToString(),
|
| host_impl_.settings().max_untiled_layer_size.ToString());
|
|
|
| // There should be a single tile since the layer is small.
|
| - PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0);
|
| + PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0);
|
| EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size());
|
|
|
| ResetTilingsAndRasterScales();
|
| @@ -1619,18 +1614,18 @@
|
| host_impl_.InitializeRenderer(
|
| FakeOutputSurface::Create3d(context.Pass()).Pass());
|
|
|
| - SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| - ASSERT_LE(1u, active_layer_->tilings()->num_tilings());
|
| -
|
| - active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
|
| + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + ASSERT_LE(1u, pending_layer_->tilings()->num_tilings());
|
| +
|
| + pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
|
|
|
| // There should be more than one tile since the max texture size won't cover
|
| // the layer.
|
| - high_res_tiling = active_layer_->tilings()->tiling_at(0);
|
| + high_res_tiling = pending_layer_->tilings()->tiling_at(0);
|
| EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size());
|
|
|
| // Verify the tiles are not larger than the context's max texture size.
|
| - Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
|
| + Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
|
| EXPECT_GE(140, tile->content_rect().width());
|
| EXPECT_GE(140, tile->content_rect().height());
|
| }
|
| @@ -1754,7 +1749,7 @@
|
| for (; !queue->IsEmpty(); queue->Pop()) {
|
| const Tile* tile = queue->Top();
|
| DCHECK(tile);
|
| - if (tile->priority().distance_to_visible == 0.f) {
|
| + if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) {
|
| EXPECT_TRUE(tile->required_for_activation());
|
| num_visible++;
|
| } else {
|
| @@ -1819,12 +1814,10 @@
|
| pending_layer_->viewport_rect_for_tile_priority_in_content_space();
|
| viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect());
|
|
|
| - EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
|
| -
|
| int num_inside = 0;
|
| int num_outside = 0;
|
| - for (PictureLayerTiling::CoverageIterator iter(active_layer_->HighResTiling(),
|
| - 1.f, gfx::Rect(layer_bounds));
|
| + for (PictureLayerTiling::CoverageIterator iter(
|
| + pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds));
|
| iter; ++iter) {
|
| if (!*iter)
|
| continue;
|
| @@ -2053,17 +2046,18 @@
|
| EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
|
| }
|
|
|
| -TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveAllReady) {
|
| +TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) {
|
| gfx::Size layer_bounds(400, 400);
|
| gfx::Size tile_size(100, 100);
|
|
|
| + // No tiles shared.
|
| SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size,
|
| gfx::Rect(layer_bounds));
|
|
|
| active_layer_->SetAllTilesReady();
|
|
|
| - // All active tiles ready, so pending can only activate with all high res
|
| - // tiles.
|
| + // No shared tiles and all active tiles ready, so pending can only
|
| + // activate with all high res tiles.
|
| pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
|
|
| @@ -2075,7 +2069,7 @@
|
| gfx::Size layer_bounds(400, 400);
|
| gfx::Size tile_size(100, 100);
|
|
|
| - // No invalidation.
|
| + // All tiles shared (no invalidation).
|
| SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
|
|
|
| // Verify active tree not ready.
|
| @@ -2083,22 +2077,18 @@
|
| active_layer_->HighResTiling()->AllTilesForTesting()[0];
|
| EXPECT_FALSE(some_active_tile->IsReadyToDraw());
|
|
|
| - // When high res are required, all tiles in active high res tiling should be
|
| - // required for activation.
|
| + // When high res are required, even if the active tree is not ready,
|
| + // the high res tiles must be ready.
|
| host_impl_.SetRequiresHighResToDraw();
|
|
|
| pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| - active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| - active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| -
|
| - EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
|
| - EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
|
| - AssertAllTilesRequired(active_layer_->HighResTiling());
|
| - AssertNoTilesRequired(active_layer_->LowResTiling());
|
| -}
|
| -
|
| -TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) {
|
| +
|
| + AssertAllTilesRequired(pending_layer_->HighResTiling());
|
| + AssertNoTilesRequired(pending_layer_->LowResTiling());
|
| +}
|
| +
|
| +TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) {
|
| gfx::Size layer_bounds(400, 400);
|
| gfx::Size tile_size(100, 100);
|
|
|
| @@ -2108,15 +2098,13 @@
|
| active_layer_->HighResTiling()->AllTilesForTesting()[0];
|
| EXPECT_FALSE(some_active_tile->IsReadyToDraw());
|
|
|
| - // Since there are no invalidations, pending tree should have no tiles.
|
| - EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
|
| - EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
|
| -
|
| - active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| - active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| -
|
| - AssertAllTilesRequired(active_layer_->HighResTiling());
|
| - AssertNoTilesRequired(active_layer_->LowResTiling());
|
| + // All tiles shared (no invalidation), so even though the active tree's
|
| + // tiles aren't ready, the high res tiles are required for activation.
|
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| +
|
| + AssertAllTilesRequired(pending_layer_->HighResTiling());
|
| + AssertNoTilesRequired(pending_layer_->LowResTiling());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) {
|
| @@ -2129,19 +2117,15 @@
|
| active_layer_->HighResTiling()->AllTilesForTesting()[0];
|
| EXPECT_FALSE(some_active_tile->IsReadyToDraw());
|
|
|
| - EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
|
| - EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
|
| - active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
|
| - active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
|
| pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
|
| pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
|
|
|
| // If we disallow required for activation, no tiles can be required.
|
| - active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| - active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| -
|
| - AssertNoTilesRequired(active_layer_->HighResTiling());
|
| - AssertNoTilesRequired(active_layer_->LowResTiling());
|
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| +
|
| + AssertNoTilesRequired(pending_layer_->HighResTiling());
|
| + AssertNoTilesRequired(pending_layer_->LowResTiling());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
|
| @@ -2215,16 +2199,9 @@
|
| // high res tiles in order to activate.
|
| pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| - active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| - active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
|
|
| AssertAllTilesRequired(pending_layer_->HighResTiling());
|
| - AssertAllTilesRequired(active_layer_->HighResTiling());
|
| - AssertNoTilesRequired(active_layer_->LowResTiling());
|
| - // Since the test doesn't invalidate the resized region, we expect that the
|
| - // same low res tile would exist (which means we don't create a new one of the
|
| - // pending tree).
|
| - EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
|
| + AssertNoTilesRequired(pending_layer_->LowResTiling());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
|
| @@ -2293,41 +2270,40 @@
|
|
|
| // pending_tiling->CreateAllTilesForTesting();
|
|
|
| - // Tile 0,0 not exist on pending, but tile 1,1 should.
|
| - EXPECT_TRUE(active_tiling->TileAt(0, 0));
|
| - EXPECT_TRUE(active_tiling->TileAt(1, 0));
|
| - EXPECT_TRUE(active_tiling->TileAt(0, 1));
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 1));
|
| + // Tile 0,0 should be shared, but tile 1,1 should not be.
|
| + EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
|
| + EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
|
| + EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
|
| EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
|
| - EXPECT_TRUE(active_tiling->TileAt(1, 1));
|
| - EXPECT_TRUE(pending_tiling->TileAt(1, 1));
|
| -
|
| - // Drop the tiles on the active tree and recreate them.
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared());
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared());
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared());
|
| + EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared());
|
| +
|
| + // Drop the tiles on the active tree and recreate them. The same tiles
|
| + // should be shared or not.
|
| active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion());
|
| EXPECT_TRUE(active_tiling->AllTilesForTesting().empty());
|
| active_tiling->CreateAllTilesForTesting();
|
|
|
| - // Tile 0,0 not exist on pending, but tile 1,1 should.
|
| - EXPECT_TRUE(active_tiling->TileAt(0, 0));
|
| - EXPECT_TRUE(active_tiling->TileAt(1, 0));
|
| - EXPECT_TRUE(active_tiling->TileAt(0, 1));
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 1));
|
| + // Tile 0,0 should be shared, but tile 1,1 should not be.
|
| + EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
|
| + EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
|
| + EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
|
| EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
|
| - EXPECT_TRUE(active_tiling->TileAt(1, 1));
|
| - EXPECT_TRUE(pending_tiling->TileAt(1, 1));
|
| -}
|
| -
|
| -TEST_F(PictureLayerImplTest, PendingHasNoTilesWithNoInvalidation) {
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared());
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared());
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared());
|
| + EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared());
|
| +}
|
| +
|
| +TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) {
|
| SetupDefaultTrees(gfx::Size(1500, 1500));
|
|
|
| EXPECT_GE(active_layer_->num_tilings(), 1u);
|
| EXPECT_GE(pending_layer_->num_tilings(), 1u);
|
|
|
| - // No invalidation.
|
| + // No invalidation, so all tiles are shared.
|
| PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
|
| PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
|
| ASSERT_TRUE(active_tiling);
|
| @@ -2338,10 +2314,19 @@
|
| EXPECT_TRUE(active_tiling->TileAt(0, 1));
|
| EXPECT_TRUE(active_tiling->TileAt(1, 1));
|
|
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 1));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 1));
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 0));
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 0));
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 1));
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 1));
|
| +
|
| + EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
|
| + EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
|
| + EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) {
|
| @@ -2363,7 +2348,8 @@
|
| EXPECT_GE(active_layer_->num_tilings(), 1u);
|
| EXPECT_GE(pending_layer_->num_tilings(), 1u);
|
|
|
| - // The active tree invalidation was handled by the active tiles.
|
| + // The active tree invalidation was handled by the active tiles, so they
|
| + // can be shared with the pending tree.
|
| PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
|
| PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
|
| ASSERT_TRUE(active_tiling);
|
| @@ -2374,10 +2360,19 @@
|
| EXPECT_TRUE(active_tiling->TileAt(0, 1));
|
| EXPECT_TRUE(active_tiling->TileAt(1, 1));
|
|
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 1));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 1));
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 0));
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 0));
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 1));
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 1));
|
| +
|
| + EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
|
| + EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
|
| + EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) {
|
| @@ -2388,7 +2383,8 @@
|
| EXPECT_GE(active_layer_->num_tilings(), 1u);
|
| EXPECT_GE(pending_layer_->num_tilings(), 1u);
|
|
|
| - // The pending tree invalidation creates tiles on the pending tree.
|
| + // The pending tree invalidation means tiles can not be shared with the
|
| + // active tree.
|
| PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
|
| PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
|
| ASSERT_TRUE(active_tiling);
|
| @@ -2400,11 +2396,19 @@
|
| EXPECT_TRUE(active_tiling->TileAt(1, 1));
|
|
|
| EXPECT_TRUE(pending_tiling->TileAt(0, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 0));
|
| - EXPECT_FALSE(pending_tiling->TileAt(0, 1));
|
| - EXPECT_FALSE(pending_tiling->TileAt(1, 1));
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 0));
|
| + EXPECT_TRUE(pending_tiling->TileAt(0, 1));
|
| + EXPECT_TRUE(pending_tiling->TileAt(1, 1));
|
|
|
| EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
|
| + EXPECT_FALSE(active_tiling->TileAt(0, 0)->is_shared());
|
| + EXPECT_FALSE(pending_tiling->TileAt(0, 0)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
|
| + EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) {
|
| @@ -2527,16 +2531,17 @@
|
| EXPECT_TRUE(host_impl_.use_gpu_rasterization());
|
|
|
| // Should only have the high-res tiling.
|
| - EXPECT_EQ(1u, active_layer_->tilings()->num_tilings());
|
| -
|
| - active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
|
| +
|
| + active_layer_->SetAllTilesReady();
|
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
|
|
| // High res tiling should have 64 tiles (4x16 tile grid).
|
| - EXPECT_EQ(64u, active_layer_->HighResTiling()->AllTilesForTesting().size());
|
| + EXPECT_EQ(64u, pending_layer_->HighResTiling()->AllTilesForTesting().size());
|
|
|
| // Visible viewport should be covered by 4 tiles. No other
|
| // tiles should be required for activation.
|
| - EXPECT_EQ(4u, NumberOfTilesRequired(active_layer_->HighResTiling()));
|
| + EXPECT_EQ(4u, NumberOfTilesRequired(pending_layer_->HighResTiling()));
|
| }
|
|
|
| TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) {
|
| @@ -2870,7 +2875,7 @@
|
| pending_layer_->picture_layer_tiling_set(), false));
|
| while (!queue->IsEmpty()) {
|
| Tile* tile = queue->Top();
|
| - TilePriority priority = tile->priority();
|
| + TilePriority priority = tile->priority(PENDING_TREE);
|
|
|
| EXPECT_TRUE(tile);
|
|
|
| @@ -2944,7 +2949,7 @@
|
| pending_layer_->picture_layer_tiling_set(), false));
|
| while (!queue->IsEmpty()) {
|
| Tile* tile = queue->Top();
|
| - TilePriority priority = tile->priority();
|
| + TilePriority priority = tile->priority(PENDING_TREE);
|
|
|
| EXPECT_TRUE(tile);
|
|
|
| @@ -2986,7 +2991,7 @@
|
| pending_layer_->picture_layer_tiling_set(), true));
|
| while (!queue->IsEmpty()) {
|
| Tile* tile = queue->Top();
|
| - TilePriority priority = tile->priority();
|
| + TilePriority priority = tile->priority(PENDING_TREE);
|
|
|
| EXPECT_TRUE(tile);
|
|
|
| @@ -3132,7 +3137,7 @@
|
|
|
| EXPECT_TRUE(tile);
|
|
|
| - TilePriority priority = tile->priority();
|
| + TilePriority priority = tile->priority(PENDING_TREE);
|
|
|
| if (priority.priority_bin == TilePriority::NOW) {
|
| reached_visible = true;
|
| @@ -3156,7 +3161,7 @@
|
| std::abs(tile->contents_scale() - last_tile->contents_scale()) <
|
| std::numeric_limits<float>::epsilon()) {
|
| if (priority.distance_to_visible <=
|
| - last_tile->priority().distance_to_visible)
|
| + last_tile->priority(PENDING_TREE).distance_to_visible)
|
| ++distance_decreasing;
|
| else
|
| ++distance_increasing;
|
| @@ -3178,7 +3183,7 @@
|
| Tile* tile = queue->Top();
|
| EXPECT_TRUE(tile);
|
|
|
| - TilePriority priority = tile->priority();
|
| + TilePriority priority = tile->priority(PENDING_TREE);
|
| EXPECT_EQ(TilePriority::NOW, priority.priority_bin);
|
|
|
| if (reached_required) {
|
| @@ -3299,7 +3304,7 @@
|
| gfx::Size tile_size(100, 100);
|
| gfx::Size layer_bounds(1000, 1000);
|
|
|
| - // Make sure pending tree has tiles.
|
| + // Make sure some tiles are not shared.
|
| gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
|
| SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
|
|
|
| @@ -3308,14 +3313,12 @@
|
|
|
| // Initialize all low-res tiles.
|
| pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
|
| - pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling());
|
|
|
| // Low-res tiles should not be enough.
|
| EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
|
|
|
| // Initialize remaining tiles.
|
| pending_layer_->SetAllTilesReady();
|
| - active_layer_->SetAllTilesReady();
|
|
|
| EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
|
| }
|
| @@ -3324,7 +3327,7 @@
|
| gfx::Size tile_size(100, 100);
|
| gfx::Size layer_bounds(1000, 1000);
|
|
|
| - // Make sure pending tree has tiles.
|
| + // Make sure some tiles are not shared.
|
| gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
|
| SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
|
|
|
| @@ -3333,18 +3336,17 @@
|
|
|
| // Initialize all high-res tiles.
|
| pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
|
| - active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
|
|
|
| // High-res tiles should be enough, since they cover everything visible.
|
| EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
|
| }
|
|
|
| TEST_F(PictureLayerImplTest,
|
| - ActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
|
| + SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
|
| gfx::Size tile_size(100, 100);
|
| gfx::Size layer_bounds(1000, 1000);
|
|
|
| - // Make sure pending tree has tiles.
|
| + // Make sure some tiles are not shared.
|
| gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
|
| SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
|
|
|
| @@ -3353,29 +3355,29 @@
|
| // And all the low-res tiles in the pending layer.
|
| pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
|
|
|
| - // The pending high-res tiles are not ready, so we cannot activate.
|
| + // The unshared high-res tiles are not ready, so we cannot activate.
|
| EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
|
|
|
| - // When the pending high-res tiles are ready, we can activate.
|
| + // When the unshared pending high-res tiles are ready, we can activate.
|
| pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
|
| EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
|
| }
|
|
|
| -TEST_F(PictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) {
|
| +TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) {
|
| gfx::Size tile_size(100, 100);
|
| gfx::Size layer_bounds(1000, 1000);
|
|
|
| - // Make sure pending tree has tiles.
|
| + // Make sure some tiles are not shared.
|
| gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
|
| SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
|
|
|
| // Initialize all high-res tiles in the active layer.
|
| active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
|
|
|
| - // The pending high-res tiles are not ready, so we cannot activate.
|
| + // The unshared high-res tiles are not ready, so we cannot activate.
|
| EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
|
|
|
| - // When the pending pending high-res tiles are ready, we can activate.
|
| + // When the unshared pending high-res tiles are ready, we can activate.
|
| pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
|
| EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
|
| }
|
| @@ -3502,7 +3504,7 @@
|
| pending_layer_->tilings()->tiling_at(0)->contents_scale());
|
| }
|
|
|
| -TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) {
|
| +TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) {
|
| gfx::Size layer_bounds(400, 400);
|
| gfx::Size tile_size(100, 100);
|
|
|
| @@ -3512,18 +3514,15 @@
|
| active_layer_->HighResTiling()->AllTilesForTesting()[0];
|
| EXPECT_FALSE(some_active_tile->IsReadyToDraw());
|
|
|
| - // Since there is no invalidation, pending tree should have no tiles.
|
| - EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
|
| + // All tiles shared (no invalidation), so even though the active tree's
|
| + // tiles aren't ready, there is nothing required.
|
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| if (host_impl_.settings().create_low_res_tiling)
|
| - EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
|
| -
|
| - active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
|
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| +
|
| + AssertAllTilesRequired(pending_layer_->HighResTiling());
|
| if (host_impl_.settings().create_low_res_tiling)
|
| - active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
|
| -
|
| - AssertAllTilesRequired(active_layer_->HighResTiling());
|
| - if (host_impl_.settings().create_low_res_tiling)
|
| - AssertNoTilesRequired(active_layer_->LowResTiling());
|
| + AssertNoTilesRequired(pending_layer_->LowResTiling());
|
| }
|
|
|
| TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
|
| @@ -3909,10 +3908,11 @@
|
| void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer,
|
| FakePictureLayerImpl* twin_layer,
|
| WhichTree tree,
|
| - size_t expected_occluded_tile_count,
|
| - int source_line) {
|
| + size_t expected_occluded_tile_count) {
|
| + WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE;
|
| size_t occluded_tile_count = 0u;
|
| Tile* last_tile = nullptr;
|
| + std::set<Tile*> shared_tiles;
|
|
|
| scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue(
|
| layer->picture_layer_tiling_set(), layer && twin_layer));
|
| @@ -3920,32 +3920,73 @@
|
| Tile* tile = queue->Top();
|
| 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();
|
| + bool tile_is_occluded = tile->is_occluded(tree);
|
| if (tile_is_occluded) {
|
| occluded_tile_count++;
|
|
|
| - bool last_tile_is_occluded = last_tile->is_occluded();
|
| + bool last_tile_is_occluded = last_tile->is_occluded(tree);
|
| if (!last_tile_is_occluded) {
|
| TilePriority::PriorityBin tile_priority_bin =
|
| - tile->priority().priority_bin;
|
| + tile->priority(tree).priority_bin;
|
| TilePriority::PriorityBin last_tile_priority_bin =
|
| - last_tile->priority().priority_bin;
|
| + last_tile->priority(tree).priority_bin;
|
|
|
| EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin ||
|
| tile->required_for_activation() ||
|
| - tile->contents_scale() != last_tile->contents_scale())
|
| - << "line: " << source_line;
|
| + tile->contents_scale() != last_tile->contents_scale());
|
| }
|
| }
|
| last_tile = tile;
|
| queue->Pop();
|
| }
|
| - EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count)
|
| - << "line: " << source_line;
|
| + // Count also shared tiles which are occluded in the tree but which were
|
| + // not returned by the tiling set eviction queue. Those shared tiles
|
| + // shall be returned by the twin tiling set eviction queue.
|
| + queue.reset(new TilingSetEvictionQueue(
|
| + twin_layer->picture_layer_tiling_set(), layer && twin_layer));
|
| + while (!queue->IsEmpty()) {
|
| + Tile* tile = queue->Top();
|
| + if (tile->is_shared()) {
|
| + EXPECT_TRUE(shared_tiles.insert(tile).second);
|
| + if (tile->is_occluded(tree))
|
| + ++occluded_tile_count;
|
| + // Check the reasons why the shared tile was not returned by
|
| + // the first tiling set eviction queue.
|
| + const TilePriority& combined_priority = tile->combined_priority();
|
| + const TilePriority& priority = tile->priority(tree);
|
| + const TilePriority& twin_priority = tile->priority(twin_tree);
|
| + // Check if the shared tile was not returned by the first tiling
|
| + // set eviction queue because it was out of order for the first
|
| + // tiling set eviction queue but not for the twin tiling set
|
| + // eviction queue.
|
| + if (priority.priority_bin != twin_priority.priority_bin) {
|
| + EXPECT_LT(combined_priority.priority_bin, priority.priority_bin);
|
| + EXPECT_EQ(combined_priority.priority_bin, twin_priority.priority_bin);
|
| + } else if (tile->is_occluded(tree) != tile->is_occluded(twin_tree)) {
|
| + EXPECT_TRUE(tile->is_occluded(tree));
|
| + EXPECT_FALSE(tile->is_occluded(twin_tree));
|
| + EXPECT_FALSE(tile->is_occluded_combined());
|
| + } else if (priority.distance_to_visible !=
|
| + twin_priority.distance_to_visible) {
|
| + EXPECT_LT(combined_priority.distance_to_visible,
|
| + priority.distance_to_visible);
|
| + EXPECT_EQ(combined_priority.distance_to_visible,
|
| + twin_priority.distance_to_visible);
|
| + } else {
|
| + // Shared tiles having the same active and pending priorities
|
| + // should be returned only by a pending tree eviction queue.
|
| + EXPECT_EQ(ACTIVE_TREE, tree);
|
| + }
|
| + }
|
| + queue->Pop();
|
| + }
|
| + EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count);
|
| }
|
| };
|
|
|
| @@ -3975,7 +4016,7 @@
|
| Tile* tile = queue->Top();
|
|
|
| // Occluded tiles should not be iterated over.
|
| - EXPECT_FALSE(tile->is_occluded());
|
| + EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
|
|
|
| // Some tiles may not be visible (i.e. outside the viewport). The rest are
|
| // visible and at least partially unoccluded, verified by the above expect.
|
| @@ -4008,7 +4049,7 @@
|
| while (!queue->IsEmpty()) {
|
| Tile* tile = queue->Top();
|
|
|
| - EXPECT_FALSE(tile->is_occluded());
|
| + EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
|
|
|
| bool tile_is_visible =
|
| tile->content_rect().Intersects(pending_layer_->visible_content_rect());
|
| @@ -4032,7 +4073,7 @@
|
| while (!queue->IsEmpty()) {
|
| Tile* tile = queue->Top();
|
|
|
| - EXPECT_FALSE(tile->is_occluded());
|
| + EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
|
|
|
| bool tile_is_visible =
|
| tile->content_rect().Intersects(pending_layer_->visible_content_rect());
|
| @@ -4065,7 +4106,6 @@
|
| int occluded_tile_count = 0;
|
| for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
|
| PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
|
| - tiling->UpdateAllTilePrioritiesForTesting();
|
|
|
| occluded_tile_count = 0;
|
| for (PictureLayerTiling::CoverageIterator iter(
|
| @@ -4079,7 +4119,7 @@
|
| const Tile* tile = *iter;
|
|
|
| // Fully occluded tiles are not required for activation.
|
| - if (tile->is_occluded()) {
|
| + if (tile->is_occluded(PENDING_TREE)) {
|
| EXPECT_FALSE(tile->required_for_activation());
|
| occluded_tile_count++;
|
| }
|
| @@ -4117,7 +4157,7 @@
|
| continue;
|
| const Tile* tile = *iter;
|
|
|
| - if (tile->is_occluded()) {
|
| + if (tile->is_occluded(PENDING_TREE)) {
|
| EXPECT_FALSE(tile->required_for_activation());
|
| occluded_tile_count++;
|
| }
|
| @@ -4157,7 +4197,7 @@
|
| continue;
|
| const Tile* tile = *iter;
|
|
|
| - if (tile->is_occluded()) {
|
| + if (tile->is_occluded(PENDING_TREE)) {
|
| EXPECT_FALSE(tile->required_for_activation());
|
| occluded_tile_count++;
|
| }
|
| @@ -4227,7 +4267,7 @@
|
|
|
| occluded_tile_count = 0;
|
| for (size_t j = 0; j < tiles.size(); ++j) {
|
| - if (tiles[j]->is_occluded()) {
|
| + if (tiles[j]->is_occluded(PENDING_TREE)) {
|
| gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
|
| tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale());
|
| EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x());
|
| @@ -4281,33 +4321,50 @@
|
|
|
| ActivateTree();
|
|
|
| - for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
|
| - PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
|
| + // Partially invalidate the pending layer.
|
| + SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect);
|
| +
|
| + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
|
| + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
|
| tiling->UpdateAllTilePrioritiesForTesting();
|
|
|
| - for (
|
| - PictureLayerTiling::CoverageIterator iter(
|
| - tiling, active_layer_->contents_scale_x(), gfx::Rect(layer_bounds));
|
| - iter; ++iter) {
|
| + for (PictureLayerTiling::CoverageIterator iter(
|
| + tiling,
|
| + pending_layer_->contents_scale_x(),
|
| + gfx::Rect(layer_bounds));
|
| + iter;
|
| + ++iter) {
|
| if (!*iter)
|
| continue;
|
| const Tile* tile = *iter;
|
|
|
| + // All tiles are unoccluded on the pending tree.
|
| + EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
|
| +
|
| + Tile* twin_tile = pending_layer_->GetPendingOrActiveTwinTiling(tiling)
|
| + ->TileAt(iter.i(), iter.j());
|
| gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
|
| tile->content_rect(), 1.0f / tile->contents_scale());
|
| - // Tiles are occluded on the active tree iff they lie beneath the
|
| - // occluding layer.
|
| - EXPECT_EQ(tile->is_occluded(),
|
| - scaled_content_rect.x() >= occluding_layer_position.x());
|
| +
|
| + if (scaled_content_rect.Intersects(invalidation_rect)) {
|
| + // Tiles inside the invalidation rect are only on the pending tree.
|
| + EXPECT_NE(tile, twin_tile);
|
| +
|
| + // Unshared tiles should be unoccluded on the active tree by default.
|
| + EXPECT_FALSE(tile->is_occluded(ACTIVE_TREE));
|
| + } else {
|
| + // Tiles outside the invalidation rect are shared between both trees.
|
| + EXPECT_EQ(tile, twin_tile);
|
| + // Shared tiles are occluded on the active tree iff they lie beneath the
|
| + // occluding layer.
|
| + EXPECT_EQ(tile->is_occluded(ACTIVE_TREE),
|
| + scaled_content_rect.x() >= occluding_layer_position.x());
|
| + }
|
| }
|
| }
|
| -
|
| - // Partially invalidate the pending layer.
|
| - SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect);
|
|
|
| for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
|
| PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
|
| - tiling->UpdateAllTilePrioritiesForTesting();
|
|
|
| for (PictureLayerTiling::CoverageIterator iter(
|
| tiling,
|
| @@ -4319,24 +4376,24 @@
|
| continue;
|
| const Tile* tile = *iter;
|
|
|
| - // All tiles are unoccluded, because the pending tree has no occlusion.
|
| - EXPECT_FALSE(tile->is_occluded());
|
| - EXPECT_FALSE(tile->is_occluded());
|
| -
|
| Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling)
|
| ->TileAt(iter.i(), iter.j());
|
| gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
|
| tile->content_rect(), 1.0f / tile->contents_scale());
|
|
|
| + // Since we've already checked the shared tiles, only consider tiles in
|
| + // the invalidation rect.
|
| if (scaled_content_rect.Intersects(invalidation_rect)) {
|
| - // Tiles inside the invalidation rect exist on both trees.
|
| - EXPECT_TRUE(tile);
|
| - EXPECT_TRUE(twin_tile);
|
| + // Tiles inside the invalidation rect are only on the active tree.
|
| EXPECT_NE(tile, twin_tile);
|
| - } else {
|
| - // Tiles outside the invalidation rect only exist on the active tree.
|
| - EXPECT_TRUE(tile);
|
| - EXPECT_FALSE(twin_tile);
|
| +
|
| + // Unshared tiles should be unoccluded on the pending tree by default.
|
| + EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
|
| +
|
| + // Unshared tiles are occluded on the active tree iff they lie beneath
|
| + // the occluding layer.
|
| + EXPECT_EQ(tile->is_occluded(ACTIVE_TREE),
|
| + scaled_content_rect.x() >= occluding_layer_position.x());
|
| }
|
| }
|
| }
|
| @@ -4354,7 +4411,7 @@
|
| gfx::Size viewport_size(1000, 1000);
|
| gfx::Point pending_occluding_layer_position(310, 0);
|
| gfx::Point active_occluding_layer_position(0, 310);
|
| - gfx::Rect invalidation_rect(230, 230, 152, 152);
|
| + gfx::Rect invalidation_rect(230, 230, 102, 102);
|
|
|
| host_impl_.SetViewportSize(viewport_size);
|
| host_impl_.SetDeviceScaleFactor(2.f);
|
| @@ -4378,7 +4435,7 @@
|
| ActivateTree();
|
|
|
| // Partially invalidate the pending layer. Tiles inside the invalidation rect
|
| - // are created.
|
| + // are not shared between trees.
|
| SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect);
|
|
|
| // Partially occlude the pending layer in a different way.
|
| @@ -4402,9 +4459,11 @@
|
|
|
| // The expected number of occluded tiles on each of the 2 tilings for each of
|
| // the 3 tree priorities.
|
| - size_t expected_occluded_tile_count_on_pending[] = {4u, 0u};
|
| - size_t expected_occluded_tile_count_on_active[] = {12u, 1u};
|
| - size_t total_expected_occluded_tile_count_on_trees[] = {13u, 4u};
|
| + size_t expected_occluded_tile_count_on_both[] = {9u, 1u};
|
| + size_t expected_occluded_tile_count_on_active[] = {30u, 3u};
|
| + size_t expected_occluded_tile_count_on_pending[] = {30u, 3u};
|
| +
|
| + size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u};
|
|
|
| // Verify number of occluded tiles on the pending layer for each tiling.
|
| for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
|
| @@ -4412,24 +4471,31 @@
|
| tiling->UpdateAllTilePrioritiesForTesting();
|
|
|
| size_t occluded_tile_count_on_pending = 0u;
|
| + size_t occluded_tile_count_on_active = 0u;
|
| + size_t occluded_tile_count_on_both = 0u;
|
| for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f,
|
| gfx::Rect(layer_bounds));
|
| iter; ++iter) {
|
| Tile* tile = *iter;
|
|
|
| - if (invalidation_rect.Intersects(iter.geometry_rect()))
|
| - EXPECT_TRUE(tile);
|
| - else
|
| - EXPECT_FALSE(tile);
|
| -
|
| if (!tile)
|
| continue;
|
| - if (tile->is_occluded())
|
| + if (tile->is_occluded(PENDING_TREE))
|
| occluded_tile_count_on_pending++;
|
| + if (tile->is_occluded(ACTIVE_TREE))
|
| + occluded_tile_count_on_active++;
|
| + if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE))
|
| + occluded_tile_count_on_both++;
|
| }
|
| EXPECT_EQ(expected_occluded_tile_count_on_pending[i],
|
| occluded_tile_count_on_pending)
|
| << tiling->contents_scale();
|
| + EXPECT_EQ(expected_occluded_tile_count_on_active[i],
|
| + occluded_tile_count_on_active)
|
| + << tiling->contents_scale();
|
| + EXPECT_EQ(expected_occluded_tile_count_on_both[i],
|
| + occluded_tile_count_on_both)
|
| + << tiling->contents_scale();
|
| }
|
|
|
| // Verify number of occluded tiles on the active layer for each tiling.
|
| @@ -4437,7 +4503,9 @@
|
| PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
|
| tiling->UpdateAllTilePrioritiesForTesting();
|
|
|
| + size_t occluded_tile_count_on_pending = 0u;
|
| size_t occluded_tile_count_on_active = 0u;
|
| + size_t occluded_tile_count_on_both = 0u;
|
| for (PictureLayerTiling::CoverageIterator iter(
|
| tiling,
|
| pending_layer_->contents_scale_x(),
|
| @@ -4448,11 +4516,21 @@
|
|
|
| if (!tile)
|
| continue;
|
| - if (tile->is_occluded())
|
| + if (tile->is_occluded(PENDING_TREE))
|
| + occluded_tile_count_on_pending++;
|
| + if (tile->is_occluded(ACTIVE_TREE))
|
| occluded_tile_count_on_active++;
|
| + if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE))
|
| + occluded_tile_count_on_both++;
|
| }
|
| + EXPECT_EQ(expected_occluded_tile_count_on_pending[i],
|
| + occluded_tile_count_on_pending)
|
| + << i;
|
| EXPECT_EQ(expected_occluded_tile_count_on_active[i],
|
| occluded_tile_count_on_active)
|
| + << i;
|
| + EXPECT_EQ(expected_occluded_tile_count_on_both[i],
|
| + occluded_tile_count_on_both)
|
| << i;
|
| }
|
|
|
| @@ -4462,39 +4540,32 @@
|
| std::vector<Tile*> tiles = tiling->AllTilesForTesting();
|
| all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end());
|
| }
|
| - for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
|
| - PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
|
| - std::vector<Tile*> tiles = tiling->AllTilesForTesting();
|
| - all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end());
|
| - }
|
|
|
| host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
|
|
|
| VerifyEvictionConsidersOcclusion(
|
| pending_layer_, active_layer_, PENDING_TREE,
|
| - total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
|
| + total_expected_occluded_tile_count_on_trees[PENDING_TREE]);
|
| VerifyEvictionConsidersOcclusion(
|
| active_layer_, pending_layer_, ACTIVE_TREE,
|
| - total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
|
| + total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]);
|
|
|
| // Repeat the tests without valid active tree priorities.
|
| active_layer_->set_has_valid_tile_priorities(false);
|
| VerifyEvictionConsidersOcclusion(
|
| pending_layer_, active_layer_, PENDING_TREE,
|
| - total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
|
| + total_expected_occluded_tile_count_on_trees[PENDING_TREE]);
|
| VerifyEvictionConsidersOcclusion(
|
| - active_layer_, pending_layer_, ACTIVE_TREE,
|
| - total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
|
| + active_layer_, pending_layer_, ACTIVE_TREE, 0u);
|
| active_layer_->set_has_valid_tile_priorities(true);
|
|
|
| // Repeat the tests without valid pending tree priorities.
|
| pending_layer_->set_has_valid_tile_priorities(false);
|
| VerifyEvictionConsidersOcclusion(
|
| active_layer_, pending_layer_, ACTIVE_TREE,
|
| - total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
|
| + total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]);
|
| VerifyEvictionConsidersOcclusion(
|
| - pending_layer_, active_layer_, PENDING_TREE,
|
| - total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
|
| + pending_layer_, active_layer_, PENDING_TREE, 0u);
|
| pending_layer_->set_has_valid_tile_priorities(true);
|
| }
|
|
|
| @@ -4723,13 +4794,6 @@
|
| if (*iter)
|
| tiles.push_back(*iter);
|
| }
|
| - for (PictureLayerTiling::CoverageIterator iter(
|
| - active_layer_->HighResTiling(), 1.f,
|
| - active_layer_->HighResTiling()->GetCurrentVisibleRectForTesting());
|
| - iter; ++iter) {
|
| - if (*iter)
|
| - tiles.push_back(*iter);
|
| - }
|
|
|
| host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
|
|
|
| @@ -4759,8 +4823,8 @@
|
| PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling();
|
| PictureLayerTiling* active_tiling = active_layer_->HighResTiling();
|
|
|
| - // We should have all tiles on active, and none on pending.
|
| - EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size());
|
| + // We should have all tiles in both tile sets.
|
| + EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
|
| EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
|
|
|
| // Now put a partially-recorded pile on the pending tree (and invalidate
|
| @@ -4788,19 +4852,16 @@
|
| SetupPendingTreeWithFixedTileSize(filled_pile, tile_size,
|
| Region(gfx::Rect(layer_bounds)));
|
| EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
|
| - Tile* tile00 = pending_tiling->TileAt(0, 0);
|
| - Tile* tile11 = pending_tiling->TileAt(1, 1);
|
| - Tile* tile22 = pending_tiling->TileAt(2, 2);
|
|
|
| // Active is not affected yet.
|
| EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
|
|
|
| - // Activate the tree. The tiles are moved to the active tree.
|
| + // Activate the tree. The tiles are created and shared on the active tree.
|
| ActivateTree();
|
| EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
|
| - EXPECT_EQ(tile00, active_tiling->TileAt(0, 0));
|
| - EXPECT_EQ(tile11, active_tiling->TileAt(1, 1));
|
| - EXPECT_EQ(tile22, active_tiling->TileAt(2, 2));
|
| + EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared());
|
| + EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
|
| + EXPECT_TRUE(active_tiling->TileAt(2, 2)->is_shared());
|
| }
|
|
|
| class TileSizeSettings : public ImplSidePaintingSettings {
|
|
|