| Index: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| index 440e16a3e3af68ffdd1031bc7fd9eb7803dc3732..414eb0283c672a3f415b600816417a10871456ec 100644
|
| --- a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| +++ b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| @@ -549,8 +549,26 @@ sk_sp<SkColorSpace> ImageDecoder::colorSpaceForSkImages() const {
|
| if (!m_colorBehavior.isTag())
|
| return nullptr;
|
|
|
| - if (m_embeddedColorSpace)
|
| - return m_embeddedColorSpace;
|
| + if (m_embeddedColorSpace) {
|
| + SkColorSpaceTransferFn fn;
|
| + if (m_embeddedColorSpace->isNumericalTransferFn(&fn)) {
|
| + // The embedded color space is supported by Skia.
|
| + return m_embeddedColorSpace;
|
| + }
|
| +
|
| + // In the rare case that the embedded color space is unsupported, xform at
|
| + // decode time.
|
| + SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor);
|
| + if (m_embeddedColorSpace->toXYZD50(&toXYZD50)) {
|
| + // Preserve the gamut, but convert to a standard transfer function.
|
| + return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
|
| + toXYZD50);
|
| + }
|
| +
|
| + // For color spaces without an identifiable gamut, just fall through to
|
| + // sRGB.
|
| + }
|
| +
|
| return SkColorSpace::MakeSRGB();
|
| }
|
|
|
|
|