Chromium Code Reviews| Index: tools/skdiff_main.cpp |
| diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp |
| index 9d0bcf55e9d92c64fee2628993b50671dae9fdab..8ae79b48206e59e628a5b0ad31c3fc24833b3a53 100644 |
| --- a/tools/skdiff_main.cpp |
| +++ b/tools/skdiff_main.cpp |
| @@ -311,6 +311,13 @@ static void get_bounds(DiffRecord& drp) { |
| get_bounds(drp.fComparison, "comparison"); |
| } |
| +#define ANSI_COLOR_RED "\x1b[31m" |
| +#define ANSI_COLOR_GREEN "\x1b[32m" |
| +#define ANSI_COLOR_YELLOW "\x1b[33m" |
| +#define ANSI_COLOR_RESET "\x1b[0m" |
| + |
| +#define VERBOSE_STATUS(status,color,filename) if (verbose) printf( "[ " color " %10s " ANSI_COLOR_RESET " ] %s\n", status, filename->c_str()) |
|
bungeman-skia
2014/05/28 17:34:28
Can we ifdef SK_OS_WIN or something here so we don
humper
2014/05/28 17:55:31
Done.
|
| + |
| /// 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 +330,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 +378,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 +396,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. |
| @@ -405,6 +417,7 @@ static void create_diff_images (DiffMetricProc dmp, |
| SkAutoDataUnref baseFileBits(read_file(drp->fBase.fFullPath.c_str())); |
| if (NULL != baseFileBits) { |
| drp->fBase.fStatus = DiffResource::kRead_Status; |
| + |
|
bungeman-skia
2014/05/28 17:34:28
remove extra line?
humper
2014/05/28 17:55:31
Done.
|
| } |
| SkAutoDataUnref comparisonFileBits(read_file(drp->fComparison.fFullPath.c_str())); |
| if (NULL != comparisonFileBits) { |
| @@ -413,20 +426,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, |
| @@ -436,6 +452,7 @@ static void create_diff_images (DiffMetricProc dmp, |
| } |
| } |
| + |
|
bungeman-skia
2014/05/28 17:34:28
remove extra line?
humper
2014/05/28 17:55:31
Done.
|
| ++i; |
| ++j; |
| } |
| @@ -558,6 +575,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 +643,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 +750,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()) { |