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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.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: Changed histograms to use suffixes 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/jpeg/JPEGImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
index 01b8f3f880c53b73c69c7ec9112396a946a50381..3c42b306a353273dac3de8df9d9ee39c5c3967ca 100644
--- a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
@@ -205,27 +205,31 @@ static ImageOrientation readImageOrientation(jpeg_decompress_struct* info)
}
#if USE(QCMSLIB)
-static void readColorProfile(jpeg_decompress_struct* info, ColorProfile& colorProfile)
+static void readColorProfile(jpeg_decompress_struct* info, ColorProfile& colorProfile, ColorProfileStatus& status)
{
#if USE(ICCJPEG)
JOCTET* profile;
unsigned profileLength;
- if (!read_icc_profile(info, &profile, &profileLength))
+ if (!read_icc_profile(info, &profile, &profileLength)) {
+ status = ColorProfileNone;
Noel Gordon 2015/12/23 15:28:48 ColorProfileNone -> ColorProfileEmpty
return;
+ }
// Only accept RGB color profiles from input class devices.
- bool ignoreProfile = false;
+ ASSERT(status == ColorProfileSuccess);
char* profileData = reinterpret_cast_ptr<char*>(profile);
if (profileLength < ImageDecoder::iccColorProfileHeaderLength)
- ignoreProfile = true;
+ status = ColorProfileIsCorrupted;
Noel Gordon 2015/12/23 15:28:48 ColorProfileIsCorrupted -> ColorProfileInvalidCont
+ else if (ImageDecoder::isICCv4(profileData, profileLength))
Noel Gordon 2015/12/23 15:28:48 We can remove this, and figure out if we need to r
+ status = ColorProfileIsV4;
else if (!ImageDecoder::rgbColorProfile(profileData, profileLength))
- ignoreProfile = true;
+ status = ColorProfileIsNotRGB;
Noel Gordon 2015/12/23 15:28:48 ColorProfileIsNotRGB -> ColorProfileInvalidContent
else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileLength))
- ignoreProfile = true;
+ status = ColorProfileIsNotAnInputProfile;
Noel Gordon 2015/12/23 15:28:48 ColorProfileIsNotAnInputProfile -> ColorProfileInv
ASSERT(colorProfile.isEmpty());
- if (!ignoreProfile)
+ if (status == ColorProfileSuccess)
colorProfile.append(profileData, profileLength);
free(profile);
#endif
@@ -476,8 +480,10 @@ public:
// Allow color management of the decoded RGBA pixels if possible.
if (!m_decoder->ignoresGammaAndColorProfile()) {
ColorProfile colorProfile;
- readColorProfile(info(), colorProfile);
- createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space));
+ ColorProfileStatus status = ColorProfileSuccess;
+ readColorProfile(info(), colorProfile, status);
+ createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space), status);
+ Platform::current()->histogramEnumeration("ColorManagement.ColorProfileStatus.JPEG", status, ColorProfileStatus::ValueCount);
if (m_transform) {
overrideColorSpace = JCS_UNKNOWN;
#if defined(TURBO_JPEG_RGB_SWIZZLE)
@@ -635,18 +641,20 @@ public:
m_transform = 0;
}
- void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
+ void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, ColorProfileStatus& status)
{
clearColorTransform();
if (colorProfile.isEmpty())
+ return; // status should already have a !success code if this is the case
+ qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
+ if (!inputProfile) {
+ status = ColorProfileFailedDecode;
Noel Gordon 2015/12/23 15:28:48 ColorProfileFailedDecode -> ColorProfileInvalidCon
return;
+ }
qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
if (!deviceProfile)
return;
- qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
- if (!inputProfile)
- return;
// We currently only support color profiles for RGB profiled images.
ASSERT(rgbData == qcms_profile_get_color_space(inputProfile));
qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;

Powered by Google App Engine
This is Rietveld 408576698