Index: include/core/SkRect.h |
diff --git a/include/core/SkRect.h b/include/core/SkRect.h |
index 06f8abe0e444c2e496c05f9e9cdf36e601124d19..69c2dc9cefbed347f006ab69d2f425b4b5e9d630 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 |