aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-10-01 09:24:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-01 09:24:12 -0700
commit10d0327c16bb748d6f73eb37dd2341c61e47ca8c (patch)
treeec15cd6630c1af4b7f4d6c3013b3945e64afa247 /include/core
parent68cd2aa797f707a9847f8eba0758787cafd43e43 (diff)
add SkRect::joinNonEmptyArg for faster unioning
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkRect.h15
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