Index: src/core/SkRect.cpp |
diff --git a/src/core/SkRect.cpp b/src/core/SkRect.cpp |
index 0b2723ab0a555f36703825f3c059a4d2c3e16f70..011d38a86a192a59fa64f62d49c958e91d1bab39 100644 |
--- a/src/core/SkRect.cpp |
+++ b/src/core/SkRect.cpp |
@@ -7,6 +7,18 @@ |
#include "SkRect.h" |
+bool SkIRect::contains(const SkRect& r) const { |
+ if (r.isEmpty() || this->isEmpty()) { |
+ return false; |
+ } |
+ // If r's coords are greater than the max int32_t, then they must be outside this SkIRect. |
+ if (!r.canRound()) { |
+ return false; |
+ } |
+ // At this point, we can convert the SkRect to SkIRect and compare directly. |
+ return this->contains(r.roundOut()); |
+} |
+ |
void SkIRect::join(int32_t left, int32_t top, int32_t right, int32_t bottom) { |
// do nothing if the params are empty |
if (left >= right || top >= bottom) { |
@@ -142,6 +154,19 @@ void SkRect::join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) |
} |
} |
+bool SkRect::canRound() const { |
+ if (fLeft < -SK_MaxS32Scalar || fTop < -SK_MaxS32Scalar || |
+ fRight > SK_MaxS32Scalar || fBottom > SK_MaxS32Scalar) { |
+ return false; |
+ } |
+ if (this->isEmpty()) { |
+ return fLeft < SK_MaxS32Scalar && fTop < SK_MaxS32Scalar && |
+ fRight > -SK_MaxS32Scalar && fBottom > -SK_MaxS32Scalar; |
+ } else { |
+ return true; |
+ } |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////////////////////// |
#include "SkString.h" |