Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: include/core/SkRect.h

Issue 306893012: add makeOffset and makeInset to SkRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRect.h
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index fd8cb16020fd2359ca7435a71be8376ebe850f9c..2c155c477ab46bdc1479f40e215730c61f8e0625 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.
*/
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698