Index: cc/layers/picture_layer_impl.cc |
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc |
index 0ec80686b8dc87069fd123bd1cb5cffb7084c3ef..d0d34616969f67cb36d19ea296cdaf83b93603ab 100644 |
--- a/cc/layers/picture_layer_impl.cc |
+++ b/cc/layers/picture_layer_impl.cc |
@@ -60,6 +60,7 @@ PictureLayerImpl::Pair::~Pair() { |
PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
: LayerImpl(tree_impl, id), |
twin_layer_(NULL), |
+ recycled_twin_layer_(NULL), |
pile_(PicturePileImpl::Create()), |
is_mask_(false), |
ideal_page_scale_(0.f), |
@@ -109,8 +110,10 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { |
LayerImpl::PushPropertiesTo(base_layer); |
// When the pending tree pushes to the active tree, the pending twin |
- // disappears. |
+ // becomes recycled. |
layer_impl->twin_layer_ = NULL; |
+ layer_impl->recycled_twin_layer_ = this; |
+ DCHECK(!recycled_twin_layer_); |
twin_layer_ = NULL; |
layer_impl->SetIsMask(is_mask_); |
@@ -610,6 +613,19 @@ const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( |
return NULL; |
} |
+PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( |
+ const PictureLayerTiling* tiling) const { |
+ if (!recycled_twin_layer_ || !recycled_twin_layer_->tilings_) |
+ return NULL; |
+ for (size_t i = 0; i < recycled_twin_layer_->tilings_->num_tilings(); ++i) { |
enne (OOO)
2014/08/22 21:36:09
I think you're looking for recycled_twin_layer_->t
vmpstr
2014/08/22 22:47:30
Ah, that's easier.
|
+ if (recycled_twin_layer_->tilings_->tiling_at(i)->contents_scale() == |
+ tiling->contents_scale()) { |
+ return recycled_twin_layer_->tilings_->tiling_at(i); |
+ } |
+ } |
+ return NULL; |
+} |
+ |
size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { |
return layer_tree_impl()->settings().max_tiles_for_interest_area; |
} |
@@ -946,6 +962,9 @@ void PictureLayerImpl::DoPostCommitInitialization() { |
if (twin_layer_) { |
DCHECK(!twin_layer_->twin_layer_); |
twin_layer_->twin_layer_ = this; |
+ DCHECK(!twin_layer_->recycled_twin_layer_ || |
+ twin_layer_->recycled_twin_layer_ == this); |
+ twin_layer_->recycled_twin_layer_ = NULL; |
// 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_) |
@@ -1250,8 +1269,6 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( |
if (to_remove.empty()) |
return; |
- PictureLayerImpl* recycled_twin = static_cast<PictureLayerImpl*>( |
- layer_tree_impl()->FindRecycleTreeLayerById(id())); |
// Remove tilings on this tree and the twin tree. |
for (size_t i = 0; i < to_remove.size(); ++i) { |
const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); |
@@ -1261,8 +1278,8 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( |
twin->RemoveTiling(to_remove[i]->contents_scale()); |
// Remove the tiling from the recycle tree. Note that we ignore resolution, |
// since we don't need to maintain high/low res on the recycle tree. |
- if (recycled_twin) |
- recycled_twin->RemoveTiling(to_remove[i]->contents_scale()); |
+ if (recycled_twin_layer_) |
+ recycled_twin_layer_->RemoveTiling(to_remove[i]->contents_scale()); |
// TODO(enne): temporary sanity CHECK for http://crbug.com/358350 |
CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); |
tilings_->Remove(to_remove[i]); |