diff options
author | 2014-06-02 14:38:28 -0700 | |
---|---|---|
committer | 2014-06-02 14:38:32 -0700 | |
commit | 5c404c55772973126d8b3c6942ee42c9361d3fad (patch) | |
tree | c57da328ebbc9218550a897f978d43ad86498bd7 | |
parent | 8ff38ccb40ee4cf5f7f4ea2be424419d1124511f (diff) |
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
-rw-r--r-- | include/core/SkRect.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h index fd8cb16020..2c155c477a 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -157,6 +157,20 @@ struct SK_API SkIRect { 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 @@ struct SK_API SkRect { 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. */ |