From c8c49c573bda7c6d74eed390842b7a0bbdf873f5 Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Wed, 24 Feb 2010 15:36:57 +0000 Subject: add tests for translate, concat, scale git-svn-id: http://skia.googlecode.com/svn/trunk@510 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/SkMatrix44.h | 48 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'experimental/SkMatrix44.h') diff --git a/experimental/SkMatrix44.h b/experimental/SkMatrix44.h index 0e47890e3f..cb4fdbf07f 100644 --- a/experimental/SkMatrix44.h +++ b/experimental/SkMatrix44.h @@ -3,11 +3,42 @@ #include "SkScalar.h" -typedef float SkMScalar; +// uncomment this to use doubles for matrix44 +#define SK_MSCALAR_IS_DOUBLE + +#ifdef SK_MSCALAR_IS_DOUBLE + typedef double SkMScalar; + static inline double SkFloatToMScalar(float x) { + return static_cast(x); + } + static inline float SkMScalarToFloat(double x) { + return static_cast(x); + } + static inline double SkDoubleToMScalar(double x) { + return x; + } + static inline double SkMScalarToDouble(double x) { + return x; + } +#else + typedef float SkMScalar; + static inline float SkFloatToMScalar(float x) { + return x; + } + static inline float SkMScalarToFloat(float x) { + return x; + } + static inline float SkDoubleToMScalar(double x) { + return static_cast(x); + } + static inline double SkMScalarToDouble(float x) { + return static_cast(x); + } +#endif + static const SkMScalar SK_MScalar1 = 1; -static inline SkMScalar SkDoubleToMScalar(double x) { - return static_cast(x); -} + +/////////////////////////////////////////////////////////////////////////////// struct SkVector4 { SkScalar fData[4]; @@ -19,7 +50,16 @@ public: SkMatrix44(const SkMatrix44&); SkMatrix44(const SkMatrix44& a, const SkMatrix44& b); + bool operator==(const SkMatrix44& other) const { + return !memcmp(this, &other, sizeof(*this)); + } + bool operator!=(const SkMatrix44& other) const { + return !!memcmp(this, &other, sizeof(*this)); + } + + bool isIdentity() const; void setIdentity(); + void reset() { this->setIdentity(); } void setTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz); void preTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz); -- cgit v1.2.3