diff options
author | Mike Reed <reed@google.com> | 2017-03-07 14:55:37 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-07 20:51:34 +0000 |
commit | ca49067a3378b5c0364817c4198c063de05a331a (patch) | |
tree | 03117f70e401489a17232a739af839d0b48fdf67 /include | |
parent | fdf3bbe82110488fa271c5a8ab0f17e5c925c2dd (diff) |
optimize intersect, use getType to utilize fast-case in preTranslate
10-15% speed up in clip_record_overhead bench
Comparing the raw fType field was missing the (maybe deprecatable) IsRectToRect
bit (0x10), which is set for identity and translate matrices, so we were
never taking the fast case.
BUG=skia:
Change-Id: I1c73f4bae42f2311454c7568ef8891239c3cae83
Reviewed-on: https://skia-review.googlesource.com/9388
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkMatrix.h | 8 | ||||
-rw-r--r-- | include/core/SkRect.h | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h index bae37a75b2..d408fb12b0 100644 --- a/include/core/SkMatrix.h +++ b/include/core/SkMatrix.h @@ -816,6 +816,14 @@ private: return ((fTypeMask & 0xF) == 0); } + inline void updateTranslateMask() { + if ((fMat[kMTransX] != 0) | (fMat[kMTransY] != 0)) { + fTypeMask |= kTranslate_Mask; + } else { + fTypeMask &= ~kTranslate_Mask; + } + } + bool SK_WARN_UNUSED_RESULT invertNonIdentity(SkMatrix* inverse) const; static bool Poly2Proc(const SkPoint[], SkMatrix*, const SkPoint& scale); diff --git a/include/core/SkRect.h b/include/core/SkRect.h index 27a648feeb..bcdc4f147b 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -280,7 +280,7 @@ struct SK_API SkIRect { intersection, otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& r) { + bool intersect(const SkIRect& r) { return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom); } @@ -327,7 +327,7 @@ struct SK_API SkIRect { otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(int32_t left, int32_t top, + bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom) { if (left < right && top < bottom && !this->isEmpty() && fLeft < right && left < fRight && fTop < bottom && top < fBottom) { @@ -676,15 +676,14 @@ struct SK_API SkRect { intersection, otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(const SkRect& r); + bool intersect(const SkRect& r); /** If this rectangle intersects the rectangle specified by left, top, right, bottom, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(SkScalar left, SkScalar top, - SkScalar right, SkScalar bottom); + bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom); /** * If rectangles a and b intersect, return true and set this rectangle to |