add makeOffset and makeInset to SkRect
TBR=bsalomon
precursor for https://codereview.chromium.org/306013010
Author: reed@google.com
Review URL: https://codereview.chromium.org/306893012
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index fd8cb16..2c155c4 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -157,6 +157,20 @@
fRight = fBottom = SK_MinS32;
}
+ /**
+ * Return a new IRect, built as an offset of this rect.
+ */
+ SkIRect makeOffset(int dx, int dy) const {
+ return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
+ }
+
+ /**
+ * Return a new IRect, built as an inset of this rect.
+ */
+ SkIRect makeInset(int dx, int dy) const {
+ return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
@@ -577,6 +591,20 @@
fRight = fBottom = SK_ScalarMin;
}
+ /**
+ * Return a new Rect, built as an offset of this rect.
+ */
+ SkRect makeOffset(SkScalar dx, SkScalar dy) const {
+ return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
+ }
+
+ /**
+ * Return a new Rect, built as an inset of this rect.
+ */
+ SkRect makeInset(SkScalar dx, SkScalar dy) const {
+ return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/