Index: include/core/SkRect.h |
diff --git a/include/core/SkRect.h b/include/core/SkRect.h |
index 39cbb330f82b207cd6a508570fe41f1372353590..b8890976fedd8ebda9cb0ee4d5f7034f4e48bf74 100644 |
--- a/include/core/SkRect.h |
+++ b/include/core/SkRect.h |
@@ -257,6 +257,11 @@ struct SK_API SkIRect { |
*/ |
bool contains(const SkRect& r) const; |
+ /** Returns true if the rectangle r is contained by the would-be non-integer rectangle that |
+ * results from outsetting this rectangle by "fuzz". |
+ */ |
+ bool fuzzyContains(const SkRect& r, SkScalar fuzz) const; |
bsalomon
2016/07/08 22:49:00
Instead of adding this to the public API, can we j
|
+ |
/** 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. |
@@ -902,4 +907,11 @@ inline bool SkIRect::contains(const SkRect& r) const { |
(SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; |
} |
+inline bool SkIRect::fuzzyContains(const SkRect& r, SkScalar fuzz) const { |
+ SkASSERT(fuzz >= 0); |
+ return !r.isEmpty() && !this->isEmpty() && // check for empties |
+ (SkScalar)fLeft <= (r.fLeft + fuzz) && (SkScalar)fTop <= (r.fTop + fuzz) && |
+ (SkScalar)fRight >= (r.fRight - fuzz) && (SkScalar)fBottom >= (r.fBottom - fuzz); |
+} |
+ |
#endif |