| Index: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| diff --git a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| index 5e3fd56c252b085e04744899b3ad87ddf6de2812..89c60c5fb57b4fb8d110f5701de4f2aae538d7f0 100644
|
| --- a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| +++ b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| @@ -38,6 +38,7 @@
|
| #include "platform/image-decoders/jpeg/JPEGImageDecoder.h"
|
|
|
| #include "platform/PlatformInstrumentation.h"
|
| +#include "platform/graphics/GraphicsScreen.h"
|
|
|
| extern "C" {
|
| #include <stdio.h> // jpeglib.h needs stdio FILE.
|
| @@ -479,8 +480,22 @@ public:
|
| if (!m_decoder->ignoresGammaAndColorProfile()) {
|
| ColorProfile colorProfile;
|
| readColorProfile(info(), colorProfile);
|
| - createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space));
|
| - if (m_transform) {
|
| + bool imageHasAlpha = colorSpaceHasAlpha(m_info.out_color_space);
|
| + RefPtr<ColorSpaceProfile> imageColorProfile = createColorTransform(colorProfile, imageHasAlpha);
|
| + m_decoder->setHasColorProfile(!!imageColorProfile.get());
|
| +
|
| + if (m_decoder->hasColorProfile() && imageColorProfilesEnabled()) {
|
| + // FIXME: allow YUV decoding of color profiled images.
|
| + overrideColorSpace = JCS_UNKNOWN;
|
| + RELEASE_ASSERT(imageColorProfile->profile());
|
| + m_decoder->setColorProfile(imageColorProfile);
|
| + // Do not color correct decoded frames during decoding.
|
| + clearColorTransform();
|
| + RELEASE_ASSERT(!m_transform);
|
| + }
|
| +
|
| + if (m_decoder->hasColorProfile() && !imageColorProfilesEnabled()) {
|
| + // FIXME: allow YUV decoding of color profiled images.
|
| overrideColorSpace = JCS_UNKNOWN;
|
| #if defined(TURBO_JPEG_RGB_SWIZZLE)
|
| // Input RGBA data to qcms. Note: restored to BGRA on output.
|
| @@ -488,7 +503,6 @@ public:
|
| m_info.out_color_space = JCS_EXT_RGBA;
|
| #endif
|
| }
|
| - m_decoder->setHasColorProfile(!!m_transform);
|
| }
|
| #endif
|
| if (overrideColorSpace == JCS_YCbCr) {
|
| @@ -637,32 +651,41 @@ public:
|
| m_transform = 0;
|
| }
|
|
|
| - void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
|
| + PassRefPtr<ColorSpaceProfile> createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
|
| {
|
| clearColorTransform();
|
|
|
| if (colorProfile.isEmpty())
|
| - return;
|
| + return nullptr;
|
| +
|
| qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
|
| if (!deviceProfile)
|
| - return;
|
| + return nullptr;
|
| +
|
| qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
|
| if (!inputProfile)
|
| - return;
|
| + return nullptr;
|
| +
|
| + if (imageColorProfilesEnabled())
|
| + return ColorSpaceProfile::create(inputProfile);
|
|
|
| // We currently only support color profiles for RGB profiled images.
|
| ASSERT(rgbData == qcms_profile_get_color_space(inputProfile));
|
|
|
| if (qcms_profile_match(inputProfile, deviceProfile)) {
|
| qcms_profile_release(inputProfile);
|
| - return;
|
| + return nullptr;
|
| }
|
|
|
| // FIXME: Don't force perceptual intent if the image profile contains an intent.
|
| qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
|
| m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL);
|
|
|
| + if (m_transform)
|
| + return ColorSpaceProfile::create(inputProfile);
|
| +
|
| qcms_profile_release(inputProfile);
|
| + return nullptr;
|
| }
|
| #endif
|
|
|
|
|