aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMatrix.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-03-07 14:55:37 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-07 20:51:34 +0000
commitca49067a3378b5c0364817c4198c063de05a331a (patch)
tree03117f70e401489a17232a739af839d0b48fdf67 /src/core/SkMatrix.cpp
parentfdf3bbe82110488fa271c5a8ab0f17e5c925c2dd (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 'src/core/SkMatrix.cpp')
-rw-r--r--src/core/SkMatrix.cpp29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 2c571e0ef6..8517d87555 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -271,7 +271,7 @@ static inline SkScalar scross(SkScalar a, SkScalar b, SkScalar c, SkScalar d) {
}
void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) {
- if (dx || dy) {
+ if ((dx != 0) | (dy != 0)) {
fMat[kMTransX] = dx;
fMat[kMTransY] = dy;
@@ -286,35 +286,24 @@ void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) {
}
void SkMatrix::preTranslate(SkScalar dx, SkScalar dy) {
- if (!dx && !dy) {
- return;
- }
+ const unsigned mask = this->getType();
- if (fTypeMask <= kTranslate_Mask) {
+ if (mask <= kTranslate_Mask) {
fMat[kMTransX] += dx;
fMat[kMTransY] += dy;
- this->setTypeMask((fMat[kMTransX] != 0 || fMat[kMTransY] != 0) ? kTranslate_Mask
- : kIdentity_Mask);
- } else if (this->hasPerspective()) {
+ } else if (mask & kPerspective_Mask) {
SkMatrix m;
m.setTranslate(dx, dy);
this->preConcat(m);
+ return;
} else {
fMat[kMTransX] += sdot(fMat[kMScaleX], dx, fMat[kMSkewX], dy);
fMat[kMTransY] += sdot(fMat[kMSkewY], dx, fMat[kMScaleY], dy);
- if (fMat[kMTransX] || fMat[kMTransY]) {
- fTypeMask |= kTranslate_Mask;
- } else {
- fTypeMask &= ~kTranslate_Mask;
- }
}
+ this->updateTranslateMask();
}
void SkMatrix::postTranslate(SkScalar dx, SkScalar dy) {
- if (!dx && !dy) {
- return;
- }
-
if (this->hasPerspective()) {
SkMatrix m;
m.setTranslate(dx, dy);
@@ -322,11 +311,7 @@ void SkMatrix::postTranslate(SkScalar dx, SkScalar dy) {
} else {
fMat[kMTransX] += dx;
fMat[kMTransY] += dy;
- if (fMat[kMTransX] || fMat[kMTransY]) {
- fTypeMask |= kTranslate_Mask;
- } else {
- fTypeMask &= ~kTranslate_Mask;
- }
+ this->updateTranslateMask();
}
}