aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkRect.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 0f68825fc1..fe276e6710 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.
*