| 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 20ecd74b10db7ac385a1bb962a3005317aa34292..de4984c216d81f4f2fce023e17429e30bdc141cf 100644
|
| --- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
|
| +++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
|
| @@ -38,6 +38,8 @@
|
|
|
| #include "platform/image-decoders/png/PNGImageDecoder.h"
|
|
|
| +#include "platform/graphics/GraphicsScreen.h"
|
| +
|
| #include "png.h"
|
| #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR)
|
| #error version error: compile against a versioned libpng.
|
| @@ -157,36 +159,45 @@ public:
|
| m_transform = 0;
|
| }
|
|
|
| - void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB)
|
| + PassRefPtr<ColorSpaceProfile> createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB)
|
| {
|
| clearColorTransform();
|
|
|
| if (colorProfile.isEmpty() && !sRGB)
|
| - return;
|
| + return nullptr;
|
| +
|
| qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
|
| if (!deviceProfile)
|
| - return;
|
| + return nullptr;
|
| +
|
| qcms_profile* inputProfile = 0;
|
| if (!colorProfile.isEmpty())
|
| inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
|
| else
|
| inputProfile = qcms_profile_sRGB();
|
| if (!inputProfile)
|
| - return;
|
| + return nullptr;
|
| +
|
| + if (imageColorProfilesEnabled())
|
| + return ColorSpaceProfile::create(inputProfile);
|
|
|
| // We currently only support color profiles for RGB and RGBA images.
|
| ASSERT(rgbData == qcms_profile_get_color_space(inputProfile));
|
|
|
| if (qcms_profile_match(inputProfile, deviceProfile)) {
|
| qcms_profile_release(inputProfile);
|
| - return;
|
| + return nullptr;
|
| }
|
|
|
| // FIXME: Don't force perceptual intent if the image profile contains an intent.
|
| qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
|
| m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL);
|
|
|
| + if (m_transform)
|
| + return ColorSpaceProfile::create(inputProfile);
|
| +
|
| qcms_profile_release(inputProfile);
|
| + return nullptr;
|
| }
|
| #endif
|
|
|
| @@ -307,8 +318,16 @@ void PNGImageDecoder::headerAvailable()
|
| ColorProfile colorProfile;
|
| getColorProfile(png, info, colorProfile, sRGB);
|
| bool imageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount;
|
| - m_reader->createColorTransform(colorProfile, imageHasAlpha, sRGB);
|
| - m_hasColorProfile = !!m_reader->colorTransform();
|
| + RefPtr<ColorSpaceProfile> imageColorProfile = m_reader->createColorTransform(colorProfile, imageHasAlpha, sRGB);
|
| + m_hasColorProfile = !!imageColorProfile.get();
|
| +
|
| + if (m_hasColorProfile && imageColorProfilesEnabled()) {
|
| + RELEASE_ASSERT(imageColorProfile->profile());
|
| + m_colorProfile = imageColorProfile;
|
| + // Do not color correct decoded frames during decoding.
|
| + m_reader->clearColorTransform();
|
| + RELEASE_ASSERT(!m_reader->colorTransform());
|
| + }
|
| }
|
| #endif
|
|
|
|
|