diff options
author | joshualitt <joshualitt@chromium.org> | 2015-05-01 08:51:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-01 08:51:48 -0700 |
commit | 3dc2ccae6c0f0cf6ac951585a197bfb8a58cfee5 (patch) | |
tree | c62f60c08ab3b8880d5922028ab6876f66b1024f | |
parent | f7a169e225b6c5c7e79e14f6713256b4b8b9ab7f (diff) |
Simple CL to add a joinWithPossiblyEmptyArg to SkRect
BUG=skia:
Review URL: https://codereview.chromium.org/1118293002
-rw-r--r-- | include/core/SkRect.h | 16 |
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. * |