aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-28 18:26:00 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-28 18:26:00 +0000
commit93d7bb6fc6e42d41e41ec9f38b540616d07925ad (patch)
tree3520959498b09ab89977ea0a8b9b2009f93c887d /tools
parentfa95b26b7a2eca76eb1d70d574262b4e2e28ef73 (diff)
add a verbose flag to skdiff that shows the progress and status of
each comparison BUG= R=bungeman@google.com Author: humper@google.com Review URL: https://codereview.chromium.org/302443012 git-svn-id: http://skia.googlecode.com/svn/trunk@14923 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r--tools/skdiff_main.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp
index 9d0bcf55e9..ba3221678e 100644
--- a/tools/skdiff_main.cpp
+++ b/tools/skdiff_main.cpp
@@ -311,6 +311,20 @@ static void get_bounds(DiffRecord& drp) {
get_bounds(drp.fComparison, "comparison");
}
+#ifdef SK_OS_WIN
+#define ANSI_COLOR_RED ""
+#define ANSI_COLOR_GREEN ""
+#define ANSI_COLOR_YELLOW ""
+#define ANSI_COLOR_RESET ""
+#else
+#define ANSI_COLOR_RED "\x1b[31m"
+#define ANSI_COLOR_GREEN "\x1b[32m"
+#define ANSI_COLOR_YELLOW "\x1b[33m"
+#define ANSI_COLOR_RESET "\x1b[0m"
+#endif
+
+#define VERBOSE_STATUS(status,color,filename) if (verbose) printf( "[ " color " %10s " ANSI_COLOR_RESET " ] %s\n", status, filename->c_str())
+
/// Creates difference images, returns the number that have a 0 metric.
/// If outputDir.isEmpty(), don't write out diff files.
static void create_diff_images (DiffMetricProc dmp,
@@ -323,6 +337,7 @@ static void create_diff_images (DiffMetricProc dmp,
const StringArray& nomatchSubstrings,
bool recurseIntoSubdirs,
bool getBounds,
+ bool verbose,
DiffSummary* summary) {
SkASSERT(!baseDir.isEmpty());
SkASSERT(!comparisonDir.isEmpty());
@@ -370,6 +385,8 @@ static void create_diff_images (DiffMetricProc dmp,
drp->fComparison.fFullPath = comparisonPath;
drp->fComparison.fStatus = DiffResource::kDoesNotExist_Status;
+ VERBOSE_STATUS("MISSING", ANSI_COLOR_YELLOW, baseFiles[i]);
+
++i;
} else if (v > 0) {
// in comparisonDir, but not in baseDir
@@ -386,6 +403,8 @@ static void create_diff_images (DiffMetricProc dmp,
drp->fComparison.fFullPath = comparisonPath;
drp->fComparison.fStatus = DiffResource::kExists_Status;
+ VERBOSE_STATUS("MISSING", ANSI_COLOR_YELLOW, comparisonFiles[j]);
+
++j;
} else {
// Found the same filename in both baseDir and comparisonDir.
@@ -413,20 +432,23 @@ static void create_diff_images (DiffMetricProc dmp,
if (NULL == baseFileBits || NULL == comparisonFileBits) {
if (NULL == baseFileBits) {
drp->fBase.fStatus = DiffResource::kCouldNotRead_Status;
+ VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, baseFiles[i]);
}
if (NULL == comparisonFileBits) {
drp->fComparison.fStatus = DiffResource::kCouldNotRead_Status;
+ VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[j]);
}
drp->fResult = DiffRecord::kCouldNotCompare_Result;
} else if (are_buffers_equal(baseFileBits, comparisonFileBits)) {
drp->fResult = DiffRecord::kEqualBits_Result;
-
+ VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]);
} else {
AutoReleasePixels arp(drp);
get_bitmap(baseFileBits, drp->fBase, SkImageDecoder::kDecodePixels_Mode);
get_bitmap(comparisonFileBits, drp->fComparison,
SkImageDecoder::kDecodePixels_Mode);
+ VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]);
if (DiffResource::kDecoded_Status == drp->fBase.fStatus &&
DiffResource::kDecoded_Status == drp->fComparison.fStatus) {
create_and_write_diff_image(drp, dmp, colorThreshold,
@@ -558,6 +580,7 @@ int tool_main(int argc, char** argv) {
bool listFilenames = false;
bool printDirNames = true;
bool recurseIntoSubdirs = true;
+ bool verbose = false;
RecordArray differences;
DiffSummary summary;
@@ -625,6 +648,10 @@ int tool_main(int argc, char** argv) {
listFilenames = true;
continue;
}
+ if (!strcmp(argv[i], "--verbose")) {
+ verbose = true;
+ continue;
+ }
if (!strcmp(argv[i], "--match")) {
matchSubstrings.push(new SkString(argv[++i]));
continue;
@@ -728,7 +755,7 @@ int tool_main(int argc, char** argv) {
create_diff_images(diffProc, colorThreshold, &differences,
baseDir, comparisonDir, outputDir,
matchSubstrings, nomatchSubstrings, recurseIntoSubdirs, generateDiffs,
- &summary);
+ verbose, &summary);
summary.print(listFilenames, failOnResultType, failOnStatusType);
if (differences.count()) {