DM: go back to memcmp for BitmapsEqual
authormtklein <mtklein@chromium.org>
Tue, 3 Jun 2014 20:56:54 +0000 (13:56 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 3 Jun 2014 20:56:54 +0000 (13:56 -0700)
Even when autovectorized, using MaxComponentDifference is slower than memcmp.
And debug builds (most runs of DM) will never even be autovectorized.

DM::MaxComponentDifference is the top function on DM profile, and memcmp moves
to ~20th.

BUG=skia:
R=halcanary@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/315743002

dm/DMUtil.cpp

index d7d6691..f142d47 100644 (file)
@@ -84,7 +84,11 @@ unsigned MaxComponentDifference(const SkBitmap& a, const SkBitmap& b) {
 }
 
 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
-    return a.info() == b.info() && 0 == MaxComponentDifference(a, b);
+    if (a.info() != b.info()) {
+        return false;
+    }
+    const SkAutoLockPixels lockA(a), lockB(b);
+    return 0 == memcmp(a.getPixels(), b.getPixels(), a.getSize());
 }
 
 }  // namespace DM