Index: cc/layers/picture_layer_impl.cc |
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc |
index 02fb92fb735dce8d5048487eebe38ab6800c7706..9259dc4afe3321419c18eb88b465ca1b9e74b4b2 100644 |
--- a/cc/layers/picture_layer_impl.cc |
+++ b/cc/layers/picture_layer_impl.cc |
@@ -1201,6 +1201,10 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( |
to_remove.push_back(tiling); |
} |
+ if (to_remove.empty()) |
+ return; |
+ |
+ // 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]); |
// Only remove tilings from the twin layer if they have |
@@ -1211,9 +1215,19 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( |
CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); |
tilings_->Remove(to_remove[i]); |
} |
- DCHECK_GT(tilings_->num_tilings(), 0u); |
+ DCHECK_GT(tilings_->num_tilings(), 0u); |
SanityCheckTilingState(); |
+ |
+ // Also remove tilings from the recycle tree to ensure that recycle tree |
+ // doesn't have any unshared tiles. |
+ PictureLayerImpl* recycled_twin = static_cast<PictureLayerImpl*>( |
+ layer_tree_impl()->FindRecycleTreeLayerById(id())); |
+ if (!recycled_twin) |
+ return; |
+ |
+ for (size_t i = 0; i < to_remove.size(); ++i) |
+ recycled_twin->RemoveTiling(to_remove[i]->contents_scale()); |
danakj
2014/07/17 22:22:49
er, wait, to_remove[i] is a use-after-free here, c
vmpstr
2014/07/17 22:30:59
Hmm.. that's not good. Good thing my testing worke
|
} |
float PictureLayerImpl::MinimumContentsScale() const { |
@@ -1261,6 +1275,10 @@ bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
void PictureLayerImpl::SanityCheckTilingState() const { |
#if DCHECK_IS_ON |
+ // Recycle tree doesn't have any restrictions. |
+ if (layer_tree_impl()->IsRecycleTree()) |
+ return; |
+ |
if (!CanHaveTilings()) { |
DCHECK_EQ(0u, tilings_->num_tilings()); |
return; |