remove one un-needed static initializer
authordigit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 10 Jan 2012 10:00:59 +0000 (10:00 +0000)
committerdigit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 10 Jan 2012 10:00:59 +0000 (10:00 +0000)
This patch removes the use of a static C++ object in the
implementation of SkMatrix44::isIdentity(). Instead, we rely
on direct comparison with a statically allocated array of
SkMScalar values, which is completely equivalent.
Review URL: http://codereview.appspot.com/5502067

git-svn-id: http://skia.googlecode.com/svn/trunk@2991 2bbb7eff-a529-9590-31e7-b0007b416f81

src/utils/SkMatrix44.cpp

index a59c91b60da25feab25ac494eead98be2edc6e0b..f00e399191a4e4e7e25c3494c60735fbcb469c3c 100644 (file)
@@ -84,10 +84,14 @@ void SkMatrix44::asRowMajord(double dst[]) const {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-static const SkMatrix44 gIdentity44;
-
 bool SkMatrix44::isIdentity() const {
-    return *this == gIdentity44;
+    static const SkMScalar  sIdentityMat[4][4] = {
+        { 1, 0, 0, 0 },
+        { 0, 1, 0, 0 },
+        { 0, 0, 1, 0 },
+        { 0, 0, 0, 1 },
+    };
+    return !memcmp(fMat, sIdentityMat, sizeof(fMat));
 }
 
 ///////////////////////////////////////////////////////////////////////////////