| 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..522797d8b05f46f34898d8c886086ef1089e8969 100644 | 
| --- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp | 
| +++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp | 
| @@ -39,6 +39,8 @@ | 
| #include "config.h" | 
| #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,28 +159,53 @@ public: | 
| m_transform = 0; | 
| } | 
|  | 
| -    void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB) | 
| +    PassRefPtr<ColorSpaceProfile> createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB) | 
| { | 
| clearColorTransform(); | 
|  | 
| +        fprintf(stderr, "PNG decoder %p createColorTransform ", m_decoder); | 
| +        if (m_decoder->deviceProfile()) | 
| +            fprintf(stderr, ": device %p\n", m_decoder->deviceProfile().get()); | 
| +        else | 
| +            fprintf(stderr, ": %p\n", nullptr); | 
| +        fprintf(stderr, "image color profiles enabled: %d\n", imageColorProfilesEnabled()); | 
| +        fflush(stderr); | 
| + | 
| if (colorProfile.isEmpty() && !sRGB) | 
| -            return; | 
| +            return nullptr; | 
| + | 
| qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); | 
| +        if (m_decoder->deviceProfile()) | 
| +            deviceProfile = m_decoder->deviceProfile()->profile(); | 
| if (!deviceProfile) | 
| -            return; | 
| -        qcms_profile* inputProfile = 0; | 
| +            return nullptr; | 
| + | 
| +        qcms_profile* inputProfile = nullptr; | 
| if (!colorProfile.isEmpty()) | 
| inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size()); | 
| else | 
| inputProfile = qcms_profile_sRGB(); | 
| if (!inputProfile) | 
| -            return; | 
| +            return nullptr; | 
| + | 
| +        fprintf(stderr, " from source profile [%s]", qcms_profile_get_description(inputProfile)); | 
| +        fprintf(stderr, " to [%s]\n", qcms_profile_get_description(deviceProfile)); | 
| +        fflush(stderr); | 
| + | 
| +        // There is no need to create a color transform if the color profiles match. | 
| +        if (imageColorProfilesEnabled() && qcms_profile_match(inputProfile, deviceProfile)) | 
| +            return ColorSpaceProfile::create(inputProfile); | 
| + | 
| // We currently only support color profiles for RGB and RGBA images. | 
| ASSERT(rgbData == qcms_profile_get_color_space(inputProfile)); | 
| qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; | 
| // FIXME: Don't force perceptual intent if the image profile contains an intent. | 
| 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 | 
|  | 
| @@ -202,10 +229,12 @@ PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp | 
| , m_hasColorProfile(false) | 
| , m_offset(offset) | 
| { | 
| +    fprintf(stderr, "PNG decoder %p created %s\n", this, !isMainThread() ? "impl-side-thread" : ""); | 
| } | 
|  | 
| PNGImageDecoder::~PNGImageDecoder() | 
| { | 
| +    fprintf(stderr, "PNG decoder %p ~PNGImageDecoder() %s\n", this, !isMainThread() ? "impl-side-thread" : ""); | 
| } | 
|  | 
| #if USE(QCMSLIB) | 
| @@ -299,8 +328,12 @@ 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; | 
| +        } | 
| } | 
| #endif | 
|  | 
| @@ -332,6 +365,8 @@ void PNGImageDecoder::headerAvailable() | 
|  | 
| m_reader->setHasAlpha(channels == 4); | 
|  | 
| +    fprintf(stderr, "PNG decoder %p headerAvailable %lux%lu %s\n", this, width, height, m_reader->decodingSizeOnly() ? "size-only-decode" : ""); | 
| + | 
| if (m_reader->decodingSizeOnly()) { | 
| // If we only needed the size, halt the reader. | 
| #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 5) | 
| @@ -434,11 +469,20 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, | 
|  | 
| #if USE(QCMSLIB) | 
| if (qcms_transform* transform = m_reader->colorTransform()) { | 
| +        if (rowIndex < 3 || rowIndex >= (unsigned)size().height() - 1) | 
| +            fprintf(stderr, "PNG decoder %p %dx%d color transform row %d\n", this, size().width(), size().height(), rowIndex); | 
| qcms_transform_data(transform, row, m_reader->rowBuffer(), size().width()); | 
| row = m_reader->rowBuffer(); | 
| } | 
| #endif | 
|  | 
| +    if (rowIndex < 3) | 
| +        fprintf(stderr, "PNG decoder %p %dx%d row %d\n", this, size().width(), size().height(), rowIndex); | 
| +    if (rowIndex >= (unsigned)size().height() - 1) { | 
| +        fprintf(stderr, "PNG decoder %p %dx%d row %d\n", this, size().width(), size().height(), rowIndex); | 
| +        fflush(stderr); | 
| +    } | 
| + | 
| // Write the decoded row pixels to the frame buffer. The repetitive | 
| // form of the row write loops is for speed. | 
| ImageFrame::PixelData* address = buffer.getAddr(0, y); | 
| @@ -472,6 +516,8 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, | 
|  | 
| void PNGImageDecoder::complete() | 
| { | 
| +    fflush(stderr); | 
| + | 
| if (m_frameBufferCache.isEmpty()) | 
| return; | 
|  | 
|  |