diff options
author | 2010-02-24 01:49:13 +0000 | |
---|---|---|
committer | 2010-02-24 01:49:13 +0000 | |
commit | 233481ebd0b8644a319443cde33e75266e990ee6 (patch) | |
tree | 3274ae73168a85d23dfc83561ee96192c9c4b39f /include/core/SkRect.h | |
parent | 6d342a4e4ae4bd61cf1799dcf5239dcce52de68d (diff) |
add static Make methods to return rects
git-svn-id: http://skia.googlecode.com/svn/trunk@508 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkRect.h')
-rw-r--r-- | include/core/SkRect.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h index 4f78e6519f..879d81a9ab 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -18,6 +18,7 @@ #define SkRect_DEFINED #include "SkPoint.h" +#include "SkSize.h" /** \struct SkIRect @@ -232,6 +233,24 @@ struct SkIRect { struct SkRect { SkScalar fLeft, fTop, fRight, fBottom; + static SkRect MakeSize(const SkSize& size) { + SkRect r; + r.set(0, 0, size.width(), size.height()); + return r; + } + + static SkRect MakeLTRB(SkScalar l, SkScalar t, SkScalar r, SkScalar b) { + SkRect rect; + rect.set(l, t, r, b); + return rect; + } + + static SkRect MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h) { + SkRect 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; } |