aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skdiff.cpp
diff options
context:
space:
mode:
authorGravatar rmistry@google.com <rmistry@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-03 19:23:22 +0000
committerGravatar rmistry@google.com <rmistry@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-03 19:23:22 +0000
commitee5a5eee12b3befac33ed6c379f81bf749f57161 (patch)
tree990692877cec0035f44d4eccdf75f61fbe41df5d /tools/skdiff.cpp
parent57cf9a6f252528ca54a2daac2b0064ce95405c09 (diff)
* Extended skdiff to report alpha channel differences.
* Created a tools/tests/rebaseline.sh to copy output-actual into output-expected. * Sample results are available here: http://www.corp.google.com/~rmistry/skia/gm-playback-windows/images-skdiff/ Review URL: https://codereview.appspot.com/7038048 git-svn-id: http://skia.googlecode.com/svn/trunk@7003 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/skdiff.cpp')
-rw-r--r--tools/skdiff.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/skdiff.cpp b/tools/skdiff.cpp
index a1783a45de..ae6d72cd7a 100644
--- a/tools/skdiff.cpp
+++ b/tools/skdiff.cpp
@@ -166,6 +166,7 @@ void compute_diff(DiffRecord* dr, DiffMetricProc diffFunction, const int colorTh
SkAutoLockPixels alpDiff(dr->fDifference.fBitmap);
SkAutoLockPixels alpWhite(dr->fWhite.fBitmap);
int mismatchedPixels = 0;
+ int totalMismatchA = 0;
int totalMismatchR = 0;
int totalMismatchG = 0;
int totalMismatchB = 0;
@@ -177,17 +178,21 @@ void compute_diff(DiffRecord* dr, DiffMetricProc diffFunction, const int colorTh
for (int x = 0; x < w; x++) {
SkPMColor c0 = *dr->fBase.fBitmap.getAddr32(x, y);
SkPMColor c1 = *dr->fComparison.fBitmap.getAddr32(x, y);
- SkPMColor trueDifference = compute_diff_pmcolor(c0, c1);
SkPMColor outputDifference = diffFunction(c0, c1);
- uint32_t thisR = SkGetPackedR32(trueDifference);
- uint32_t thisG = SkGetPackedG32(trueDifference);
- uint32_t thisB = SkGetPackedB32(trueDifference);
+ uint32_t thisA = SkAbs32(SkGetPackedA32(c0) - SkGetPackedA32(c1));
+ uint32_t thisR = SkAbs32(SkGetPackedR32(c0) - SkGetPackedR32(c1));
+ uint32_t thisG = SkAbs32(SkGetPackedG32(c0) - SkGetPackedG32(c1));
+ uint32_t thisB = SkAbs32(SkGetPackedB32(c0) - SkGetPackedB32(c1));
+ totalMismatchA += thisA;
totalMismatchR += thisR;
totalMismatchG += thisG;
totalMismatchB += thisB;
// In HSV, value is defined as max RGB component.
int value = MAX3(thisR, thisG, thisB);
dr->fWeightedFraction += ((float) value) / 255;
+ if (thisA > dr->fMaxMismatchA) {
+ dr->fMaxMismatchA = thisA;
+ }
if (thisR > dr->fMaxMismatchR) {
dr->fMaxMismatchR = thisR;
}
@@ -215,6 +220,8 @@ void compute_diff(DiffRecord* dr, DiffMetricProc diffFunction, const int colorTh
int pixelCount = w * h;
dr->fFractionDifference = ((float) mismatchedPixels) / pixelCount;
dr->fWeightedFraction /= pixelCount;
+ dr->fTotalMismatchA = totalMismatchA;
+ dr->fAverageMismatchA = ((float) totalMismatchA) / pixelCount;
dr->fAverageMismatchR = ((float) totalMismatchR) / pixelCount;
dr->fAverageMismatchG = ((float) totalMismatchG) / pixelCount;
dr->fAverageMismatchB = ((float) totalMismatchB) / pixelCount;