diff options
author | reed <reed@google.com> | 2014-10-01 09:24:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-01 09:24:12 -0700 |
commit | 10d0327c16bb748d6f73eb37dd2341c61e47ca8c (patch) | |
tree | ec15cd6630c1af4b7f4d6c3013b3945e64afa247 /include/core | |
parent | 68cd2aa797f707a9847f8eba0758787cafd43e43 (diff) |
add SkRect::joinNonEmptyArg for faster unioning
BUG=skia:
Review URL: https://codereview.chromium.org/619853005
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkRect.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h index c8fc7c65c8..d249aee8d0 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -702,8 +702,19 @@ struct SK_API SkRect { void join(const SkRect& r) { this->join(r.fLeft, r.fTop, r.fRight, r.fBottom); } - // alias for join() - void growToInclude(const SkRect& r) { this->join(r); } + + void joinNonEmptyArg(const SkRect& r) { + SkASSERT(!r.isEmpty()); + // if we are empty, just assign + 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()); + } + } /** * Grow the rect to include the specified (x,y). After this call, the |