Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 1488133002: Add usage metrics for display and image color profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added a histogram bucket for ICCv4 Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ec3026cb06be3e6e90f81454646edd1bcf63c1b2 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;
+ }
+ Platform::current()->histogramEnumeration("ColorManagement.WEBPColorProfileStatus", 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;
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;
}
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;
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)

Powered by Google App Engine
This is Rietveld 408576698