diff options
Diffstat (limited to 'include/core/SkRect.h')
-rw-r--r-- | include/core/SkRect.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h index fbd9f7f..b6caad5 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -27,6 +27,36 @@ struct SkIRect { int32_t fLeft, fTop, fRight, fBottom; + static SkIRect MakeEmpty() { + SkIRect r; + r.setEmpty(); + return r; + } + + static SkIRect MakeWH(int32_t w, int32_t h) { + SkIRect r; + r.set(0, 0, w, h); + return r; + } + + static SkIRect MakeSize(const SkISize& size) { + SkIRect r; + r.set(0, 0, size.width(), size.height()); + return r; + } + + static SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b) { + SkIRect rect; + rect.set(l, t, r, b); + return rect; + } + + static SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h) { + SkIRect r; + r.set(x, y, x + w, y + h); + return r; + } + /** Return true if the rectangle's width or height are <= 0 */ bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } @@ -266,6 +296,7 @@ struct SkRect { /** Return true if the rectangle's width or height are <= 0 */ bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } + bool hasValidCoordinates() const; SkScalar width() const { return fRight - fLeft; } SkScalar height() const { return fBottom - fTop; } SkScalar centerX() const { return SkScalarHalf(fLeft + fRight); } |