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 8653487de0e030332a57d5a41027af96b177d262..84aa389d2f402437c0443b6e901c7ff08c4a9dd5 100644 |
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
@@ -29,6 +29,8 @@ |
#include "config.h" |
#include "platform/image-decoders/webp/WEBPImageDecoder.h" |
+#include "platform/graphics/GraphicsScreen.h" |
+ |
#if USE(QCMSLIB) |
#include "qcms.h" |
#endif |
@@ -316,16 +318,17 @@ 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; |
// We currently only support color profiles for RGB profiled images. |
ASSERT(rgbData == qcms_profile_get_color_space(inputProfile)); |
@@ -333,15 +336,18 @@ bool WEBPImageDecoder::createColorTransform(const char* data, size_t size) |
qcms_data_type format = QCMS_DATA_RGBA_8; |
// 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; |
} |
@@ -358,8 +364,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); |
} |