update skpdiff visualization (image magnification with alpha mask)

R=epoger@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@12174 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp b/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp
index 4e5e939..a3e4a38 100644
--- a/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp
+++ b/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp
@@ -16,12 +16,18 @@
     bool finished;
     double result;
     SkTDArray<SkIPoint>* poi;
+    SkBitmap poiAlphaMask;
 };
 
 const char* SkDifferentPixelsMetric::getName() {
     return "different_pixels";
 }
 
+bool SkDifferentPixelsMetric::enablePOIAlphaMask() {
+    fPOIAlphaMask = true;
+    return true;
+}
+
 int SkDifferentPixelsMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) {
     double startTime = get_seconds();
     int diffID = fQueuedDiffs.count();
@@ -44,6 +50,14 @@
     int height = baseline->height();
     int differentPixelsCount = 0;
 
+    // Prepare the POI alpha mask if needed
+    if (fPOIAlphaMask) {
+        diff->poiAlphaMask.setConfig(SkBitmap::kA8_Config, width, height);
+        diff->poiAlphaMask.allocPixels();
+        diff->poiAlphaMask.lockPixels();
+        diff->poiAlphaMask.eraseARGB(SK_AlphaOPAQUE, 0, 0, 0);
+    }
+
     // Prepare the pixels for comparison
     baseline->lockPixels();
     test->lockPixels();
@@ -56,6 +70,9 @@
             if (std::memcmp(&baselineRow[x * 4], &testRow[x * 4], 4) != 0) {
                 poi->push()->set(x, y);
                 differentPixelsCount++;
+                if (fPOIAlphaMask) {
+                    *diff->poiAlphaMask.getAddr8(x,y) = SK_AlphaTRANSPARENT;
+                }
             }
         }
     }
@@ -93,3 +110,10 @@
 SkIPoint* SkDifferentPixelsMetric::getPointsOfInterest(int id) {
     return fQueuedDiffs[id].poi->begin();
 }
+
+SkBitmap* SkDifferentPixelsMetric::getPointsOfInterestAlphaMask(int id) {
+    if (fQueuedDiffs[id].poiAlphaMask.empty()) {
+        return NULL;
+    }
+    return &fQueuedDiffs[id].poiAlphaMask;
+}