skdiff: only write out diff images that are included in index.html
Not only are those files unnecessary, in some different-image-size cases, their contents are nondeterministic!
Review URL: https://codereview.appspot.com/6208073
git-svn-id: http://skia.googlecode.com/svn/trunk@3975 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp
index f038b2c..e7d30d2 100644
--- a/tools/skdiff_main.cpp
+++ b/tools/skdiff_main.cpp
@@ -401,6 +401,8 @@
}
// based on gm
+// Postcondition: when we exit this method, dr->fResult should have some value
+// other than kUnknown.
static void compute_diff(DiffRecord* dr,
DiffMetricProc diffFunction,
const int colorThreshold) {
@@ -531,9 +533,12 @@
drp->fDifferenceBitmap->allocPixels();
drp->fWhiteBitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h);
drp->fWhiteBitmap->allocPixels();
- compute_diff(drp, dmp, colorThreshold);
- if (!outputDir.isEmpty()) {
+ SkASSERT(kUnknown == drp->fResult);
+ compute_diff(drp, dmp, colorThreshold);
+ SkASSERT(kUnknown != drp->fResult);
+
+ if ((kDifferentPixels == drp->fResult) && !outputDir.isEmpty()) {
SkString differencePath (outputDir);
differencePath.append(filename_to_diff_filename(filename));
write_bitmap(differencePath, drp->fDifferenceBitmap);
@@ -541,7 +546,7 @@
whitePath.append(filename_to_white_filename(filename));
write_bitmap(whitePath, drp->fWhiteBitmap);
}
-
+
release_bitmaps(drp);
}
@@ -612,7 +617,7 @@
qsort(comparisonFiles.begin(), comparisonFiles.count(),
sizeof(SkString*), SkCastForQSort(compare_file_name_metrics));
}
-
+
int i = 0;
int j = 0;
@@ -1138,7 +1143,7 @@
return 0;
}
}
-
+
if (numUnflaggedArguments == 2) {
outputDir = comparisonDir;
} else if (numUnflaggedArguments != 3) {
@@ -1198,7 +1203,7 @@
qsort(differences.begin(), differences.count(),
sizeof(DiffRecord*), sortProc);
}
-
+
if (generateDiffs) {
print_diff_page(summary.fNumMatches, colorThreshold, differences,
baseDir, comparisonDir, outputDir);