From b87b0c84b5545817e7338d1a2e220863878343bb Mon Sep 17 00:00:00 2001 From: "danakj@chromium.org" Date: Wed, 15 May 2013 08:48:18 +0000 Subject: cc: Don't add tilings to layers without recordings. Before calling PictureLayerImpl::AddTiling() the layer checks to make sure it has a recording, as this should be an invariant for adding a tiling. Code paths to sync tilings were not checking this however, and causing DCHECKs to fire as a result. Any time we add a tiling, we must check that we are able to do so by verifying: 1) The contents scale of the tiling is large enough. 2) The layer has a recording (and is non-empty). 3) The layer DrawsContents() The first was already verified, the second was not, and the third was only in some situations. R=enne BUG=240361 Review URL: https://chromiumcodereview.appspot.com/14813034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200205 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/layers/picture_layer_impl.cc | 27 +++++++++++++++++++++++---- cc/layers/picture_layer_impl.h | 3 +++ cc/resources/picture_layer_tiling.cc | 6 +++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 8c50b94..00bb878 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -548,13 +548,15 @@ void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { invalidation_.Union(difference_region); tilings_->RemoveAllTilings(); - tilings_->AddTilingsToMatchScales(*other->tilings_, MinimumContentsScale()); + if (CanHaveTilings()) + tilings_->AddTilingsToMatchScales(*other->tilings_, MinimumContentsScale()); + DCHECK(bounds() == tilings_->layer_bounds()); } void PictureLayerImpl::SyncTiling( const PictureLayerTiling* tiling) { - if (!DrawsContent() || tiling->contents_scale() < MinimumContentsScale()) + if (!CanHaveTilingWithScale(tiling->contents_scale())) return; tilings_->AddTiling(tiling->contents_scale()); @@ -652,7 +654,8 @@ bool PictureLayerImpl::AreVisibleResourcesReady() const { } PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { - DCHECK(contents_scale >= MinimumContentsScale()); + DCHECK(CanHaveTilingWithScale(contents_scale)) << + "contents_scale: " << contents_scale; PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); @@ -703,7 +706,7 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { DCHECK(ideal_device_scale_); DCHECK(ideal_source_scale_); - if (pile_->recorded_region().IsEmpty()) + if (!CanHaveTilings()) return; bool change_target_tiling = @@ -943,6 +946,22 @@ void PictureLayerImpl::ResetRasterScale() { low_res_raster_contents_scale_ = 0.f; } +bool PictureLayerImpl::CanHaveTilings() const { + if (!DrawsContent()) + return false; + if (pile_->recorded_region().IsEmpty()) + return false; + return true; +} + +bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { + if (!CanHaveTilings()) + return false; + if (contents_scale < MinimumContentsScale()) + return false; + return true; +} + void PictureLayerImpl::GetDebugBorderProperties( SkColor* color, float* width) const { diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index 736ba60..f982ea8 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -94,6 +94,9 @@ class CC_EXPORT PictureLayerImpl void UpdateLCDTextStatus(); void ResetRasterScale(); + bool CanHaveTilings() const; + bool CanHaveTilingWithScale(float contents_scale) const; + virtual void GetDebugBorderProperties( SkColor* color, float* width) const OVERRIDE; virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc index 678a0fa..1a041f2 100644 --- a/cc/resources/picture_layer_tiling.cc +++ b/cc/resources/picture_layer_tiling.cc @@ -44,9 +44,9 @@ PictureLayerTiling::PictureLayerTiling(float contents_scale, DCHECK(!gfx::ToFlooredSize( gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << - "Tiling created with scale too small as contents become empty. " << - "Layer bounds: " << layer_bounds.ToString() << - "Contents scale: " << contents_scale; + "Tiling created with scale too small as contents become empty." << + " Layer bounds: " << layer_bounds.ToString() << + " Contents scale: " << contents_scale; tiling_data_.SetTotalSize(content_bounds); tiling_data_.SetMaxTextureSize(tile_size); -- cgit v1.1