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

Unified Diff: experimental/skpdiff/SkDiffContext.cpp

Issue 19786004: skpdiff: add ability to write the diff scores in a csv file (one line per pair of diff images, with… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months 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 | « no previous file | experimental/skpdiff/main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/skpdiff/SkDiffContext.cpp
===================================================================
--- experimental/skpdiff/SkDiffContext.cpp (revision 10191)
+++ experimental/skpdiff/SkDiffContext.cpp (working copy)
@@ -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 @@
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 @@
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 @@
// 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);
+ }
}
« no previous file with comments | « no previous file | experimental/skpdiff/main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698