aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-19 17:19:47 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-19 17:19:47 +0000
commit9345d94db69ce20d49dce0372bb267f7cd5ddd18 (patch)
treef846807d8f798d5951b3f86eb697543469eeac20 /experimental
parente4eaea2d126d58d8ce4034a1ce921404e83fe3f4 (diff)
skpdiff: add ability to write the diff scores in a csv file (one line per pair of diff images, with the result of each diff engine)
Review URL: https://codereview.chromium.org/19786004 git-svn-id: http://skia.googlecode.com/svn/trunk@10194 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental')
-rw-r--r--experimental/skpdiff/SkDiffContext.cpp38
-rw-r--r--experimental/skpdiff/main.cpp8
2 files changed, 46 insertions, 0 deletions
diff --git a/experimental/skpdiff/SkDiffContext.cpp b/experimental/skpdiff/SkDiffContext.cpp
index b5991273b5..bfe860462e 100644
--- a/experimental/skpdiff/SkDiffContext.cpp
+++ b/experimental/skpdiff/SkDiffContext.cpp
@@ -6,6 +6,7 @@
*/
#include "SkBitmap.h"
+#include "SkCommandLineFlags.h"
#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkStream.h"
@@ -14,6 +15,8 @@
#include "SkImageDiffer.h"
#include "skpdiff_util.h"
+DECLARE_string(csv);
+
SkDiffContext::SkDiffContext() {
fRecords = NULL;
fDiffers = NULL;
@@ -68,6 +71,28 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
newRecord->fNext = fRecords;
fRecords = newRecord;
+ FILE* csvFile = NULL;
+ if (!FLAGS_csv.isEmpty()) {
+ csvFile = fopen(FLAGS_csv[0], "a");
+ SkASSERT(csvFile);
+ if (ftell(csvFile) == 0) {
+ fprintf(csvFile, "%s", "skp");
+ for (int differIndex = 0; differIndex < fDifferCount; differIndex++) {
+ SkImageDiffer* differ = fDiffers[differIndex];
+ fprintf(csvFile, ", %s", differ->getName());
+ }
+ fprintf(csvFile, "\n");
+ }
+ }
+
+ if (csvFile) {
+ const char* filename = baselinePath + strlen(baselinePath) - 1;
+ while (filename > baselinePath && *(filename - 1) != '/') {
+ filename--;
+ }
+ fprintf(csvFile, "%s", filename);
+ }
+
// Perform each diff
for (int differIndex = 0; differIndex < fDifferCount; differIndex++) {
SkImageDiffer* differ = fDiffers[differIndex];
@@ -80,6 +105,10 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
diffData.fDiffName = differ->getName();
diffData.fResult = differ->getResult(diffID);
+ if (csvFile) {
+ fprintf(csvFile, ", %f", diffData.fResult);
+ }
+
int poiCount = differ->getPointsOfInterestCount(diffID);
SkIPoint* poi = differ->getPointsOfInterest(diffID);
diffData.fPointsOfInterest.append(poiCount, poi);
@@ -87,8 +116,17 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
// Because we are doing everything synchronously for now, we are done with the diff
// after reading it.
differ->deleteDiff(diffID);
+ } else {
+ if (csvFile) {
+ fprintf(csvFile, ", -1");
+ }
}
}
+
+ if (csvFile) {
+ fprintf(csvFile, "\n");
+ fclose(csvFile);
+ }
}
diff --git a/experimental/skpdiff/main.cpp b/experimental/skpdiff/main.cpp
index d258c147c6..f546008bea 100644
--- a/experimental/skpdiff/main.cpp
+++ b/experimental/skpdiff/main.cpp
@@ -32,6 +32,7 @@ DEFINE_string2(folders, f, "", "Compare two folders with identical subfile names
DEFINE_string2(patterns, p, "", "Use two patterns to compare images: <baseline> <test>");
DEFINE_string2(output, o, "skpdiff_output.json", "Writes the output of these diffs to output: <output>");
DEFINE_bool(jsonp, true, "Output JSON with padding");
+DEFINE_string(csv, "", "Writes the output of these diffs to a csv file");
#if SK_SUPPORT_OPENCL
/// A callback for any OpenCL errors
@@ -169,6 +170,13 @@ int main(int argc, char** argv) {
}
}
+ if (!FLAGS_csv.isEmpty()) {
+ if (1 != FLAGS_csv.count()) {
+ SkDebugf("csv flag expects one argument: <csv file>\n");
+ return 1;
+ }
+ }
+
SkDiffContext ctx;
ctx.setDiffers(chosenDiffers);