aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRect.h
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-31 18:28:59 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-31 18:28:59 +0000
commit0d10280190c411b18feb569a2248552047d1aa93 (patch)
tree4590a03f96903de021699869f91a26d7779d2a4b /include/core/SkRect.h
parent6f6efa90c48a8c8f0052f65b54cdeeaad67fea44 (diff)
We often rgn-diff an area >= the other rgn. now we detect that and return empty
We do this when we update our devices in SkCanvas.cpp Review URL: https://codereview.appspot.com/6249073 git-svn-id: http://skia.googlecode.com/svn/trunk@4101 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkRect.h')
-rw-r--r--include/core/SkRect.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index e055c3d70b..83ef2df35c 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -206,6 +206,10 @@ struct SK_API SkIRect {
fRight >= right && fBottom >= bottom;
}
+ bool containsNoEmptyCheck(const SkIRect& r) const {
+ return containsNoEmptyCheck(r.fLeft, r.fTop, r.fRight, r.fBottom);
+ }
+
/** If r intersects this rectangle, return true and set this rectangle to that
intersection, otherwise return false and do not change this rectangle.
If either rectangle is empty, do nothing and return false.
@@ -273,10 +277,20 @@ struct SK_API SkIRect {
}
/** Returns true if a and b are not empty, and they intersect
- */
+ */
static bool Intersects(const SkIRect& a, const SkIRect& b) {
return !a.isEmpty() && !b.isEmpty() && // check for empties
- a.fLeft < b.fRight && b.fLeft < a.fRight &&
+ a.fLeft < b.fRight && b.fLeft < a.fRight &&
+ a.fTop < b.fBottom && b.fTop < a.fBottom;
+ }
+
+ /**
+ * Returns true if a and b intersect. debug-asserts that neither are empty.
+ */
+ static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b) {
+ SkASSERT(!a.isEmpty());
+ SkASSERT(!b.isEmpty());
+ return a.fLeft < b.fRight && b.fLeft < a.fRight &&
a.fTop < b.fBottom && b.fTop < a.fBottom;
}