From 23d8593f8127411d9d687b4565b34b4ecd6b11d3 Mon Sep 17 00:00:00 2001 From: schenney Date: Fri, 6 Mar 2015 16:20:28 -0800 Subject: Update SkPicture cull rects with RTree information When computed, the RTree for an SkPicture will have a root bounds that reflects the best bounding information available, rather than the best estimate at the time the picture recorder is created. Given that creators frequently don't know ahead of time what will be drawn, the RTree bound is often tighter. Perf testing on Chrome indicates a small raster performance advantage. For upcoming painting changes in Chrome the performance advantage is much larger. BUG= Committed: https://skia.googlesource.com/skia/+/2dd3b6647dc726f36fd8774b3d0d2e83b493aeac Review URL: https://codereview.chromium.org/971803002 --- src/core/SkRecordDraw.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/core/SkRecordDraw.cpp') diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index 9b08426670..ba15c1b512 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -248,7 +248,11 @@ private: Bounds clip = SkRect::Make(devBounds); // We don't call adjustAndMap() because as its last step it would intersect the adjusted // clip bounds with the previous clip, exactly what we can't do when the clip grows. - fCurrentClipBounds = this->adjustForSaveLayerPaints(&clip) ? clip : fCullRect; + if (this->adjustForSaveLayerPaints(&clip)) { + fCurrentClipBounds = clip.intersect(fCullRect) ? clip : Bounds::MakeEmpty(); + } else { + fCurrentClipBounds = fCullRect; + } } // Restore holds the devBounds for the clip after the {save,saveLayer}/restore block completes. @@ -259,8 +263,11 @@ private: // so they are not affected by the saveLayer's paint. const int kSavesToIgnore = 1; Bounds clip = SkRect::Make(op.devBounds); - fCurrentClipBounds = - this->adjustForSaveLayerPaints(&clip, kSavesToIgnore) ? clip : fCullRect; + if (this->adjustForSaveLayerPaints(&clip, kSavesToIgnore)) { + fCurrentClipBounds = clip.intersect(fCullRect) ? clip : Bounds::MakeEmpty(); + } else { + fCurrentClipBounds = fCullRect; + } } // We also take advantage of SaveLayer bounds when present to further cut the clip down. @@ -387,8 +394,12 @@ private: Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOps don't draw. - Bounds bounds(const DrawSprite& op) const { // Ignores the matrix. - return Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.height()); + Bounds bounds(const DrawSprite& op) const { // Ignores the matrix, but respects the clip. + SkRect rect = Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.height()); + if (!rect.intersect(fCurrentClipBounds)) { + return Bounds::MakeEmpty(); + } + return rect; } Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } -- cgit v1.2.3