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
diff --git a/include/utils/SkMatrix44.h b/include/utils/SkMatrix44.h
index 4789e7e2..22cbd79 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 @@
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 @@
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,