restore bool version of clip-bounds
BUG=skia:
Change-Id: I94e35566cf5bcd250515c71a566dd79030e2acb4
Reviewed-on: https://skia-review.googlesource.com/7430
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index a1d652d..13b3bc6 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -533,11 +533,27 @@
SkRect getLocalClipBounds() const { return this->onGetLocalClipBounds(); }
/**
+ * Returns true if the clip bounds are non-empty.
+ */
+ bool getLocalClipBounds(SkRect* bounds) const {
+ *bounds = this->onGetLocalClipBounds();
+ return !bounds->isEmpty();
+ }
+
+ /**
* Return the bounds of the current clip in device coordinates. If the clip is empty,
* return { 0, 0, 0, 0 }.
*/
SkIRect getDeviceClipBounds() const { return this->onGetDeviceClipBounds(); }
+ /**
+ * Returns true if the clip bounds are non-empty.
+ */
+ bool getDeviceClipBounds(SkIRect* bounds) const {
+ *bounds = this->onGetDeviceClipBounds();
+ return !bounds->isEmpty();
+ }
+
#ifdef SK_SUPPORT_LEGACY_GETCLIPBOUNDS
bool getClipBounds(SkRect* bounds) const {
SkRect r = this->getLocalClipBounds();
diff --git a/src/core/SkRecordedDrawable.cpp b/src/core/SkRecordedDrawable.cpp
index e70dce7..d153762 100644
--- a/src/core/SkRecordedDrawable.cpp
+++ b/src/core/SkRecordedDrawable.cpp
@@ -51,9 +51,8 @@
SkPictureRecord pictureRecord(SkISize::Make(fBounds.width(), fBounds.height()), 0);
// If the query contains the whole picture, don't bother with the bounding box hierarchy.
- SkRect clipBounds = pictureRecord.getLocalClipBounds();
SkBBoxHierarchy* bbh;
- if (clipBounds.contains(fBounds)) {
+ if (pictureRecord.getLocalClipBounds().contains(fBounds)) {
bbh = nullptr;
} else {
bbh = fBBH.get();
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 6229e84..c947ce4 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -68,21 +68,31 @@
DEF_TEST(canvas_clipbounds, reporter) {
SkCanvas canvas(10, 10);
- SkIRect irect;
- SkRect rect;
+ SkIRect irect, irect2;
+ SkRect rect, rect2;
irect = canvas.getDeviceClipBounds();
REPORTER_ASSERT(reporter, irect == SkIRect::MakeWH(10, 10));
+ REPORTER_ASSERT(reporter, canvas.getDeviceClipBounds(&irect2));
+ REPORTER_ASSERT(reporter, irect == irect2);
+
// local bounds are always too big today -- can we trim them?
rect = canvas.getLocalClipBounds();
REPORTER_ASSERT(reporter, rect.contains(SkRect::MakeWH(10, 10)));
+ REPORTER_ASSERT(reporter, canvas.getLocalClipBounds(&rect2));
+ REPORTER_ASSERT(reporter, rect == rect2);
canvas.clipRect(SkRect::MakeEmpty());
irect = canvas.getDeviceClipBounds();
REPORTER_ASSERT(reporter, irect == SkIRect::MakeEmpty());
+ REPORTER_ASSERT(reporter, !canvas.getDeviceClipBounds(&irect2));
+ REPORTER_ASSERT(reporter, irect == irect2);
+
rect = canvas.getLocalClipBounds();
REPORTER_ASSERT(reporter, rect == SkRect::MakeEmpty());
+ REPORTER_ASSERT(reporter, !canvas.getLocalClipBounds(&rect2));
+ REPORTER_ASSERT(reporter, rect == rect2);
}
static const int kWidth = 2, kHeight = 2;