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>
This commit is contained in:
Mike Reed 2017-01-24 09:13:40 -05:00 committed by Skia Commit-Bot
parent eb5061baac
commit 6f4a9b2948
3 changed files with 29 additions and 4 deletions

View File

@ -532,12 +532,28 @@ public:
*/
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();

View File

@ -51,9 +51,8 @@ void SkRecordedDrawable::flatten(SkWriteBuffer& buffer) const {
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();

View File

@ -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;