Fix GrTextureAccess::operator ==
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Sep 2012 15:37:30 +0000 (15:37 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Sep 2012 15:37:30 +0000 (15:37 +0000)
compare the textures, correctly intepret memcmp result, don't compare last byte of swizzle array which must be 0.

BUG=895
Review URL: https://codereview.appspot.com/6542048

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

include/gpu/GrTextureAccess.h

index 7f47b6e..0d0860f 100644 (file)
@@ -145,11 +145,12 @@ public:
     bool operator== (const GrTextureAccess& other) const {
 #if GR_DEBUG
         // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long.
-        GrAssert(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)) ==
+        GrAssert(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) ==
                  strcmp(fSwizzle, other.fSwizzle));
 #endif
         return fParams == other.fParams &&
-               memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle));
+               (fTexture.get() == other.fTexture.get()) &&
+               (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1));
     }
 
     bool operator!= (const GrTextureAccess& other) const { return !(*this == other); }