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 5eae6a6c52ae72d544d5985f29221da8d7b4562d..10c51ca5b3ed24ea6cbc095120e9c320a6b47052 100644 |
| --- a/cc/layers/picture_layer_impl_unittest.cc |
| +++ b/cc/layers/picture_layer_impl_unittest.cc |
| @@ -1366,27 +1366,6 @@ TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { |
| EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); |
| } |
| -TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { |
| - gfx::Size tile_size(100, 100); |
| - gfx::Size layer_bounds(1000, 1000); |
| - |
| - scoped_refptr<FakePicturePileImpl> pending_pile = |
| - FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| - // Layers with entirely empty piles can't get tilings. |
| - pending_pile->AddRecordingAt(0, 0); |
| - |
| - SetupPendingTree(pending_pile); |
| - |
| - ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| - pending_layer_->AddTiling(1.0f); |
| - pending_layer_->AddTiling(2.0f); |
| - |
| - // It should be safe to call this (and MarkVisibleResourcesAsRequired) |
| - // on a layer with no recordings. |
| - host_impl_.pending_tree()->UpdateDrawProperties(); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| -} |
| - |
| TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
| gfx::Size tile_size(100, 100); |
| gfx::Size layer_bounds(200, 200); |
| @@ -1399,44 +1378,22 @@ TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
| ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
| host_impl_.pending_tree()->UpdateDrawProperties(); |
| - EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); |
|
danakj
2014/08/18 19:29:13
Why not?
|
| - |
| pending_layer_->draw_properties().visible_content_rect = |
| gfx::Rect(0, 0, 100, 200); |
| - |
| - // Fake set priorities. |
| - for (PictureLayerTiling::CoverageIterator iter( |
| - tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
| - iter; |
| - ++iter) { |
| - if (!*iter) |
| - continue; |
| - Tile* tile = *iter; |
| - TilePriority priority; |
| - priority.resolution = HIGH_RESOLUTION; |
| - gfx::Rect tile_bounds = iter.geometry_rect(); |
| - if (pending_layer_->visible_content_rect().Intersects(tile_bounds)) { |
| - priority.priority_bin = TilePriority::NOW; |
| - priority.distance_to_visible = 0.f; |
| - } else { |
| - priority.priority_bin = TilePriority::SOON; |
| - priority.distance_to_visible = 1.f; |
| - } |
| - tile->SetPriority(PENDING_TREE, priority); |
| - } |
| - |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + base::TimeTicks time_ticks; |
| + time_ticks += base::TimeDelta::FromMilliseconds(16); |
| + host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| + pending_layer_->UpdateTiles(NULL); |
| + EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); |
| int num_visible = 0; |
| int num_offscreen = 0; |
| - for (PictureLayerTiling::CoverageIterator iter( |
| - tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
| + for (PictureLayerTiling::TilingRasterTileIterator iter(tiling, PENDING_TREE); |
| iter; |
| ++iter) { |
| - if (!*iter) |
| - continue; |
| const Tile* tile = *iter; |
| + DCHECK(tile); |
| if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
| EXPECT_TRUE(tile->required_for_activation()); |
|
danakj
2014/08/18 19:29:13
Why isn't this doing tiling->IsTileRequiredForActi
vmpstr
2014/08/18 19:49:52
The idea, which is kind of subtle unfortunately is
|
| num_visible++; |
| @@ -1464,8 +1421,10 @@ TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { |
| // No shared tiles and all active tiles ready, so pending can only |
| // activate with all high res tiles. |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| + |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| } |
| @@ -1485,8 +1444,11 @@ TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
| // When high res are required, even if the active tree is not ready, |
| // the high res tiles must be ready. |
| host_impl_.active_tree()->SetRequiresHighResToDraw(); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| + |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| } |
| @@ -1503,8 +1465,10 @@ TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
| // All tiles shared (no invalidation), so even though the active tree's |
| // tiles aren't ready, there is nothing required. |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->HighResTiling()); |
| + |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| } |
| @@ -1533,8 +1497,10 @@ TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| // Since the active layer has no tiles at all, the pending layer doesn't |
| // need content in order to activate. |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->HighResTiling()); |
| + |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| } |
| @@ -1558,8 +1524,10 @@ TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
| // to the case where there is no active layer, to avoid flashing content. |
| // This can happen if a layer exists for a while and switches from |
| // not being able to have content to having content. |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| + |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| } |
| @@ -1572,13 +1540,24 @@ TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
| pending_layer_->SetBounds(pending_layer_bounds); |
| CreateHighLowResAndSetAllTilesVisible(); |
| + pending_layer_->HighResTiling()->UpdateTilePriorities( |
|
danakj
2014/08/18 19:29:13
Can you explain why this is needed here but Update
vmpstr
2014/08/18 19:49:52
This is for the tiling to get new bounds. All othe
|
| + PENDING_TREE, |
| + gfx::Rect(pending_layer_bounds), |
| + 1.f, |
| + 1.f, |
| + NULL, |
| + NULL, |
| + gfx::Transform()); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| active_layer_->SetAllTilesReady(); |
| // Since the active layer has different bounds, the pending layer needs all |
| // high res tiles in order to activate. |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| + |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| } |
| @@ -2266,7 +2245,7 @@ TEST_F(PictureLayerImplTest, LayerEvictionTileIterator) { |
| ++iter) { |
| if (mark_required) { |
| number_of_marked_tiles++; |
| - iter->MarkRequiredForActivation(); |
| + iter->set_required_for_activation(true); |
| } else { |
| number_of_unmarked_tiles++; |
| } |
| @@ -2481,7 +2460,6 @@ TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| CreateHighLowResAndSetAllTilesVisible(); |
| active_layer_->SetAllTilesReady(); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| // All pending layer tiles required are not ready. |
| EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| @@ -2509,7 +2487,6 @@ TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { |
| CreateHighLowResAndSetAllTilesVisible(); |
| active_layer_->SetAllTilesReady(); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| // All pending layer tiles required are not ready. |
| EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| @@ -2517,8 +2494,8 @@ TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { |
| // Initialize all high-res tiles. |
| pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| - // High-res tiles should not be enough. |
| - EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| + // High-res tiles is enough. |
| + EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| // Initialize remaining tiles. |
| pending_layer_->SetAllTilesReady(); |
| @@ -2597,27 +2574,6 @@ TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
| pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| } |
| -TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) { |
| - gfx::Size tile_size(100, 100); |
| - gfx::Size layer_bounds(1000, 1000); |
| - |
| - scoped_refptr<FakePicturePileImpl> pending_pile = |
| - FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| - // Layers with entirely empty piles can't get tilings. |
| - pending_pile->AddRecordingAt(0, 0); |
| - |
| - SetupPendingTree(pending_pile); |
| - |
| - ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| - pending_layer_->AddTiling(1.0f); |
| - pending_layer_->AddTiling(2.0f); |
| - |
| - // It should be safe to call this (and MarkVisibleResourcesAsRequired) |
| - // on a layer with no recordings. |
| - host_impl_.pending_tree()->UpdateDrawProperties(); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| -} |
| - |
| TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
| gfx::Size layer_bounds(400, 400); |
| gfx::Size tile_size(100, 100); |
| @@ -2631,9 +2587,10 @@ TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
| // All tiles shared (no invalidation), so even though the active tree's |
| // tiles aren't ready, there is nothing required. |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->HighResTiling()); |
| if (host_impl_.settings().create_low_res_tiling) { |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| } |
| } |
| @@ -2664,10 +2621,12 @@ TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| // Since the active layer has no tiles at all, the pending layer doesn't |
| // need content in order to activate. |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| + pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->HighResTiling()); |
| - if (host_impl_.settings().create_low_res_tiling) |
| + if (host_impl_.settings().create_low_res_tiling) { |
| + pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| + } |
| } |
| TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
| @@ -3311,6 +3270,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 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( |
| @@ -3330,10 +3290,10 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| } |
| switch (i) { |
| case 0: |
| - EXPECT_EQ(occluded_tile_count, 5); |
| + EXPECT_EQ(5, occluded_tile_count); |
| break; |
| case 1: |
| - EXPECT_EQ(occluded_tile_count, 2); |
| + EXPECT_EQ(2, occluded_tile_count); |
| break; |
| default: |
| NOTREACHED(); |
| @@ -3349,6 +3309,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 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( |
| @@ -3368,10 +3329,10 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| } |
| switch (i) { |
| case 0: |
| - EXPECT_EQ(occluded_tile_count, 25); |
| + EXPECT_EQ(25, occluded_tile_count); |
| break; |
| case 1: |
| - EXPECT_EQ(occluded_tile_count, 4); |
| + EXPECT_EQ(4, occluded_tile_count); |
| break; |
| default: |
| NOTREACHED(); |
| @@ -3418,6 +3379,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { |
| tilings.begin(); |
| tiling_iterator != tilings.end(); |
| ++tiling_iterator) { |
| + (*tiling_iterator)->UpdateAllTilePrioritiesForTesting(); |
| std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
| occluded_tile_count = 0; |
| @@ -3485,6 +3447,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { |
| 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, |
| @@ -3629,6 +3592,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| tiling->CreateAllTilesForTesting(); |
| + tiling->UpdateAllTilePrioritiesForTesting(); |
| size_t occluded_tile_count_on_pending = 0u; |
| size_t occluded_tile_count_on_active = 0u; |
| @@ -3663,6 +3627,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| tiling->CreateAllTilesForTesting(); |
| + tiling->UpdateAllTilePrioritiesForTesting(); |
| size_t occluded_tile_count_on_pending = 0u; |
| size_t occluded_tile_count_on_active = 0u; |