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 2b9457b019fe60f6862711d97893cd87f7bda4c0..6c889701c9e414e2f30c86c8ded4da023d4f6aab 100644 |
| --- a/cc/layers/picture_layer_impl_unittest.cc |
| +++ b/cc/layers/picture_layer_impl_unittest.cc |
| @@ -1388,27 +1388,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); |
| @@ -1421,44 +1400,23 @@ 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); |
| - |
| 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_.SetCurrentBeginFrameArgs( |
| + CreateBeginFrameArgsForTesting(time_ticks)); |
| + pending_layer_->UpdateTiles(Occlusion()); |
| + 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()); |
| num_visible++; |
| @@ -1515,8 +1473,6 @@ TEST_F(PictureLayerImplTest, TileOutsideOfViewportForTilePriorityNotRequired) { |
| CreateBeginFrameArgsForTesting(time_ticks)); |
| pending_layer_->UpdateTiles(Occlusion()); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| - |
| // Intersect the two rects. Any tile outside should not be required for |
| // activation. |
| gfx::Rect viewport_for_tile_priority = |
| @@ -1727,8 +1683,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()); |
| } |
| @@ -1748,8 +1706,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()); |
| } |
| @@ -1766,8 +1727,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()); |
| } |
| @@ -1796,8 +1759,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()); |
| } |
| @@ -1821,8 +1786,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()); |
| } |
| @@ -1835,13 +1802,18 @@ TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
| pending_layer_->SetBounds(pending_layer_bounds); |
| CreateHighLowResAndSetAllTilesVisible(); |
| + pending_layer_->HighResTiling()->UpdateTilePriorities( |
| + PENDING_TREE, gfx::Rect(pending_layer_bounds), 1.f, 1.f, Occlusion()); |
| + 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()); |
| } |
| @@ -2691,7 +2663,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++; |
| } |
| @@ -2906,7 +2878,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()); |
| @@ -2934,7 +2905,6 @@ TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
| CreateHighLowResAndSetAllTilesVisible(); |
| active_layer_->SetAllTilesReady(); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| // All pending layer tiles required are not ready. |
| EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| @@ -2963,8 +2933,6 @@ TEST_F(PictureLayerImplTest, |
| // And all the low-res tiles in the pending layer. |
| pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| - |
| // The unshared high-res tiles are not ready, so we cannot activate. |
| EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| @@ -2987,8 +2955,6 @@ TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { |
| // Initialize all high-res tiles in the active layer. |
| active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| - pending_layer_->MarkVisibleResourcesAsRequired(); |
| - |
| // The unshared high-res tiles are not ready, so we cannot activate. |
| EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| @@ -3063,27 +3029,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); |
| @@ -3097,9 +3042,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()); |
| } |
| } |
| @@ -3130,10 +3076,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, |
| @@ -3709,7 +3657,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| if (tile_is_visible) |
| unoccluded_tile_count++; |
| } |
| - EXPECT_EQ(unoccluded_tile_count, 20 + 2); |
| + EXPECT_EQ(20 + 2, unoccluded_tile_count); |
| // Full occlusion. |
| layer1->SetPosition(gfx::Point(0, 0)); |
| @@ -3797,6 +3745,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( |
| @@ -3836,6 +3785,8 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, |
| for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| + tiling->UpdateAllTilePrioritiesForTesting(); |
| + tiling->UpdateAllTilePrioritiesForTesting(); |
|
reveman
2014/09/17 15:44:45
2 calls to UpdateAllTilePrioritiesForTesting inten
|
| occluded_tile_count = 0; |
| for (PictureLayerTiling::CoverageIterator iter( |
| @@ -3855,10 +3806,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(); |
| @@ -3905,6 +3856,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; |
| @@ -3972,6 +3924,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, |
| @@ -4116,6 +4069,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; |
| @@ -4150,6 +4104,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; |