diff options
author | daplatz <daplatz@googlemail.com> | 2015-03-04 11:04:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-04 19:05:19 +0000 |
commit | 350219ee4e5d02ca86f2f898172411f7da3d6902 (patch) | |
tree | 3ee8db7bfef29287e9859eedf1df3fe4ea537a52 | |
parent | b2b11fdea2692c93392b48cbfacce749efc99cf2 (diff) | |
download | chromium_src-350219ee4e5d02ca86f2f898172411f7da3d6902.zip chromium_src-350219ee4e5d02ca86f2f898172411f7da3d6902.tar.gz chromium_src-350219ee4e5d02ca86f2f898172411f7da3d6902.tar.bz2 |
Draw correct repaint regions instead of a conservative bounding box
Previously, the update_rect() of the LayerImpl was used for the repaint
regions in the DebugRectHistory; now the base LayerImpl class defines a
virtual method giving back an invalidation Region that is overwritten by
PictureLayerImpl to use the already existent invalidations_ Region.
Regions give a more tighter bound on the invalidations than the
single conservative rect that was used before on a per-layer basis.
BUG=424682
Review URL: https://codereview.chromium.org/958843004
Cr-Commit-Position: refs/heads/master@{#319094}
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | cc/debug/debug_rect_history.cc | 18 | ||||
-rw-r--r-- | cc/layers/layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/layers/layer_impl.h | 4 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 9 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.h | 1 |
6 files changed, 30 insertions, 7 deletions
@@ -109,6 +109,7 @@ Daniel Carvalho Liedke <dliedke@gmail.com> Daniel Imms <daniimms@amazon.com> Daniel Johnson <danielj41@gmail.com> Daniel Nishi <dhnishi@gmail.com> +Daniel Platz <daplatz@googlemail.com> Daniel Shaulov <dshaulov@ptc.com> Daniel Trebbien <dtrebbien@gmail.com> Darshini KN <kn.darshini@samsung.com> diff --git a/cc/debug/debug_rect_history.cc b/cc/debug/debug_rect_history.cc index 22a612c..c257c60 100644 --- a/cc/debug/debug_rect_history.cc +++ b/cc/debug/debug_rect_history.cc @@ -68,17 +68,21 @@ void DebugRectHistory::SavePaintRects(LayerImpl* layer) { // not. Therefore we traverse recursively over all layers, not just the render // surface list. - if (!layer->update_rect().IsEmpty() && layer->DrawsContent()) { + Region invalidation_region = layer->GetInvalidationRegion(); + if (!invalidation_region.IsEmpty() && layer->DrawsContent()) { float width_scale = layer->content_bounds().width() / static_cast<float>(layer->bounds().width()); float height_scale = layer->content_bounds().height() / static_cast<float>(layer->bounds().height()); - gfx::Rect update_content_rect = gfx::ScaleToEnclosingRect( - layer->update_rect(), width_scale, height_scale); - debug_rects_.push_back( - DebugRect(PAINT_RECT_TYPE, - MathUtil::MapEnclosingClippedRect( - layer->screen_space_transform(), update_content_rect))); + + for (Region::Iterator it(invalidation_region); it.has_rect(); it.next()) { + gfx::Rect update_content_rect = + gfx::ScaleToEnclosingRect(it.rect(), width_scale, height_scale); + debug_rects_.push_back( + DebugRect(PAINT_RECT_TYPE, + MathUtil::MapEnclosingClippedRect( + layer->screen_space_transform(), update_content_rect))); + } } for (unsigned i = 0; i < layer->children().size(); ++i) diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 0c6ddf5..0353a78 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -1590,4 +1590,8 @@ void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { render_surface_.reset(); } +Region LayerImpl::GetInvalidationRegion() { + return Region(update_rect_); +} + } // namespace cc diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 5de0d9a..0357252 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -596,6 +596,10 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, SyncedScrollOffset* synced_scroll_offset() { return scroll_offset_.get(); } + // Get the correct invalidation region instead of conservative Rect + // for layers that provide it. + virtual Region GetInvalidationRegion(); + protected: LayerImpl(LayerTreeImpl* layer_impl, int id, diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index e819afd..76b9c0a 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -605,6 +605,15 @@ skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { return raster_source_->GetFlattenedPicture(); } +Region PictureLayerImpl::GetInvalidationRegion() { + // |invalidation_| gives the invalidation contained in the source frame, but + // is not cleared after drawing from the layer. However, update_rect() is + // cleared once the invalidation is drawn, which is useful for debugging + // visualizations. This method intersects the two to give a more exact + // representation of what was invalidated that is cleared after drawing. + return IntersectRegions(invalidation_, update_rect()); +} + scoped_refptr<Tile> PictureLayerImpl::CreateTile( float contents_scale, const gfx::Rect& content_rect) { diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index 9500e22..397cb62 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -61,6 +61,7 @@ class CC_EXPORT PictureLayerImpl void ReleaseResources() override; void RecreateResources() override; skia::RefPtr<SkPicture> GetPicture() override; + Region GetInvalidationRegion() override; // PictureLayerTilingClient overrides. scoped_refptr<Tile> CreateTile(float contents_scale, |