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_utils.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_utils.cpp')
-rw-r--r-- | tools/skdiff/skdiff_utils.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/skdiff/skdiff_utils.cpp b/tools/skdiff/skdiff_utils.cpp index fddd99cef3..18682c02b7 100644 --- a/tools/skdiff/skdiff_utils.cpp +++ b/tools/skdiff/skdiff_utils.cpp @@ -34,7 +34,8 @@ sk_sp<SkData> read_file(const char* file_path) { return data; } -bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly) { +bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly, + bool ignoreColorSpace) { auto codec = SkCodec::MakeFromData(fileBits); if (!codec) { SkDebugf("ERROR: could not create codec for <%s>\n", resource.fFullPath.c_str()); @@ -42,7 +43,18 @@ bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly) { return false; } - if (!resource.fBitmap.setInfo(codec->getInfo().makeColorType(kN32_SkColorType))) { + // If we're "ignoring" color space, then we want the raw pixel values from each image, so we + // decode to the original color space. If we want to account for color spaces, then we want to + // decode each image to the same color space, so that colors that are the "same" (but encoded + // differently) are transformed to some canonical representation prior to comparison. + // + // TODO: Use something wider than sRGB to avoid clipping with out-of-gamut colors. + SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType); + if (!ignoreColorSpace) { + info = info.makeColorSpace(SkColorSpace::MakeSRGB()); + } + + if (!resource.fBitmap.setInfo(info.makeColorType(kN32_SkColorType))) { SkDebugf("ERROR: could not set bitmap info for <%s>\n", resource.fFullPath.c_str()); resource.fStatus = DiffResource::kCouldNotDecode_Status; return false; |