| Index: Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| diff --git a/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| index 5da5d357157ecd6047d9358012230ff7a20178f6..1efa815fefabbd593f3def84530adc7664ca2fa6 100644
|
| --- a/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| +++ b/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| @@ -305,9 +305,7 @@ public:
|
| m_info.src = 0;
|
|
|
| #if USE(QCMSLIB)
|
| - if (m_transform)
|
| - qcms_transform_release(m_transform);
|
| - m_transform = 0;
|
| + clearColorTransform();
|
| #endif
|
| jpeg_destroy_decompress(&m_info);
|
| }
|
| @@ -391,12 +389,23 @@ public:
|
| ColorProfile colorProfile;
|
| readColorProfile(info(), colorProfile);
|
| createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space));
|
| + m_decoder->setHasColorProfile(!!m_transform);
|
| + if (m_transform) {
|
| + // FIXME: paint-time color correction is assumed here.
|
| + qcms_profile* profile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
|
| + RefPtr<ColorSpaceProfile> imageColorProfile = ColorSpaceProfile::create(profile);
|
| + bool hasColorProfile = !!imageColorProfile->profile();
|
| + m_decoder->setHasColorProfile(hasColorProfile);
|
| + m_decoder->setColorProfile(hasColorProfile ? imageColorProfile : nullptr);
|
| + // Don't color correct decoded frames during decoding.
|
| + clearColorTransform();
|
| + ASSERT(!m_transform);
|
| + }
|
| #if defined(TURBO_JPEG_RGB_SWIZZLE)
|
| // Input RGBA data to qcms. Note: restored to BGRA on output.
|
| if (m_transform && m_info.out_color_space == JCS_EXT_BGRA)
|
| m_info.out_color_space = JCS_EXT_RGBA;
|
| #endif
|
| - m_decoder->setHasColorProfile(!!m_transform);
|
| }
|
| #endif
|
| // Don't allocate a giant and superfluous memory buffer when the
|
| @@ -521,12 +530,16 @@ public:
|
| #if USE(QCMSLIB)
|
| qcms_transform* colorTransform() const { return m_transform; }
|
|
|
| - void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
|
| + void clearColorTransform()
|
| {
|
| if (m_transform)
|
| qcms_transform_release(m_transform);
|
| m_transform = 0;
|
| + }
|
|
|
| + void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
|
| + {
|
| + clearColorTransform();
|
| if (colorProfile.isEmpty())
|
| return;
|
| qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
|
| @@ -665,6 +678,15 @@ ImageFrame* JPEGImageDecoder::frameBufferAtIndex(size_t index)
|
| return &frame;
|
| }
|
|
|
| +PassRefPtr<ColorSpaceProfile> JPEGImageDecoder::colorProfile() const
|
| +{
|
| +#if USE(QCMSLIB)
|
| + return m_colorProfile;
|
| +#else
|
| + return nullptr;
|
| +#endif
|
| +}
|
| +
|
| bool JPEGImageDecoder::setFailed()
|
| {
|
| m_reader.clear();
|
|
|