diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-15 14:54:00 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-15 14:54:00 +0000 |
commit | d53025364a8062b5c72f3f9ed54a613a1ae17958 (patch) | |
tree | a1194284c49c9001984fb605783e37f555298d27 /include/utils/SkMatrix44.h | |
parent | 5c4d5582c9d47ea47c7699fe69b9f95d0117dbd5 (diff) |
To support alignment pragmas (for speed), we need to relax assumptions about
our sizeof. So rewrite operator= and copy-constructor to just copy individual
fields.
Review URL: https://codereview.appspot.com/7098063
git-svn-id: http://skia.googlecode.com/svn/trunk@7181 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/utils/SkMatrix44.h')
-rw-r--r-- | include/utils/SkMatrix44.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/include/utils/SkMatrix44.h b/include/utils/SkMatrix44.h index 4789e7e209..22cbd79ba0 100644 --- a/include/utils/SkMatrix44.h +++ b/include/utils/SkMatrix44.h @@ -16,7 +16,6 @@ #error "can't define MSCALAR both as DOUBLE and FLOAT" #endif typedef double SkMScalar; - typedef int64_t SkMIntScalar; static inline double SkFloatToMScalar(float x) { return static_cast<double>(x); @@ -36,7 +35,6 @@ #error "can't define MSCALAR both as DOUBLE and FLOAT" #endif typedef float SkMScalar; - typedef int32_t SkMIntScalar; static inline float SkFloatToMScalar(float x) { return x; @@ -115,12 +113,19 @@ public: SkMatrix44(Identity_Constructor) { this->setIdentity(); } SkMatrix44() { this->setIdentity(); } - SkMatrix44(const SkMatrix44&); - SkMatrix44(const SkMatrix44& a, const SkMatrix44& b); + + SkMatrix44(const SkMatrix44& src) { + memcpy(fMat, src.fMat, sizeof(fMat)); + fTypeMask = src.fTypeMask; + } + + SkMatrix44(const SkMatrix44& a, const SkMatrix44& b) { + this->setConcat(a, b); + } SkMatrix44& operator=(const SkMatrix44& src) { - SkASSERT(sizeof(src) == sizeof(fMat) + sizeof(SkMIntScalar)); - memcpy(this, &src, sizeof(*this)); + memcpy(fMat, src.fMat, sizeof(fMat)); + fTypeMask = src.fTypeMask; return *this; } @@ -353,11 +358,8 @@ public: double determinant() const; private: - SkMScalar fMat[4][4]; - // we use SkMIntScalar instead of just int, as we want to ensure that - // we are always packed with no extra bits, allowing us to call memcpy - // without fear of copying uninitialized bits. - mutable SkMIntScalar fTypeMask; + SkMScalar fMat[4][4]; + mutable unsigned fTypeMask; enum { kUnknown_Mask = 0x80, |