Bug 705204 - Add mozilla::gfx::Matrix::operator!= and operator==. r=Bas
authorJoe Drew <joe@drew.ca>
Wed, 04 Jan 2012 18:02:59 -0500
changeset 85045 4bd2675fefa0f85249a1945ac5d4f17e946a59a2
parent 85044 ec3401e5a7b8c939b3a730718d85cabcee05a6c8
child 85046 f6f8a1cd6702c23881c2c7025b52f017b2115007
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs705204
milestone12.0a1
Bug 705204 - Add mozilla::gfx::Matrix::operator!= and operator==. r=Bas
gfx/2d/Matrix.h
--- a/gfx/2d/Matrix.h
+++ b/gfx/2d/Matrix.h
@@ -139,16 +139,31 @@ public:
     resultMatrix._21 = this->_21 * aMatrix._11 + this->_22 * aMatrix._21;
     resultMatrix._22 = this->_21 * aMatrix._12 + this->_22 * aMatrix._22;
     resultMatrix._31 = this->_31 * aMatrix._11 + this->_32 * aMatrix._21 + aMatrix._31;
     resultMatrix._32 = this->_31 * aMatrix._12 + this->_32 * aMatrix._22 + aMatrix._32;
 
     return resultMatrix;
   }
 
+  /* Returns true if the other matrix is fuzzy-equal to this matrix.
+   * Note that this isn't a cheap comparison!
+   */
+  bool operator==(const Matrix& other) const
+  {
+    return FuzzyEqual(_11, other._11) && FuzzyEqual(_12, other._12) &&
+           FuzzyEqual(_21, other._21) && FuzzyEqual(_22, other._22) &&
+           FuzzyEqual(_31, other._31) && FuzzyEqual(_32, other._32);
+  }
+
+  bool operator!=(const Matrix& other) const
+  {
+    return !(*this == other);
+  }
+
   /* Returns true if the matrix is a rectilinear transformation (i.e.
    * grid-aligned rectangles are transformed to grid-aligned rectangles)
    */
   bool IsRectilinear() {
     if (FuzzyEqual(_12, 0) && FuzzyEqual(_21, 0)) {
       return true;
     } else if (FuzzyEqual(_22, 0) && FuzzyEqual(_11, 0)) {
       return true;