Commit 350219ee authored by daplatz's avatar daplatz Committed by Commit bot

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}
parent b2b11fde
...@@ -109,6 +109,7 @@ Daniel Carvalho Liedke <dliedke@gmail.com> ...@@ -109,6 +109,7 @@ Daniel Carvalho Liedke <dliedke@gmail.com>
Daniel Imms <daniimms@amazon.com> Daniel Imms <daniimms@amazon.com>
Daniel Johnson <danielj41@gmail.com> Daniel Johnson <danielj41@gmail.com>
Daniel Nishi <dhnishi@gmail.com> Daniel Nishi <dhnishi@gmail.com>
Daniel Platz <daplatz@googlemail.com>
Daniel Shaulov <dshaulov@ptc.com> Daniel Shaulov <dshaulov@ptc.com>
Daniel Trebbien <dtrebbien@gmail.com> Daniel Trebbien <dtrebbien@gmail.com>
Darshini KN <kn.darshini@samsung.com> Darshini KN <kn.darshini@samsung.com>
......
...@@ -68,17 +68,21 @@ void DebugRectHistory::SavePaintRects(LayerImpl* layer) { ...@@ -68,17 +68,21 @@ void DebugRectHistory::SavePaintRects(LayerImpl* layer) {
// not. Therefore we traverse recursively over all layers, not just the render // not. Therefore we traverse recursively over all layers, not just the render
// surface list. // 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() / float width_scale = layer->content_bounds().width() /
static_cast<float>(layer->bounds().width()); static_cast<float>(layer->bounds().width());
float height_scale = layer->content_bounds().height() / float height_scale = layer->content_bounds().height() /
static_cast<float>(layer->bounds().height()); static_cast<float>(layer->bounds().height());
gfx::Rect update_content_rect = gfx::ScaleToEnclosingRect(
layer->update_rect(), width_scale, height_scale); for (Region::Iterator it(invalidation_region); it.has_rect(); it.next()) {
debug_rects_.push_back( gfx::Rect update_content_rect =
DebugRect(PAINT_RECT_TYPE, gfx::ScaleToEnclosingRect(it.rect(), width_scale, height_scale);
MathUtil::MapEnclosingClippedRect( debug_rects_.push_back(
layer->screen_space_transform(), update_content_rect))); DebugRect(PAINT_RECT_TYPE,
MathUtil::MapEnclosingClippedRect(
layer->screen_space_transform(), update_content_rect)));
}
} }
for (unsigned i = 0; i < layer->children().size(); ++i) for (unsigned i = 0; i < layer->children().size(); ++i)
......
...@@ -1590,4 +1590,8 @@ void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { ...@@ -1590,4 +1590,8 @@ void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) {
render_surface_.reset(); render_surface_.reset();
} }
Region LayerImpl::GetInvalidationRegion() {
return Region(update_rect_);
}
} // namespace cc } // namespace cc
...@@ -596,6 +596,10 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, ...@@ -596,6 +596,10 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
SyncedScrollOffset* synced_scroll_offset() { return scroll_offset_.get(); } 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: protected:
LayerImpl(LayerTreeImpl* layer_impl, LayerImpl(LayerTreeImpl* layer_impl,
int id, int id,
......
...@@ -605,6 +605,15 @@ skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { ...@@ -605,6 +605,15 @@ skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
return raster_source_->GetFlattenedPicture(); 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( scoped_refptr<Tile> PictureLayerImpl::CreateTile(
float contents_scale, float contents_scale,
const gfx::Rect& content_rect) { const gfx::Rect& content_rect) {
......
...@@ -61,6 +61,7 @@ class CC_EXPORT PictureLayerImpl ...@@ -61,6 +61,7 @@ class CC_EXPORT PictureLayerImpl
void ReleaseResources() override; void ReleaseResources() override;
void RecreateResources() override; void RecreateResources() override;
skia::RefPtr<SkPicture> GetPicture() override; skia::RefPtr<SkPicture> GetPicture() override;
Region GetInvalidationRegion() override;
// PictureLayerTilingClient overrides. // PictureLayerTilingClient overrides.
scoped_refptr<Tile> CreateTile(float contents_scale, scoped_refptr<Tile> CreateTile(float contents_scale,
......
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