aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkRect.h30
-rw-r--r--include/core/SkRegion.h7
2 files changed, 37 insertions, 0 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index fbd9f7f502..00e0aaf576 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; }
diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h
index 8b15a893c8..103e2cc864 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -98,6 +98,13 @@ public:
*/
bool setRect(int32_t left, int32_t top, int32_t right, int32_t bottom);
+ /** Set this region to the union of an array of rects. This is generally
+ faster than calling region.op(rect, kUnion_Op) in a loop. If count is
+ 0, then this region is set to the empty region.
+ @return true if the resulting region is non-empty
+ */
+ bool setRects(const SkIRect rects[], int count);
+
/** Set this region to the specified region, and return true if it is
non-empty. */
bool setRegion(const SkRegion&);