| 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..52266326917435362cb8cfa4ad52b696620d5f09 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;
|
| 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;
|
| + else if (ImageDecoder::isICCv4(profileData, profileLength))
|
| + status = ColorProfileIsV4;
|
| else if (!ImageDecoder::rgbColorProfile(profileData, profileLength))
|
| - ignoreProfile = true;
|
| + status = ColorProfileIsNotRGB;
|
| else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileLength))
|
| - ignoreProfile = true;
|
| + status = ColorProfileIsNotAnInputProfile;
|
|
|
| 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.JPEGColorProfileStatus", 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;
|
| 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;
|
|
|