diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-05 22:13:59 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-05 22:13:59 +0000 |
commit | 99b5c7f94ba5ef0c9cb464e34834cd5adea37a0e (patch) | |
tree | bc8fbe0af0020dcf1439280e331e6e2e3ef3cff9 /include | |
parent | 128db207aec5d85a7eac7dc1be9d5c83cecc7198 (diff) |
optimize translate and scale
add map2() to optimize for mapping an array of 2D points into homogeneous 4-vector
Review URL: https://codereview.appspot.com/6874064
git-svn-id: http://skia.googlecode.com/svn/trunk@6685 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/utils/SkMatrix44.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/include/utils/SkMatrix44.h b/include/utils/SkMatrix44.h index f63f0df495..565fcf5848 100644 --- a/include/utils/SkMatrix44.h +++ b/include/utils/SkMatrix44.h @@ -37,7 +37,7 @@ #endif typedef float SkMScalar; typedef int32_t SkMIntScalar; - + static inline float SkFloatToMScalar(float x) { return x; } @@ -134,7 +134,7 @@ public: kAffine_Mask = 0x04, //!< set if the matrix skews or rotates kPerspective_Mask = 0x08 //!< set if the matrix is in perspective }; - + /** * Returns a bitfield describing the transformations the matrix may * perform. The bitfield is computed conservatively, so it may include @@ -153,7 +153,7 @@ public: inline bool isIdentity() const { return 0 == this->getType(); } - + void setIdentity(); inline void reset() { this->setIdentity();} @@ -309,6 +309,17 @@ public: return dst; } + /** + * map an array of [x, y, 0, 1] through the matrix, returning an array + * of [x', y', z', w']. + * + * @param src2 array of [x, y] pairs, with implied z=0 and w=1 + * @param count number of [x, y] pairs in src2 + * @param dst4 array of [x', y', z', w'] quads as the output. + */ + void map2(const float src2[], int count, float dst4[]) const; + void map2(const double src2[], int count, double dst4[]) const; + void dump() const; double determinant() const; @@ -319,7 +330,7 @@ private: // we are always packed with no extra bits, allowing us to call memcpy // without fear of copying uninitialized bits. mutable SkMIntScalar fTypeMask; - + enum { kUnknown_Mask = 0x80, @@ -333,7 +344,7 @@ private: SkMScalar scaleX() const { return fMat[0][0]; } SkMScalar scaleY() const { return fMat[1][1]; } SkMScalar scaleZ() const { return fMat[2][2]; } - + SkMScalar perspX() const { return fMat[0][3]; } SkMScalar perspY() const { return fMat[1][3]; } SkMScalar perspZ() const { return fMat[2][3]; } |