| Index: cc/layers/picture_layer_impl.cc
|
| diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
|
| index 6556afa8f37c1fa158a36c46c1b29d8fb4967044..e51821fbc92a7d2b8f13536998b41210f141003d 100644
|
| --- a/cc/layers/picture_layer_impl.cc
|
| +++ b/cc/layers/picture_layer_impl.cc
|
| @@ -90,8 +90,6 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id)
|
| }
|
|
|
| PictureLayerImpl::~PictureLayerImpl() {
|
| - if (twin_layer_)
|
| - twin_layer_->twin_layer_ = nullptr;
|
| layer_tree_impl()->UnregisterPictureLayerImpl(this);
|
| }
|
|
|
| @@ -112,15 +110,10 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
|
|
|
| LayerImpl::PushPropertiesTo(base_layer);
|
|
|
| - // Twin relationships should never change once established.
|
| - DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl);
|
| - DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this);
|
| - // The twin relationship does not need to exist before the first
|
| - // PushPropertiesTo from pending to active layer since before that the active
|
| - // layer can not have a pile or tilings, it has only been created and inserted
|
| - // into the tree at that point.
|
| - twin_layer_ = layer_impl;
|
| - layer_impl->twin_layer_ = this;
|
| + // When the pending tree pushes to the active tree, the pending twin
|
| + // becomes recycled.
|
| + layer_impl->twin_layer_ = nullptr;
|
| + twin_layer_ = nullptr;
|
|
|
| layer_impl->pile_ = pile_;
|
|
|
| @@ -568,16 +561,10 @@ gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const {
|
| return visible_rect_in_content_space;
|
| }
|
|
|
| -PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const {
|
| - if (!twin_layer_ || !twin_layer_->IsOnActiveOrPendingTree())
|
| - return nullptr;
|
| - return twin_layer_;
|
| -}
|
| -
|
| -PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const {
|
| - if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree())
|
| - return nullptr;
|
| - return twin_layer_;
|
| +PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() {
|
| + // TODO(vmpstr): Maintain recycled twin as a member. crbug.com/407418
|
| + return static_cast<PictureLayerImpl*>(
|
| + layer_tree_impl()->FindRecycleTreeLayerById(id()));
|
| }
|
|
|
| void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) {
|
| @@ -645,21 +632,15 @@ PicturePileImpl* PictureLayerImpl::GetPile() {
|
| return pile_.get();
|
| }
|
|
|
| -const Region* PictureLayerImpl::GetPendingInvalidation() {
|
| - if (layer_tree_impl()->IsPendingTree())
|
| - return &invalidation_;
|
| - DCHECK(layer_tree_impl()->IsActiveTree());
|
| - if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer())
|
| - return &twin_layer->invalidation_;
|
| - return nullptr;
|
| +const Region* PictureLayerImpl::GetInvalidation() {
|
| + return &invalidation_;
|
| }
|
|
|
| -const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling(
|
| +const PictureLayerTiling* PictureLayerImpl::GetTwinTiling(
|
| const PictureLayerTiling* tiling) const {
|
| - PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer();
|
| - if (!twin_layer)
|
| + if (!twin_layer_)
|
| return nullptr;
|
| - return twin_layer->tilings_->TilingAtScale(tiling->contents_scale());
|
| + return twin_layer_->tilings_->TilingAtScale(tiling->contents_scale());
|
| }
|
|
|
| PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling(
|
| @@ -864,12 +845,16 @@ void PictureLayerImpl::DoPostCommitInitialization() {
|
| if (!tilings_)
|
| tilings_ = make_scoped_ptr(new PictureLayerTilingSet(this));
|
|
|
| - PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer();
|
| - if (twin_layer) {
|
| + DCHECK(!twin_layer_);
|
| + twin_layer_ = static_cast<PictureLayerImpl*>(
|
| + layer_tree_impl()->FindActiveTreeLayerById(id()));
|
| + if (twin_layer_) {
|
| + DCHECK(!twin_layer_->twin_layer_);
|
| + twin_layer_->twin_layer_ = this;
|
| // If the twin has never been pushed to, do not sync from it.
|
| // This can happen if this function is called during activation.
|
| - if (!twin_layer->needs_post_commit_initialization_)
|
| - SyncFromActiveLayer(twin_layer);
|
| + if (!twin_layer_->needs_post_commit_initialization_)
|
| + SyncFromActiveLayer(twin_layer_);
|
| }
|
|
|
| needs_post_commit_initialization_ = false;
|
| @@ -883,8 +868,8 @@ PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
|
|
|
| DCHECK(pile_->HasRecordings());
|
|
|
| - if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer())
|
| - twin_layer->SyncTiling(tiling);
|
| + if (twin_layer_)
|
| + twin_layer_->SyncTiling(tiling);
|
|
|
| return tiling;
|
| }
|
| @@ -1128,7 +1113,7 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
|
| raster_contents_scale_, ideal_contents_scale_);
|
| float twin_low_res_scale = 0.f;
|
|
|
| - PictureLayerImpl* twin = GetPendingOrActiveTwinLayer();
|
| + PictureLayerImpl* twin = twin_layer_;
|
| if (twin && twin->CanHaveTilings()) {
|
| min_acceptable_high_res_scale = std::min(
|
| min_acceptable_high_res_scale,
|
| @@ -1175,8 +1160,7 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
|
| PictureLayerImpl* recycled_twin = GetRecycledTwinLayer();
|
| // Remove tilings on this tree and the twin tree.
|
| for (size_t i = 0; i < to_remove.size(); ++i) {
|
| - const PictureLayerTiling* twin_tiling =
|
| - GetPendingOrActiveTwinTiling(to_remove[i]);
|
| + const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]);
|
| // Only remove tilings from the twin layer if they have
|
| // NON_IDEAL_RESOLUTION.
|
| if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION)
|
|
|