Bug 705200 - Add mozilla::gfx::Matrix::IsIdentity(). r=Bas
authorJoe Drew <joe@drew.ca>
Wed, 04 Jan 2012 18:02:59 -0500
changeset 85044 ec3401e5a7b8c939b3a730718d85cabcee05a6c8
parent 85043 2325e88b6026d5396df22e2f014daeb05e877fb9
child 85045 4bd2675fefa0f85249a1945ac5d4f17e946a59a2
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
bugs705200
milestone12.0a1
Bug 705200 - Add mozilla::gfx::Matrix::IsIdentity(). r=Bas
gfx/2d/Matrix.h
--- a/gfx/2d/Matrix.h
+++ b/gfx/2d/Matrix.h
@@ -151,16 +151,26 @@ public:
     if (FuzzyEqual(_12, 0) && FuzzyEqual(_21, 0)) {
       return true;
     } else if (FuzzyEqual(_22, 0) && FuzzyEqual(_11, 0)) {
       return true;
     }
 
     return false;
   }
+
+  /* Returns true if the matrix is an identity matrix.
+   */
+  bool IsIdentity() const
+  {
+    return _11 == 1.0f && _12 == 0.0f &&
+           _21 == 0.0f && _22 == 1.0f &&
+           _31 == 0.0f && _32 == 0.0f;
+  }
+
 private:
   static bool FuzzyEqual(Float aV1, Float aV2) {
     // XXX - Check if fabs does the smart thing and just negates the sign bit.
     return fabs(aV2 - aV1) < 1e-6;
   }
 };
 
 }