diff options
author | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-10 03:27:47 +0000 |
---|---|---|
committer | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-10 03:27:47 +0000 |
commit | f8b1ebc35b6872c2805a22481b7c23b85486fb46 (patch) | |
tree | 727b21c8d9bbd2bda8bfd0778f696cd21ef5beb6 /src | |
parent | c1f224ac07b1310211e0219a4d6bda41e49abe90 (diff) |
add helpers for isTranslate and isScaleTranslate
special-case determinant for isScaleTranslate
git-svn-id: http://skia.googlecode.com/svn/trunk@6725 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/SkMatrix44.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp index 1c9fd845fb..f76f405c07 100644 --- a/src/utils/SkMatrix44.cpp +++ b/src/utils/SkMatrix44.cpp @@ -411,6 +411,13 @@ static inline double det3x3(double m00, double m01, double m02, promoting our SkMScalar values to double (if needed). */ double SkMatrix44::determinant() const { + if (this->isIdentity()) { + return 1; + } + if (this->isScaleTranslate()) { + return fMat[0][0] * fMat[1][1] * fMat[2][2] * fMat[3][3]; + } + return fMat[0][0] * det3x3(fMat[1][1], fMat[1][2], fMat[1][3], fMat[2][1], fMat[2][2], fMat[2][3], fMat[3][1], fMat[3][2], fMat[3][3]) - @@ -438,23 +445,19 @@ static inline double dabs(double x) { } bool SkMatrix44::invert(SkMatrix44* inverse) const { - const SkMatrix44::TypeMask mask = this->getType(); - - if (kIdentity_Mask == mask) { + if (this->isIdentity()) { if (inverse) { *inverse = *this; return true; } } - - if (kTranslate_Mask == mask) { + if (this->isTranslate()) { if (inverse) { inverse->setTranslate(-fMat[3][0], -fMat[3][1], -fMat[3][2]); } return true; } - - if (bits_isonly(mask, kScale_Mask | kTranslate_Mask)) { + if (this->isScaleTranslate()) { if (0 == fMat[0][0] * fMat[1][1] * fMat[2][2]) { return false; } @@ -470,7 +473,7 @@ bool SkMatrix44::invert(SkMatrix44* inverse) const { inverse->fMat[2][2] = 1 / fMat[2][2]; inverse->fMat[3][3] = 1; - inverse->setTypeMask(mask); + inverse->setTypeMask(this->getType()); } return true; } |