Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: include/core/SkRect.h

Issue 2132073002: Pre-crop filled rects to avoid scissor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/gpu/GrClip.h » ('j') | include/gpu/GrDrawContext.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | include/gpu/GrClip.h » ('j') | include/gpu/GrDrawContext.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698