Index: include/core/SkRect.h |
diff --git a/include/core/SkRect.h b/include/core/SkRect.h |
index 0f68825fc1ced755a9ae41e89f807c9fcd76ff3b..fe276e6710b0d242a0b96de66eb22d87f7e7c015 100644 |
--- a/include/core/SkRect.h |
+++ b/include/core/SkRect.h |
@@ -747,14 +747,22 @@ public: |
if (fLeft >= fRight || fTop >= fBottom) { |
*this = r; |
} else { |
- fLeft = SkMinScalar(fLeft, r.left()); |
- fTop = SkMinScalar(fTop, r.top()); |
- fRight = SkMaxScalar(fRight, r.right()); |
- fBottom = SkMaxScalar(fBottom, r.bottom()); |
+ this->joinPossiblyEmptyRect(r); |
} |
} |
/** |
+ * Joins the rectangle with another without checking if either are empty (may produce unexpected |
+ * results if either rect is inverted). |
+ */ |
+ void joinPossiblyEmptyRect(const SkRect& r) { |
+ fLeft = SkMinScalar(fLeft, r.left()); |
+ fTop = SkMinScalar(fTop, r.top()); |
+ fRight = SkMaxScalar(fRight, r.right()); |
+ fBottom = SkMaxScalar(fBottom, r.bottom()); |
+ } |
+ |
+ /** |
* Grow the rect to include the specified (x,y). After this call, the |
* following will be true: fLeft <= x <= fRight && fTop <= y <= fBottom. |
* |