From 233481ebd0b8644a319443cde33e75266e990ee6 Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Wed, 24 Feb 2010 01:49:13 +0000 Subject: [PATCH] add static Make methods to return rects git-svn-id: http://skia.googlecode.com/svn/trunk@508 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkRect.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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; } -- 2.34.1