aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/SkMatrix44.h
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-02-24 15:36:57 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-02-24 15:36:57 +0000
commitc8c49c573bda7c6d74eed390842b7a0bbdf873f5 (patch)
treed8c9d3acf9f1db9ba66777e38a715bbf5616adfa /experimental/SkMatrix44.h
parent2bd703b3163fe1da3ea55f6459c5e162f32cce12 (diff)
add tests for translate, concat, scale
git-svn-id: http://skia.googlecode.com/svn/trunk@510 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/SkMatrix44.h')
-rw-r--r--experimental/SkMatrix44.h48
1 files changed, 44 insertions, 4 deletions
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<double>(x);
+ }
+ static inline float SkMScalarToFloat(double x) {
+ return static_cast<float>(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<float>(x);
+ }
+ static inline double SkMScalarToDouble(float x) {
+ return static_cast<double>(x);
+ }
+#endif
+
static const SkMScalar SK_MScalar1 = 1;
-static inline SkMScalar SkDoubleToMScalar(double x) {
- return static_cast<float>(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);