diff options
author | vmpstr <vmpstr@chromium.org> | 2015-04-02 12:28:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-02 19:33:51 +0000 |
commit | 074006a706461a22204fbdf183161819f416290b (patch) | |
tree | 659b0cb331cd5d5fce164f079dcfd26d288ca2c6 /cc/resources | |
parent | 9b580384b806134526d7baf6f5f6eff19a8eafdd (diff) | |
download | chromium_src-074006a706461a22204fbdf183161819f416290b.zip chromium_src-074006a706461a22204fbdf183161819f416290b.tar.gz chromium_src-074006a706461a22204fbdf183161819f416290b.tar.bz2 |
cc: Separate tiling set functionality into explicit separate functions.
This patch separates UpdateTilingsToCurrentRaster source into three
separate functions, so that it is clear when each one is meant to run:
- UpdateTilingsToCurrentRasterSourceForCommit(raster_source, invalidation)
This function is called during PictureLayer::PushPropertiesTo to on
the sync tree (either pending or active).
- UpdateTilingsToCurrentRasterSourceForActivation(
raster_source, pending_twin_set, invalidation)
This function is called during PictureLayerImpl::PushPropertiesTo on
the active tree only.
- UpdateRasterSourceDueToLCDChange(raster_source, invalidation)
This function is called on the sync tree when the LCD flag changes.
The raster source in this case is of the same size as previously set
but has lcd flag changed.
R=danakj, enne
Review URL: https://codereview.chromium.org/1041893003
Cr-Commit-Position: refs/heads/master@{#323550}
Diffstat (limited to 'cc/resources')
-rw-r--r-- | cc/resources/picture_layer_tiling.cc | 7 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling.h | 1 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling_set.cc | 69 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling_set.h | 24 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling_set_unittest.cc | 29 |
5 files changed, 91 insertions, 39 deletions
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc index 171a8cb..4f1c8e6 100644 --- a/cc/resources/picture_layer_tiling.cc +++ b/cc/resources/picture_layer_tiling.cc @@ -852,6 +852,13 @@ void PictureLayerTiling::UpdateRequiredStateForTile(Tile* tile, tile->set_is_occluded(tree, false); } +void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { +#if DCHECK_IS_ON() + for (const auto& tile_pair : tiles_) + DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); +#endif +} + TilePriority PictureLayerTiling::ComputePriorityForTile( const Tile* tile) const { // TODO(vmpstr): See if this can be moved to iterators. diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h index ea258a3..c05185a 100644 --- a/cc/resources/picture_layer_tiling.h +++ b/cc/resources/picture_layer_tiling.h @@ -161,6 +161,7 @@ class CC_EXPORT PictureLayerTiling { const gfx::Rect& current_eventually_rect() const { return current_eventually_rect_; } + void VerifyAllTilesHaveCurrentRasterSource() const; // Iterate over all tiles to fill content_rect. Even if tiles are invalid // (i.e. no valid resource) this tiling should still iterate over them. diff --git a/cc/resources/picture_layer_tiling_set.cc b/cc/resources/picture_layer_tiling_set.cc index e616ce2..93d85f7b 100644 --- a/cc/resources/picture_layer_tiling_set.cc +++ b/cc/resources/picture_layer_tiling_set.cc @@ -53,7 +53,7 @@ PictureLayerTilingSet::PictureLayerTilingSet( PictureLayerTilingSet::~PictureLayerTilingSet() { } -void PictureLayerTilingSet::CopyTilingsFromPendingTwin( +void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin( const PictureLayerTilingSet* pending_twin_set, const scoped_refptr<RasterSource>& raster_source) { if (pending_twin_set->tilings_.empty()) { @@ -61,8 +61,10 @@ void PictureLayerTilingSet::CopyTilingsFromPendingTwin( // current frame. So we drop tilings from our set as well, instead of // leaving behind unshared tilings that are all non-ideal. RemoveAllTilings(); + return; } + bool tiling_sort_required = false; for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) { float contents_scale = pending_twin_tiling->contents_scale(); PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); @@ -73,12 +75,16 @@ void PictureLayerTilingSet::CopyTilingsFromPendingTwin( skewport_extrapolation_limit_in_content_pixels_); tilings_.push_back(new_tiling.Pass()); this_tiling = tilings_.back(); + tiling_sort_required = true; } this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling); } + + if (tiling_sort_required) + tilings_.sort(LargestToSmallestScaleFunctor()); } -void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( +void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( scoped_refptr<RasterSource> raster_source, const PictureLayerTilingSet* pending_twin_set, const Region& layer_invalidation, @@ -87,19 +93,15 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( RemoveTilingsBelowScale(minimum_contents_scale); RemoveTilingsAboveScale(maximum_contents_scale); - // Copy over tilings that are shared with the |pending_twin_set| tiling set - // (if it exists). - if (pending_twin_set) - CopyTilingsFromPendingTwin(pending_twin_set, raster_source); + // Copy over tilings that are shared with the |pending_twin_set| tiling set. + // Also, copy all of the properties from twin tilings. + CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source); - // If the tiling is not shared (FindTilingWithScale returns nullptr) or if - // |this| is the sync set (pending_twin_set is nullptr), then invalidate - // tiles and update them to the new raster source. + // If the tiling is not shared (FindTilingWithScale returns nullptr), then + // invalidate tiles and update them to the new raster source. for (PictureLayerTiling* tiling : tilings_) { - if (pending_twin_set && - pending_twin_set->FindTilingWithScale(tiling->contents_scale())) { + if (pending_twin_set->FindTilingWithScale(tiling->contents_scale())) continue; - } tiling->SetRasterSourceAndResize(raster_source); tiling->Invalidate(layer_invalidation); @@ -109,14 +111,47 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( // raster source. tiling->CreateMissingTilesInLiveTilesRect(); - // If |pending_twin_set| is present, then |this| is active and |tiling| is - // not in the pending set, which means it is now NON_IDEAL_RESOLUTION. - if (pending_twin_set) - tiling->set_resolution(NON_IDEAL_RESOLUTION); + // |this| is active set and |tiling| is not in the pending set, which means + // it is now NON_IDEAL_RESOLUTION. + tiling->set_resolution(NON_IDEAL_RESOLUTION); } - tilings_.sort(LargestToSmallestScaleFunctor()); + VerifyTilings(pending_twin_set); +} + +void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( + scoped_refptr<RasterSource> raster_source, + const Region& layer_invalidation, + float minimum_contents_scale, + float maximum_contents_scale) { + RemoveTilingsBelowScale(minimum_contents_scale); + RemoveTilingsAboveScale(maximum_contents_scale); + + // Invalidate tiles and update them to the new raster source. + for (PictureLayerTiling* tiling : tilings_) { + tiling->SetRasterSourceAndResize(raster_source); + tiling->Invalidate(layer_invalidation); + tiling->SetRasterSourceOnTiles(); + // This is needed for cases where the live tiles rect didn't change but + // recordings exist in the raster source that did not exist on the last + // raster source. + tiling->CreateMissingTilesInLiveTilesRect(); + } + VerifyTilings(nullptr /* pending_twin_set */); +} + +void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( + const scoped_refptr<RasterSource>& raster_source, + const Region& layer_invalidation) { + for (PictureLayerTiling* tiling : tilings_) { + tiling->SetRasterSourceAndResize(raster_source); + tiling->Invalidate(layer_invalidation); + tiling->VerifyAllTilesHaveCurrentRasterSource(); + } +} +void PictureLayerTilingSet::VerifyTilings( + const PictureLayerTilingSet* pending_twin_set) const { #if DCHECK_IS_ON() for (PictureLayerTiling* tiling : tilings_) { DCHECK(tiling->tile_size() == diff --git a/cc/resources/picture_layer_tiling_set.h b/cc/resources/picture_layer_tiling_set.h index 24da44d..d4d55a3 100644 --- a/cc/resources/picture_layer_tiling_set.h +++ b/cc/resources/picture_layer_tiling_set.h @@ -55,19 +55,26 @@ class CC_EXPORT PictureLayerTilingSet { PictureLayerTilingSet* recycled_twin_set); void RemoveNonIdealTilings(); - // This function can be called on both the active and pending tree. - // |pending_twin_set| represents the current pending twin. In situations where - // this is called on the active tree in two trees situations, - // |pending_twin_set| represents the tiling set from the pending twin layer. - // In situations where this is called on the sync tree (whether it's pending - // or active in cases of one tree), |pending_twin_set| should be nullptr. - void UpdateTilingsToCurrentRasterSource( + // This function is called on the active tree during activation. + void UpdateTilingsToCurrentRasterSourceForActivation( scoped_refptr<RasterSource> raster_source, const PictureLayerTilingSet* pending_twin_set, const Region& layer_invalidation, float minimum_contents_scale, float maximum_contents_scale); + // This function is called on the sync tree during commit. + void UpdateTilingsToCurrentRasterSourceForCommit( + scoped_refptr<RasterSource> raster_source, + const Region& layer_invalidation, + float minimum_contents_scale, + float maximum_contents_scale); + + // This function is called on the sync tree right after commit. + void UpdateRasterSourceDueToLCDChange( + const scoped_refptr<RasterSource>& raster_source, + const Region& layer_invalidation); + PictureLayerTiling* AddTiling(float contents_scale, scoped_refptr<RasterSource> raster_source); size_t num_tilings() const { return tilings_.size(); } @@ -170,12 +177,13 @@ class CC_EXPORT PictureLayerTilingSet { float skewport_target_time_in_seconds, int skewport_extrapolation_limit_in_content_pixels); - void CopyTilingsFromPendingTwin( + void CopyTilingsAndPropertiesFromPendingTwin( const PictureLayerTilingSet* pending_twin_set, const scoped_refptr<RasterSource>& raster_source); // Remove one tiling. void Remove(PictureLayerTiling* tiling); + void VerifyTilings(const PictureLayerTilingSet* pending_twin_set) const; ScopedPtrVector<PictureLayerTiling> tilings_; diff --git a/cc/resources/picture_layer_tiling_set_unittest.cc b/cc/resources/picture_layer_tiling_set_unittest.cc index 3cafa4c..2eceb71 100644 --- a/cc/resources/picture_layer_tiling_set_unittest.cc +++ b/cc/resources/picture_layer_tiling_set_unittest.cc @@ -337,8 +337,8 @@ TEST(PictureLayerTilingSetTest, TileSizeChange) { // Update to a new source frame with a new tile size. pending_client.SetTileSize(tile_size2); - pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), - 1.f, 1.f); + pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), Region(), + 1.f, 1.f); // The tiling should get the correct tile size. EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); @@ -355,8 +355,8 @@ TEST(PictureLayerTilingSetTest, TileSizeChange) { // Clone from the pending to the active tree. active_client.SetTileSize(tile_size2); - active_set->UpdateTilingsToCurrentRasterSource(pile.get(), pending_set.get(), - Region(), 1.f, 1.f); + active_set->UpdateTilingsToCurrentRasterSourceForActivation( + pile.get(), pending_set.get(), Region(), 1.f, 1.f); // The active tiling should get the right tile size. EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); @@ -369,8 +369,8 @@ TEST(PictureLayerTilingSetTest, TileSizeChange) { // A new source frame with a new tile size. pending_client.SetTileSize(tile_size3); - pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), - 1.f, 1.f); + pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), Region(), + 1.f, 1.f); // The tiling gets the new size correctly. EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); @@ -387,8 +387,8 @@ TEST(PictureLayerTilingSetTest, TileSizeChange) { // Now we activate with a different tile size for the active tiling. active_client.SetTileSize(tile_size3); - active_set->UpdateTilingsToCurrentRasterSource(pile.get(), pending_set.get(), - Region(), 1.f, 1.f); + active_set->UpdateTilingsToCurrentRasterSourceForActivation( + pile.get(), pending_set.get(), Region(), 1.f, 1.f); // The active tiling changes its tile size. EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); @@ -423,13 +423,14 @@ TEST(PictureLayerTilingSetTest, MaxContentScale) { // Update to a new source frame with a max content scale that is larger than // everything. float max_content_scale = 3.f; - pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), - 1.f, max_content_scale); + pending_set->UpdateTilingsToCurrentRasterSourceForCommit( + pile.get(), Region(), 1.f, max_content_scale); + // All the tilings are there still. EXPECT_EQ(3u, pending_set->num_tilings()); // Clone from the pending to the active tree with the same max content size. - active_set->UpdateTilingsToCurrentRasterSource( + active_set->UpdateTilingsToCurrentRasterSourceForActivation( pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); // All the tilings are on the active tree. EXPECT_EQ(3u, active_set->num_tilings()); @@ -437,15 +438,15 @@ TEST(PictureLayerTilingSetTest, MaxContentScale) { // Update to a new source frame with a max content scale that will drop one // tiling. max_content_scale = 2.9f; - pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), - 1.f, max_content_scale); + pending_set->UpdateTilingsToCurrentRasterSourceForCommit( + pile.get(), Region(), 1.f, max_content_scale); // All the tilings are there still. EXPECT_EQ(2u, pending_set->num_tilings()); pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); // Clone from the pending to the active tree with the same max content size. - active_set->UpdateTilingsToCurrentRasterSource( + active_set->UpdateTilingsToCurrentRasterSourceForActivation( pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); // All the tilings are on the active tree. EXPECT_EQ(2u, active_set->num_tilings()); |