aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRect.h
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-02-23 14:44:57 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-23 14:44:58 -0800
commit44701df5ce572ac3cccec785cf52103d3d5d14a5 (patch)
treeb2f3b5465cc8490261163006376c7f7a30b5399e /include/core/SkRect.h
parent98c251bc7eec5aa236700d9936c740f2744788db (diff)
Move clip off of draw target
Diffstat (limited to 'include/core/SkRect.h')
-rw-r--r--include/core/SkRect.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 06f8abe0e4..69c2dc9cef 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -11,6 +11,8 @@
#include "SkPoint.h"
#include "SkSize.h"
+struct SkRect;
+
/** \struct SkIRect
SkIRect holds four 32 bit integer coordinates for a rectangle
@@ -244,6 +246,10 @@ struct SK_API SkIRect {
fRight >= r.fRight && fBottom >= r.fBottom;
}
+ /** Returns true if the specified rectangle r is inside or equal to this rectangle.
+ */
+ bool contains(const SkRect& r) const;
+
/** Return true if this rectangle contains the specified rectangle.
For speed, this method does not check if either this or the specified
rectangles are empty, and if either is, its return value is undefined.
@@ -880,4 +886,10 @@ public:
void dumpHex() const { this->dump(true); }
};
+inline bool SkIRect::contains(const SkRect& r) const {
+ return !r.isEmpty() && !this->isEmpty() && // check for empties
+ (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop &&
+ (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom;
+}
+
#endif