diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-03-01 14:54:05 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-03-01 14:54:05 +0000 |
commit | d055c1fde2128514167b315f4d104b177e04a3de (patch) | |
tree | 5efe11bc139ac853874a196fb5910e79bf817279 /experimental | |
parent | 85f9e1a0ad2be17c5ba606c4e2d7e83dda30c151 (diff) |
convert matrix <--> matrix44
add glyphrec to bounder
git-svn-id: http://skia.googlecode.com/svn/trunk@516 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental')
-rw-r--r-- | experimental/SkMatrix44.cpp | 38 | ||||
-rw-r--r-- | experimental/SkMatrix44.h | 12 |
2 files changed, 49 insertions, 1 deletions
diff --git a/experimental/SkMatrix44.cpp b/experimental/SkMatrix44.cpp index b2b8c30465..841eec27d1 100644 --- a/experimental/SkMatrix44.cpp +++ b/experimental/SkMatrix44.cpp @@ -269,4 +269,42 @@ void SkMatrix44::dump() const { #endif } +/////////////////////////////////////////////////////////////////////////////// + +static void initFromMatrix(SkMScalar dst[4][4], const SkMatrix& src) { + sk_bzero(dst, 16 * sizeof(SkMScalar)); + dst[0][0] = src[SkMatrix::kMScaleX]; + dst[1][0] = src[SkMatrix::kMSkewX]; + dst[3][0] = src[SkMatrix::kMTransX]; + dst[0][1] = src[SkMatrix::kMSkewY]; + dst[1][1] = src[SkMatrix::kMScaleY]; + dst[3][1] = src[SkMatrix::kMTransY]; + dst[2][2] = dst[3][3] = 1; +} + +SkMatrix44::SkMatrix44(const SkMatrix& src) { + initFromMatrix(fMat, src); +} + +SkMatrix44& SkMatrix44::operator=(const SkMatrix& src) { + initFromMatrix(fMat, src); + return *this; +} + +SkMatrix44::operator SkMatrix() const { + SkMatrix dst; + dst.reset(); // setup our perspective correctly for identity + + dst[SkMatrix::kMScaleX] = SkMScalarToFloat(fMat[0][0]); + dst[SkMatrix::kMSkewX] = SkMScalarToFloat(fMat[1][0]); + dst[SkMatrix::kMTransX] = SkMScalarToFloat(fMat[3][0]); + + dst[SkMatrix::kMSkewY] = SkMScalarToFloat(fMat[0][1]); + dst[SkMatrix::kMScaleY] = SkMScalarToFloat(fMat[1][1]); + dst[SkMatrix::kMTransY] = SkMScalarToFloat(fMat[3][1]); + + return dst; +} + + diff --git a/experimental/SkMatrix44.h b/experimental/SkMatrix44.h index f86559056a..b0e7148c41 100644 --- a/experimental/SkMatrix44.h +++ b/experimental/SkMatrix44.h @@ -1,6 +1,7 @@ #ifndef SkMatrix44_DEFINED #define SkMatrix44_DEFINED +#include "SkMatrix.h" #include "SkScalar.h" // uncomment this to use doubles for matrix44 @@ -89,13 +90,22 @@ public: SkMatrix44(const SkMatrix44&); SkMatrix44(const SkMatrix44& a, const SkMatrix44& b); + SkMatrix44& operator=(const SkMatrix44& src) { + memcpy(this, &src, sizeof(*this)); + return *this; + } + bool operator==(const SkMatrix44& other) const { return !memcmp(this, &other, sizeof(*this)); } bool operator!=(const SkMatrix44& other) const { return !!memcmp(this, &other, sizeof(*this)); } - + + SkMatrix44(const SkMatrix&); + SkMatrix44& operator=(const SkMatrix& src); + operator SkMatrix() const; + bool isIdentity() const; void setIdentity(); void reset() { this->setIdentity(); } |