aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-05-01 08:51:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-01 08:51:48 -0700
commit3dc2ccae6c0f0cf6ac951585a197bfb8a58cfee5 (patch)
treec62f60c08ab3b8880d5922028ab6876f66b1024f
parentf7a169e225b6c5c7e79e14f6713256b4b8b9ab7f (diff)
Simple CL to add a joinWithPossiblyEmptyArg to SkRect
-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.
*