Index: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
diff --git a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
index ce5a2f5813707ffd96d654517ea30ee105322ddf..6d375a8e183e621a71a88bef632e0fd08e272a88 100644 |
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
@@ -28,6 +28,8 @@ |
#include "platform/image-decoders/webp/WEBPImageDecoder.h" |
+#include "platform/graphics/GraphicsScreen.h" |
+ |
#if USE(QCMSLIB) |
#include "qcms.h" |
#endif |
@@ -315,23 +317,27 @@ void WEBPImageDecoder::clearColorTransform() |
m_transform = 0; |
} |
-bool WEBPImageDecoder::createColorTransform(const char* data, size_t size) |
+PassRefPtr<ColorSpaceProfile> WEBPImageDecoder::createColorTransform(const char* data, size_t size) |
{ |
clearColorTransform(); |
qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); |
if (!deviceProfile) |
- return false; |
+ return nullptr; |
+ |
qcms_profile* inputProfile = qcms_profile_from_memory(data, size); |
if (!inputProfile) |
- return false; |
+ 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 false; |
+ return nullptr; |
} |
// The input image pixels are RGBA format. |
@@ -339,14 +345,18 @@ bool WEBPImageDecoder::createColorTransform(const char* data, size_t size) |
// FIXME: Don't force perceptual intent if the image profile contains an intent. |
m_transform = qcms_transform_create(inputProfile, format, deviceProfile, QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL); |
+ if (m_transform) |
+ return ColorSpaceProfile::create(inputProfile); |
+ |
qcms_profile_release(inputProfile); |
- return !!m_transform; |
+ return nullptr; |
} |
void WEBPImageDecoder::readColorProfile() |
{ |
WebPChunkIterator chunkIterator; |
if (!WebPDemuxGetChunk(m_demux, "ICCP", 1, &chunkIterator)) { |
+ RELEASE_ASSERT(!m_hasColorProfile && !m_transform); |
WebPDemuxReleaseChunkIterator(&chunkIterator); |
return; |
} |
@@ -363,8 +373,22 @@ void WEBPImageDecoder::readColorProfile() |
else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileSize)) |
ignoreProfile = true; |
- if (!ignoreProfile) |
- m_hasColorProfile = createColorTransform(profileData, profileSize); |
+ if (ignoreProfile) { |
+ RELEASE_ASSERT(!m_hasColorProfile && !m_transform); |
+ WebPDemuxReleaseChunkIterator(&chunkIterator); |
+ return; |
+ } |
+ |
+ RefPtr<ColorSpaceProfile> imageColorProfile = createColorTransform(profileData, profileSize); |
+ m_hasColorProfile = !!imageColorProfile.get(); |
+ |
+ if (m_hasColorProfile && imageColorProfilesEnabled()) { |
+ RELEASE_ASSERT(imageColorProfile->profile()); |
+ m_colorProfile = imageColorProfile; |
+ // Do not color correct decoded frames during decoding. |
+ clearColorTransform(); |
+ RELEASE_ASSERT(!m_transform); |
+ } |
WebPDemuxReleaseChunkIterator(&chunkIterator); |
} |