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..34d9b03a4108d89e77e5d6d350c93a62f48b1de0 100644 |
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp |
@@ -239,8 +239,15 @@ bool WEBPImageDecoder::updateDemuxer() |
} |
#if USE(QCMSLIB) |
- if ((m_formatFlags & ICCP_FLAG) && !ignoresGammaAndColorProfile()) |
- readColorProfile(); |
+ if (!ignoresGammaAndColorProfile()) { |
+ ColorProfileStatus status; |
+ if ((m_formatFlags & ICCP_FLAG)) { |
+ status = readColorProfile(); |
+ } else { |
+ status = ColorProfileNone; |
Noel Gordon
2015/12/23 15:28:48
ColorProfileEmpty
|
+ } |
+ Platform::current()->histogramEnumeration("ColorManagement.ColorProfileStatus.WEBP", status, ColorProfileStatus::ValueCount); |
+ } |
#endif |
} |
@@ -316,17 +323,19 @@ void WEBPImageDecoder::clearColorTransform() |
m_transform = 0; |
} |
-bool WEBPImageDecoder::createColorTransform(const char* data, size_t size) |
+bool WEBPImageDecoder::createColorTransform(const char* data, size_t size, ColorProfileStatus& status) |
{ |
clearColorTransform(); |
- qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); |
- if (!deviceProfile) |
- return false; |
qcms_profile* inputProfile = qcms_profile_from_memory(data, size); |
- if (!inputProfile) |
+ if (!inputProfile) { |
+ status = ColorProfileFailedDecode; |
Noel Gordon
2015/12/23 15:28:48
ColorProfileFailedDecode -> ColorProfileInvalidCon
|
return false; |
+ } |
+ qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); |
+ if (!deviceProfile) |
+ return false; |
// We currently only support color profiles for RGB profiled images. |
ASSERT(rgbData == qcms_profile_get_color_space(inputProfile)); |
// The input image pixels are RGBA format. |
@@ -338,30 +347,33 @@ bool WEBPImageDecoder::createColorTransform(const char* data, size_t size) |
return !!m_transform; |
} |
-void WEBPImageDecoder::readColorProfile() |
+ColorProfileStatus WEBPImageDecoder::readColorProfile() |
{ |
WebPChunkIterator chunkIterator; |
if (!WebPDemuxGetChunk(m_demux, "ICCP", 1, &chunkIterator)) { |
WebPDemuxReleaseChunkIterator(&chunkIterator); |
- return; |
+ return ColorProfileNotFound; |
Noel Gordon
2015/12/23 15:28:48
ColorProfileNotFound -> ColorProfileEmpty
|
} |
const char* profileData = reinterpret_cast<const char*>(chunkIterator.chunk.bytes); |
size_t profileSize = chunkIterator.chunk.size; |
// Only accept RGB color profiles from input class devices. |
- bool ignoreProfile = false; |
+ ColorProfileStatus status = ColorProfileSuccess; |
Noel Gordon
2015/12/23 15:28:48
362-370, same as per the JPEG decoder.
|
if (profileSize < ImageDecoder::iccColorProfileHeaderLength) |
- ignoreProfile = true; |
+ status = ColorProfileIsCorrupted; |
+ else if (ImageDecoder::isICCv4(profileData, profileSize)) |
+ status = ColorProfileIsV4; |
else if (!ImageDecoder::rgbColorProfile(profileData, profileSize)) |
- ignoreProfile = true; |
+ status = ColorProfileIsNotRGB; |
else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileSize)) |
- ignoreProfile = true; |
+ status = ColorProfileIsNotAnInputProfile; |
- if (!ignoreProfile) |
- m_hasColorProfile = createColorTransform(profileData, profileSize); |
+ if (status == ColorProfileSuccess) |
+ m_hasColorProfile = createColorTransform(profileData, profileSize, status); |
WebPDemuxReleaseChunkIterator(&chunkIterator); |
+ return status; |
} |
#endif // USE(QCMSLIB) |