diff options
author | 2014-09-26 11:45:48 -0700 | |
---|---|---|
committer | 2014-09-26 11:45:48 -0700 | |
commit | faccb8eb53f1bc745d3dd530d8df8b40e0dedc23 (patch) | |
tree | 2a509c0e5486a16cd89388f0c7407178d974856b /include/utils/SkMatrix44.h | |
parent | 5ceff913cfd458c653358db7f60e995f505bce84 (diff) |
SkMatrix44::preserves2dAxisAlignment()
Convenience function requested for Chrome compositor that may have a performance
advantage.
BUG=skia:1017
R=reed@google.com, danakj@chromium.org, vollick@chromium.org
Author: tomhudson@google.com
Review URL: https://codereview.chromium.org/508303005
Diffstat (limited to 'include/utils/SkMatrix44.h')
-rw-r--r-- | include/utils/SkMatrix44.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/utils/SkMatrix44.h b/include/utils/SkMatrix44.h index 83b5443d68..38a011467f 100644 --- a/include/utils/SkMatrix44.h +++ b/include/utils/SkMatrix44.h @@ -29,6 +29,9 @@ static inline double SkMScalarToDouble(double x) { return x; } + static inline double SkMScalarAbs(double x) { + return fabs(x); + } static const SkMScalar SK_MScalarPI = 3.141592653589793; #elif defined SK_MSCALAR_IS_FLOAT #ifdef SK_MSCALAR_IS_DOUBLE @@ -48,6 +51,9 @@ static inline double SkMScalarToDouble(float x) { return static_cast<double>(x); } + static inline float SkMScalarAbs(float x) { + return sk_float_abs(x); + } static const SkMScalar SK_MScalarPI = 3.14159265f; #endif @@ -377,6 +383,18 @@ public: void map2(const float src2[], int count, float dst4[]) const; void map2(const double src2[], int count, double dst4[]) const; + /** Returns true if transformating an axis-aligned square in 2d by this matrix + will produce another 2d axis-aligned square; typically means the matrix + is a scale with perhaps a 90-degree rotation. A 3d rotation through 90 + degrees into a perpendicular plane collapses a square to a line, but + is still considered to be axis-aligned. + + By default, tolerates very slight error due to float imprecisions; + a 90-degree rotation can still end up with 10^-17 of + "non-axis-aligned" result. + */ + bool preserves2dAxisAlignment(SkMScalar epsilon = SK_ScalarNearlyZero) const; + void dump() const; double determinant() const; |