diff options
author | Brian Osman <brianosman@google.com> | 2018-07-17 16:45:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-18 17:13:46 +0000 |
commit | 9889c24ec62b7a9fe29df65853ee804fc1b84625 (patch) | |
tree | 4c9007064dc72dc43f52374a9d812778a13e10f2 /tools/skdiff/skdiff_main.cpp | |
parent | 66dac70719096b67cb292e0352ea9e8fa94334a4 (diff) |
Add color space logic to skdiff
By default, decode images to a common color space (sRGB) before comparing.
This lets us compare images rendered to different gamuts (eg sRGB or P3),
where the raw pixel values are wildly different, even though the colors
being described are actually the same (or very similar).
Add a "--nocolorspace" option to get the existing behavior of comparing
the raw pixel values.
Also removed the source code for skimagediff, which hasn't been built in
a long time.
Change-Id: Ic55724b523348421bf21e9764d155730b94fc40a
Reviewed-on: https://skia-review.googlesource.com/141962
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'tools/skdiff/skdiff_main.cpp')
-rw-r--r-- | tools/skdiff/skdiff_main.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/skdiff/skdiff_main.cpp b/tools/skdiff/skdiff_main.cpp index 59e9b0a6b7..56aebe7ffb 100644 --- a/tools/skdiff/skdiff_main.cpp +++ b/tools/skdiff/skdiff_main.cpp @@ -344,7 +344,7 @@ static void get_bounds(DiffResource& resource, const char* name) { if (resource.fBitmap.empty() && !DiffResource::isStatusFailed(resource.fStatus)) { sk_sp<SkData> fileBits(read_file(resource.fFullPath.c_str())); if (fileBits) { - get_bitmap(fileBits, resource, true); + get_bitmap(fileBits, resource, true, true); } else { SkDebugf("WARNING: couldn't read %s file <%s>\n", name, resource.fFullPath.c_str()); resource.fStatus = DiffResource::kCouldNotRead_Status; @@ -375,6 +375,7 @@ static void get_bounds(DiffRecord& drp) { /// If outputDir.isEmpty(), don't write out diff files. static void create_diff_images (DiffMetricProc dmp, const int colorThreshold, + bool ignoreColorSpace, RecordArray* differences, const SkString& baseDir, const SkString& comparisonDir, @@ -495,8 +496,8 @@ static void create_diff_images (DiffMetricProc dmp, VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]); } else { AutoReleasePixels arp(drp); - get_bitmap(baseFileBits, drp->fBase, false); - get_bitmap(comparisonFileBits, drp->fComparison, false); + get_bitmap(baseFileBits, drp->fBase, false, ignoreColorSpace); + get_bitmap(comparisonFileBits, drp->fComparison, false, ignoreColorSpace); VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]); if (DiffResource::kDecoded_Status == drp->fBase.fStatus && DiffResource::kDecoded_Status == drp->fComparison.fStatus) { @@ -585,6 +586,7 @@ static void usage (char * argv0) { "\n --match <substring>: compare files whose filenames contain this substring;" "\n if unspecified, compare ALL files." "\n this flag may be repeated." +"\n --nocolorspace: Ignore color space of images." "\n --nodiffs: don't write out image diffs or index.html, just generate" "\n report on stdout" "\n --nomatch <substring>: regardless of --match, DO NOT compare files whose" @@ -630,6 +632,7 @@ int main(int argc, char** argv) { bool recurseIntoSubdirs = true; bool verbose = false; bool listFailingBase = false; + bool ignoreColorSpace = false; RecordArray differences; DiffSummary summary; @@ -705,6 +708,10 @@ int main(int argc, char** argv) { matchSubstrings.push(new SkString(argv[++i])); continue; } + if (!strcmp(argv[i], "--nocolorspace")) { + ignoreColorSpace = true; + continue; + } if (!strcmp(argv[i], "--nodiffs")) { generateDiffs = false; continue; @@ -805,7 +812,7 @@ int main(int argc, char** argv) { matchSubstrings.push(new SkString("")); } - create_diff_images(diffProc, colorThreshold, &differences, + create_diff_images(diffProc, colorThreshold, ignoreColorSpace, &differences, baseDir, comparisonDir, outputDir, matchSubstrings, nomatchSubstrings, recurseIntoSubdirs, generateDiffs, verbose, &summary); |