Allow user-specified clip region for SkiaBitLocker
This allows us to allocate a smaller region when painting native
controls on Mac.
BUG=247716
Review URL: https://codereview.chromium.org/462423006
Cr-Commit-Position: refs/heads/master@{#291226}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291226 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/skia/ext/skia_utils_mac.h b/skia/ext/skia_utils_mac.h
index 6a0efdeb..e087867 100644
--- a/skia/ext/skia_utils_mac.h
+++ b/skia/ext/skia_utils_mac.h
@@ -109,16 +109,36 @@
class SK_API SkiaBitLocker {
public:
explicit SkiaBitLocker(SkCanvas* canvas);
+ SkiaBitLocker(SkCanvas* canvas, const SkIRect& userClipRect);
~SkiaBitLocker();
CGContextRef cgContext();
+ bool hasEmptyClipRegion() const;
private:
void releaseIfNeeded();
+ SkIRect computeDirtyRect();
+
SkCanvas* canvas_;
+
+ // If the user specified a clip rect it would draw into then the locker may
+ // skip the step of searching for a rect bounding the pixels that the user
+ // has drawn into.
+ bool userClipRectSpecified_;
+
CGContextRef cgContext_;
SkBitmap bitmap_;
SkIPoint bitmapOffset_;
+
+ // True if we are drawing to |canvas_|'s SkBaseDevice's bits directly through
+ // |bitmap_|. Otherwise, the bits in |bitmap_| are our allocation and need to
+ // be copied over to |canvas_|.
bool useDeviceBits_;
+
+ // True if |bitmap_| is a dummy 1x1 bitmap allocated for the sake of creating
+ // a non-NULL CGContext (it is invalid to use a NULL CGContext), and will not
+ // be copied to |canvas_|. This will happen if |canvas_|'s clip region is
+ // empty.
+ bool bitmapIsDummy_;
};