aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkPngCodec.cpp
diff options
context:
space:
mode:
authorGravatar raftias <raftias@google.com>2016-12-08 10:53:24 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-12 17:06:41 +0000
commitd737bee1470bbba8af5c9d74cbec2d731da33804 (patch)
tree12140efa7c572787ee98ad527f54c7586b7b7098 /src/codec/SkPngCodec.cpp
parentccd0eeecae63d2c43ad96fbfc2417b812f0588f9 (diff)
Updated the get_images_from_skps tool to check for ICC profile support
Tool will now check for and output all unsuccessfully parsed ICC profiles in input sksp images if --testColorCorrectionSupported is set as a flag. All ICC-aware codecs had to be slightly modified in order to expose this information, as the logic for accessing the ICC profiles is all within the codecs. If --writeFailedImages is set, it will also output all images whoses ICC profiles were not supported. TBR=reed@google.com BUG=skia: Change-Id: Ic310d82bdebf92f8d3bc0ad3dcc688136b6de377 Reviewed-on: https://skia-review.googlesource.com/5355 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Robert Aftias <raftias@google.com>
Diffstat (limited to 'src/codec/SkPngCodec.cpp')
-rw-r--r--src/codec/SkPngCodec.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 758ffa5130..b8576fbc6c 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -326,8 +326,8 @@ static constexpr float gSRGB_toXYZD50[] {
#endif // LIBPNG >= 1.6
// Returns a colorSpace object that represents any color space information in
-// the encoded data. If the encoded data contains no color space, this will
-// return NULL.
+// the encoded data. If the encoded data contains an invalid/unsupported color space,
+// this will return NULL. If there is no color space information, it will guess sRGB
sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) {
#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
@@ -410,9 +410,9 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) {
#endif // LIBPNG >= 1.6
- // Report that there is no color space information in the PNG. SkPngCodec is currently
- // implemented to guess sRGB in this case.
- return nullptr;
+ // Report that there is no color space information in the PNG.
+ // Guess sRGB in this case.
+ return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
}
void SkPngCodec::allocateStorage(const SkImageInfo& dstInfo) {
@@ -984,8 +984,9 @@ void AutoCleanPng::infoCallback() {
if (fOutCodec) {
SkASSERT(nullptr == *fOutCodec);
sk_sp<SkColorSpace> colorSpace = read_color_space(fPng_ptr, fInfo_ptr);
+ const bool unsupportedICC = !colorSpace;
if (!colorSpace) {
- // Treat unmarked pngs as sRGB.
+ // Treat unsupported/invalid color spaces as sRGB.
colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
}
@@ -1014,6 +1015,7 @@ void AutoCleanPng::infoCallback() {
*fOutCodec = new SkPngInterlacedDecoder(encodedInfo, imageInfo, fStream,
fChunkReader, fPng_ptr, fInfo_ptr, bitDepth, numberPasses);
}
+ (*fOutCodec)->setUnsupportedICC(unsupportedICC);
}