Commit 5e034244 authored by vmpstr@chromium.org's avatar vmpstr@chromium.org

cc: Remove tilings from recycle tree when active tree removes them.

This patch is the second part of ensuring that recycle tree does not
contain any unshared tiles.

This is done by removing recycle tree tilings when active tree removes
those tilings.

BUG=393802
R=danakj

Review URL: https://codereview.chromium.org/400633004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284311 0039d316-1c4b-4281-b951-d872f2087c98
parent 2adf1996
...@@ -1195,18 +1195,28 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( ...@@ -1195,18 +1195,28 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
to_remove.push_back(tiling); to_remove.push_back(tiling);
} }
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) { for (size_t i = 0; i < to_remove.size(); ++i) {
const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]);
// Only remove tilings from the twin layer if they have // Only remove tilings from the twin layer if they have
// NON_IDEAL_RESOLUTION. // NON_IDEAL_RESOLUTION.
if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION)
twin->RemoveTiling(to_remove[i]->contents_scale()); 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());
// TODO(enne): temporary sanity CHECK for http://crbug.com/358350 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350
CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution());
tilings_->Remove(to_remove[i]); tilings_->Remove(to_remove[i]);
} }
DCHECK_GT(tilings_->num_tilings(), 0u);
DCHECK_GT(tilings_->num_tilings(), 0u);
SanityCheckTilingState(); SanityCheckTilingState();
} }
...@@ -1255,6 +1265,10 @@ bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { ...@@ -1255,6 +1265,10 @@ bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const {
void PictureLayerImpl::SanityCheckTilingState() const { void PictureLayerImpl::SanityCheckTilingState() const {
#if DCHECK_IS_ON #if DCHECK_IS_ON
// Recycle tree doesn't have any restrictions.
if (layer_tree_impl()->IsRecycleTree())
return;
if (!CanHaveTilings()) { if (!CanHaveTilings()) {
DCHECK_EQ(0u, tilings_->num_tilings()); DCHECK_EQ(0u, tilings_->num_tilings());
return; return;
......
...@@ -296,6 +296,7 @@ class CC_EXPORT LayerTreeHostImpl ...@@ -296,6 +296,7 @@ class CC_EXPORT LayerTreeHostImpl
const LayerTreeImpl* active_tree() const { return active_tree_.get(); } const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
LayerTreeImpl* pending_tree() { return pending_tree_.get(); } LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
LayerTreeImpl* recycle_tree() { return recycle_tree_.get(); }
const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
// Returns the tree LTH synchronizes with. // Returns the tree LTH synchronizes with.
LayerTreeImpl* sync_tree() { LayerTreeImpl* sync_tree() {
......
...@@ -718,6 +718,13 @@ LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { ...@@ -718,6 +718,13 @@ LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) {
return tree->LayerById(id); return tree->LayerById(id);
} }
LayerImpl* LayerTreeImpl::FindRecycleTreeLayerById(int id) {
LayerTreeImpl* tree = layer_tree_host_impl_->recycle_tree();
if (!tree)
return NULL;
return tree->LayerById(id);
}
int LayerTreeImpl::MaxTextureSize() const { int LayerTreeImpl::MaxTextureSize() const {
return layer_tree_host_impl_->GetRendererCapabilities().max_texture_size; return layer_tree_host_impl_->GetRendererCapabilities().max_texture_size;
} }
......
...@@ -81,6 +81,7 @@ class CC_EXPORT LayerTreeImpl { ...@@ -81,6 +81,7 @@ class CC_EXPORT LayerTreeImpl {
bool IsRecycleTree() const; bool IsRecycleTree() const;
LayerImpl* FindActiveTreeLayerById(int id); LayerImpl* FindActiveTreeLayerById(int id);
LayerImpl* FindPendingTreeLayerById(int id); LayerImpl* FindPendingTreeLayerById(int id);
LayerImpl* FindRecycleTreeLayerById(int id);
int MaxTextureSize() const; int MaxTextureSize() const;
bool PinchGestureActive() const; bool PinchGestureActive() const;
base::TimeTicks CurrentFrameTimeTicks() const; base::TimeTicks CurrentFrameTimeTicks() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment