| Index: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
|
| diff --git a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
|
| index 643a2dc5255bb46bf9d40d48c05574727d203a39..e8f0830d7bfaa67174687b45f32685139b77922b 100644
|
| --- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
|
| +++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
|
| @@ -157,21 +157,23 @@ public:
|
| m_transform = 0;
|
| }
|
|
|
| - void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB)
|
| + void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB, ColorProfileStatus* status)
|
| {
|
| clearColorTransform();
|
|
|
| if (colorProfile.isEmpty() && !sRGB)
|
| return;
|
| - qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
|
| - if (!deviceProfile)
|
| - return;
|
| qcms_profile* inputProfile = 0;
|
| if (!colorProfile.isEmpty())
|
| inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
|
| else
|
| inputProfile = qcms_profile_sRGB();
|
| - if (!inputProfile)
|
| + if (!inputProfile) {
|
| + *status = ColorProfileFailedDecode;
|
| + return;
|
| + }
|
| + qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
|
| + if (!deviceProfile)
|
| return;
|
| // We currently only support color profiles for RGB and RGBA images.
|
| ASSERT(rgbData == qcms_profile_get_color_space(inputProfile));
|
| @@ -209,12 +211,13 @@ PNGImageDecoder::~PNGImageDecoder()
|
| }
|
|
|
| #if USE(QCMSLIB)
|
| -static void getColorProfile(png_structp png, png_infop info, ColorProfile& colorProfile, bool& sRGB)
|
| +static void getColorProfile(png_structp png, png_infop info, ColorProfile& colorProfile, bool& sRGB, ColorProfileStatus& status)
|
| {
|
| #ifdef PNG_iCCP_SUPPORTED
|
| ASSERT(colorProfile.isEmpty());
|
| if (png_get_valid(png, info, PNG_INFO_sRGB)) {
|
| sRGB = true;
|
| + status = ColorProfileSuccess_PNGsRGB;
|
| return;
|
| }
|
|
|
| @@ -226,20 +229,24 @@ static void getColorProfile(png_structp png, png_infop info, ColorProfile& color
|
| png_bytep profile;
|
| #endif
|
| png_uint_32 profileLength;
|
| - if (!png_get_iCCP(png, info, &profileName, &compressionType, &profile, &profileLength))
|
| + if (!png_get_iCCP(png, info, &profileName, &compressionType, &profile, &profileLength)) {
|
| + status = ColorProfileNone;
|
| return;
|
| + }
|
|
|
| // Only accept RGB color profiles from input class devices.
|
| - bool ignoreProfile = false;
|
| + ASSERT(status == ColorProfileSuccess);
|
| char* profileData = reinterpret_cast<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;
|
|
|
| - if (!ignoreProfile)
|
| + if (status == ColorProfileSuccess)
|
| colorProfile.append(profileData, profileLength);
|
| #endif
|
| }
|
| @@ -297,9 +304,11 @@ void PNGImageDecoder::headerAvailable()
|
| // hand that to CoreGraphics.
|
| bool sRGB = false;
|
| ColorProfile colorProfile;
|
| - getColorProfile(png, info, colorProfile, sRGB);
|
| + ColorProfileStatus status = ColorProfileSuccess;
|
| + getColorProfile(png, info, colorProfile, sRGB, status);
|
| bool imageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount;
|
| - m_reader->createColorTransform(colorProfile, imageHasAlpha, sRGB);
|
| + m_reader->createColorTransform(colorProfile, imageHasAlpha, sRGB, &status);
|
| + Platform::current()->histogramEnumeration("ColorManagement.PNGColorProfileStatus", status, ColorProfileStatus::ValueCount);
|
| m_hasColorProfile = !!m_reader->colorTransform();
|
| }
|
| #endif
|
|
|