| Index: tools/skdiff_main.cpp
|
| diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp
|
| index df07844734c4f02494f3dfda86a22c4e89e9a7c9..fdd83a60360faa263c9aa194ec37a832c0dcb328 100644
|
| --- a/tools/skdiff_main.cpp
|
| +++ b/tools/skdiff_main.cpp
|
| @@ -17,7 +17,6 @@
|
| #include "SkTDArray.h"
|
| #include "SkTemplates.h"
|
| #include "SkTSearch.h"
|
| -#include "SkTypes.h"
|
|
|
| __SK_FORCE_IMAGE_DECODER_LINKING;
|
|
|
| @@ -38,6 +37,30 @@ __SK_FORCE_IMAGE_DECODER_LINKING;
|
| typedef SkTDArray<SkString*> StringArray;
|
| typedef StringArray FileArray;
|
|
|
| +static void add_unique_basename(StringArray* array, const SkString& filename) {
|
| + // trim off dirs
|
| + const char* src = filename.c_str();
|
| + const char* trimmed = strrchr(src, SkPATH_SEPARATOR);
|
| + if (trimmed) {
|
| + trimmed += 1; // skip the separator
|
| + } else {
|
| + trimmed = src;
|
| + }
|
| + const char* end = strrchr(trimmed, '.');
|
| + if (!end) {
|
| + end = trimmed + strlen(trimmed);
|
| + }
|
| + SkString result(trimmed, end - trimmed);
|
| +
|
| + // only add unique entries
|
| + for (int i = 0; i < array->count(); ++i) {
|
| + if (*array->getAt(i) == result) {
|
| + return;
|
| + }
|
| + }
|
| + *array->append() = new SkString(result);
|
| +}
|
| +
|
| struct DiffSummary {
|
| DiffSummary ()
|
| : fNumMatches(0)
|
| @@ -64,6 +87,8 @@ struct DiffSummary {
|
| FileArray fResultsOfType[DiffRecord::kResultCount];
|
| FileArray fStatusOfType[DiffResource::kStatusCount][DiffResource::kStatusCount];
|
|
|
| + StringArray fFailedBaseNames[DiffRecord::kResultCount];
|
| +
|
| void printContents(const FileArray& fileArray,
|
| const char* baseStatus, const char* comparisonStatus,
|
| bool listFilenames) {
|
| @@ -142,6 +167,19 @@ struct DiffSummary {
|
| }
|
| }
|
|
|
| + void printfFailingBaseNames(const char separator[]) {
|
| + for (int resultInt = 0; resultInt < DiffRecord::kResultCount; ++resultInt) {
|
| + const StringArray& array = fFailedBaseNames[resultInt];
|
| + if (array.count()) {
|
| + printf("%s [%d]%s", DiffRecord::ResultNames[resultInt], array.count(), separator);
|
| + for (int j = 0; j < array.count(); ++j) {
|
| + printf("%s%s", array[j]->c_str(), separator);
|
| + }
|
| + printf("\n");
|
| + }
|
| + }
|
| + }
|
| +
|
| void add (DiffRecord* drp) {
|
| uint32_t mismatchValue;
|
|
|
| @@ -188,6 +226,15 @@ struct DiffSummary {
|
| SkDEBUGFAIL("adding DiffRecord with unhandled fResult value");
|
| break;
|
| }
|
| +
|
| + switch (drp->fResult) {
|
| + case DiffRecord::kEqualBits_Result:
|
| + case DiffRecord::kEqualPixels_Result:
|
| + break;
|
| + default:
|
| + add_unique_basename(&fFailedBaseNames[drp->fResult], drp->fBase.fFilename);
|
| + break;
|
| + }
|
| }
|
| };
|
|
|
| @@ -581,6 +628,7 @@ int tool_main(int argc, char** argv) {
|
| bool printDirNames = true;
|
| bool recurseIntoSubdirs = true;
|
| bool verbose = false;
|
| + bool listFailingBase = false;
|
|
|
| RecordArray differences;
|
| DiffSummary summary;
|
| @@ -705,6 +753,10 @@ int tool_main(int argc, char** argv) {
|
| return kGenericError;
|
| }
|
| }
|
| + if (!strcmp(argv[i], "--listFailingBase")) {
|
| + listFailingBase = true;
|
| + continue;
|
| + }
|
|
|
| SkDebugf("Unrecognized argument <%s>\n", argv[i]);
|
| usage(argv[0]);
|
| @@ -758,6 +810,10 @@ int tool_main(int argc, char** argv) {
|
| verbose, &summary);
|
| summary.print(listFilenames, failOnResultType, failOnStatusType);
|
|
|
| + if (listFailingBase) {
|
| + summary.printfFailingBaseNames("\n");
|
| + }
|
| +
|
| if (differences.count()) {
|
| qsort(differences.begin(), differences.count(),
|
| sizeof(DiffRecord*), sortProc);
|
|
|