Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: src/core/SkMatrix.cpp

Issue 520123002: Fix matrix similarity test on arm64 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Minor clean-ups. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkMatrix.h ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrix.cpp
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 95662fc4cd42bca1edfb286e94089494b6e5a206..814f16a5ea4e6e247b010db07db984cb12c5e623 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -176,20 +176,16 @@ bool SkMatrix::isSimilarity(SkScalar tol) const {
return false;
}
- // it has scales and skews, but it could also be rotation, check it out.
- SkVector vec[2];
- vec[0].set(mx, sx);
- vec[1].set(sy, my);
-
- return SkScalarNearlyZero(vec[0].dot(vec[1]), SkScalarSquare(tol)) &&
- SkScalarNearlyEqual(vec[0].lengthSqd(), vec[1].lengthSqd(),
- SkScalarSquare(tol));
+ // upper 2x2 is rotation/reflection + uniform scale if basis vectors
+ // are 90 degree rotations of each other
+ return (SkScalarNearlyEqual(mx, my, tol) && SkScalarNearlyEqual(sx, -sy, tol))
+ || (SkScalarNearlyEqual(mx, -my, tol) && SkScalarNearlyEqual(sx, sy, tol));
}
bool SkMatrix::preservesRightAngles(SkScalar tol) const {
TypeMask mask = this->getType();
- if (mask <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
+ if (mask <= kTranslate_Mask) {
// identity, translate and/or scale
return true;
}
@@ -197,7 +193,7 @@ bool SkMatrix::preservesRightAngles(SkScalar tol) const {
return false;
}
- SkASSERT(mask & kAffine_Mask);
+ SkASSERT(mask & (kAffine_Mask | kScale_Mask));
SkScalar mx = fMat[kMScaleX];
SkScalar my = fMat[kMScaleY];
@@ -208,14 +204,12 @@ bool SkMatrix::preservesRightAngles(SkScalar tol) const {
return false;
}
- // it has scales and skews, but it could also be rotation, check it out.
+ // upper 2x2 is scale + rotation/reflection if basis vectors are orthogonal
SkVector vec[2];
- vec[0].set(mx, sx);
- vec[1].set(sy, my);
+ vec[0].set(mx, sy);
+ vec[1].set(sx, my);
- return SkScalarNearlyZero(vec[0].dot(vec[1]), SkScalarSquare(tol)) &&
- SkScalarNearlyEqual(vec[0].lengthSqd(), vec[1].lengthSqd(),
- SkScalarSquare(tol));
+ return SkScalarNearlyZero(vec[0].dot(vec[1]), SkScalarSquare(tol));
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « include/core/SkMatrix.h ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698