Index: tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp |
diff --git a/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp b/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp |
index 4e5e93969c3f743ecc6024bbba9576a06a3791ef..a3e4a383f2e8ef0edc32882a35958b3af28c2018 100644 |
--- a/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp |
+++ b/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp |
@@ -16,12 +16,18 @@ struct SkDifferentPixelsMetric::QueuedDiff { |
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 SkDifferentPixelsMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { |
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 @@ int SkDifferentPixelsMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { |
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 @@ int SkDifferentPixelsMetric::getPointsOfInterestCount(int id) { |
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; |
+} |