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

Unified Diff: include/utils/SkMatrix44.h

Issue 508303005: SkMatrix44::preserves2dAxisAlignment() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unit test review fixes 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 | « no previous file | src/utils/SkMatrix44.cpp » ('j') | src/utils/SkMatrix44.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/utils/SkMatrix44.h
diff --git a/include/utils/SkMatrix44.h b/include/utils/SkMatrix44.h
index 83b5443d681cc548e3f001bcdeebe20c15ffbd41..38a011467f96c01392bc91cf941853c709b1e051 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;
« no previous file with comments | « no previous file | src/utils/SkMatrix44.cpp » ('j') | src/utils/SkMatrix44.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698