Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp

Issue 29103005: update skpdiff visualization (image magnification with alpha mask) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/skpdiff/SkDifferentPixelsMetric.h ('k') | tools/skpdiff/SkDifferentPixelsMetric_opencl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « tools/skpdiff/SkDifferentPixelsMetric.h ('k') | tools/skpdiff/SkDifferentPixelsMetric_opencl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698