diff options
author | 2012-03-26 15:24:27 +0000 | |
---|---|---|
committer | 2012-03-26 15:24:27 +0000 | |
commit | 8fe84b53a64b5d92f3aabdd8e7fc7b2ee15c0a75 (patch) | |
tree | a9d6c08b4dd8e9bd00308ccf4dd7d0fcec549c21 /include/core/SkMatrix.h | |
parent | 22f42b71fc7f120e995b6e90e9fca8584438192c (diff) |
Add SkMatrix::cheapEqualTo, use in Gr code
Review URL: http://codereview.appspot.com/5865057/
git-svn-id: http://skia.googlecode.com/svn/trunk@3488 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkMatrix.h')
-rw-r--r-- | include/core/SkMatrix.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h index df3275ec4b..3c3d105805 100644 --- a/include/core/SkMatrix.h +++ b/include/core/SkMatrix.h @@ -483,20 +483,28 @@ public: */ bool fixedStepInX(SkScalar y, SkFixed* stepX, SkFixed* stepY) const; -#ifdef SK_SCALAR_IS_FIXED - friend bool operator==(const SkMatrix& a, const SkMatrix& b) { - return memcmp(a.fMat, b.fMat, sizeof(a.fMat)) == 0; + /** Efficient comparison of two matrices. It distinguishes between zero and + * negative zero. It will return false when the sign of zero values is the + * only difference between the two matrices. It considers NaN values to be + * equal to themselves. So a matrix full of NaNs is "cheap equal" to + * another matrix full of NaNs iff the NaN values are bitwise identical + * while according to strict the strict == test a matrix with a NaN value + * is equal to nothing, including itself. + */ + bool cheapEqualTo(const SkMatrix& m) const { + return 0 == memcmp(fMat, m.fMat, sizeof(fMat)); } - friend bool operator!=(const SkMatrix& a, const SkMatrix& b) { - return memcmp(a.fMat, b.fMat, sizeof(a.fMat)) != 0; +#ifdef SK_SCALAR_IS_FIXED + friend bool operator==(const SkMatrix& a, const SkMatrix& b) { + return a->cheapEquals(b); } #else - friend bool operator==(const SkMatrix& a, const SkMatrix& b); + friend bool operator==(const SkMatrix& a, const SkMatrix& b); +#endif friend bool operator!=(const SkMatrix& a, const SkMatrix& b) { return !(a == b); } -#endif enum { // flatten/unflatten will never return a value larger than this |