Commit 71618ed3 authored by vmpstr@chromium.org's avatar vmpstr@chromium.org

(Reland) cc: Remove recycled tilings 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.

This includes a check in RemoveTilings for NULL tilings. When the first
pending tree activates, it swaps with active tree's NULL tilings, which
become the recycle tilings. When removing tilings, we have to ensure
that tilings is not NULL before accessing its members.

BUG=393802
R=danakj, enne

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285114 0039d316-1c4b-4281-b951-d872f2087c98
parent bdcca37a
......@@ -936,6 +936,9 @@ PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
}
void PictureLayerImpl::RemoveTiling(float contents_scale) {
if (!tilings_ || tilings_->num_tilings() == 0)
return;
for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
PictureLayerTiling* tiling = tilings_->tiling_at(i);
if (tiling->contents_scale() == contents_scale) {
......@@ -1195,18 +1198,28 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
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) {
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)
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
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();
}
......@@ -1255,6 +1268,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;
......
......@@ -296,6 +296,7 @@ class CC_EXPORT LayerTreeHostImpl
const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
LayerTreeImpl* pending_tree() { 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(); }
// Returns the tree LTH synchronizes with.
LayerTreeImpl* sync_tree() {
......
......@@ -723,6 +723,13 @@ LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int 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 {
return layer_tree_host_impl_->GetRendererCapabilities().max_texture_size;
}
......
......@@ -81,6 +81,7 @@ class CC_EXPORT LayerTreeImpl {
bool IsRecycleTree() const;
LayerImpl* FindActiveTreeLayerById(int id);
LayerImpl* FindPendingTreeLayerById(int id);
LayerImpl* FindRecycleTreeLayerById(int id);
int MaxTextureSize() const;
bool PinchGestureActive() 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