aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core/SkRect.h23
-rw-r--r--include/core/SkRegion.h4
2 files changed, 18 insertions, 9 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index a9d73be235..eae2e49e4b 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -194,14 +194,21 @@ struct SK_API SkIRect {
*/
int32_t centerY() const { return (fBottom + fTop) >> 1; }
- /** Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
- to or greater than fBottom. Call sort() to reverse rectangles with negative
- width() or height().
-
- @return true if width() or height() are zero or negative
- */
- bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
-
+ int64_t width64() const { return (int64_t)fRight - (int64_t)fLeft; }
+ int64_t height64() const { return (int64_t)fBottom - (int64_t)fTop; }
+
+ /** Returns true if the rectangle's dimensions are non-positive or if either its width or hieght
+ * exceeds int32_t.
+ */
+ bool isEmpty() const {
+ int64_t w = this->width64();
+ int64_t h = this->height64();
+ if (w <= 0 || h <= 0) {
+ return true;
+ }
+ // Return true if either exceeds int32_t
+ return !sk_64_isS32(w | h);
+ }
/** Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
identical to corresponding members in b.
diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h
index 32be090764..84ab670cc3 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -117,7 +117,9 @@ public:
* If left < right and top < bottom, set this region to that rectangle and
* return true, otherwise set this region to empty and return false.
*/
- bool setRect(int32_t left, int32_t top, int32_t right, int32_t bottom);
+ bool setRect(int32_t left, int32_t top, int32_t right, int32_t bottom) {
+ return this->setRect({ left, top, right, bottom });
+ }
/**
* Set this region to the union of an array of rects. This is generally