Index: Source/platform/image-decoders/png/PNGImageDecoder.cpp |
diff --git a/Source/platform/image-decoders/png/PNGImageDecoder.cpp b/Source/platform/image-decoders/png/PNGImageDecoder.cpp |
index c62a4e1bb0031f7680529e51ecdb0f57d8d05e87..394c456b152ffe75cd4ddaebfd7e0eef51a81e78 100644 |
--- a/Source/platform/image-decoders/png/PNGImageDecoder.cpp |
+++ b/Source/platform/image-decoders/png/PNGImageDecoder.cpp |
@@ -129,9 +129,7 @@ public: |
// This will zero the pointers. |
png_destroy_read_struct(&m_png, &m_info, 0); |
#if USE(QCMSLIB) |
- if (m_transform) |
- qcms_transform_release(m_transform); |
- m_transform = 0; |
+ clearColorTransform(); |
#endif |
delete[] m_interlaceBuffer; |
m_interlaceBuffer = 0; |
@@ -177,12 +175,16 @@ public: |
void createRowBuffer(int size) { m_rowBuffer = adoptArrayPtr(new png_byte[size]); } |
qcms_transform* colorTransform() const { return m_transform; } |
- void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha) |
+ void clearColorTransform() |
{ |
if (m_transform) |
qcms_transform_release(m_transform); |
m_transform = 0; |
+ } |
+ void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha) |
+ { |
+ clearColorTransform(); |
if (colorProfile.isEmpty()) |
return; |
qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); |
@@ -264,6 +266,15 @@ bool PNGImageDecoder::setFailed() |
return ImageDecoder::setFailed(); |
} |
+PassRefPtr<ColorSpaceProfile> PNGImageDecoder::colorProfile() const |
+{ |
+#if USE(QCMSLIB) |
+ return m_colorProfile; |
+#else |
+ return nullptr; |
+#endif |
+} |
+ |
#if USE(QCMSLIB) |
static void readColorProfile(png_structp png, png_infop info, ColorProfile& colorProfile) |
{ |
@@ -357,6 +368,16 @@ void PNGImageDecoder::headerAvailable() |
bool decodedImageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount; |
m_reader->createColorTransform(colorProfile, decodedImageHasAlpha); |
m_hasColorProfile = !!m_reader->colorTransform(); |
+ if (m_hasColorProfile) { |
+ // FIXME: paint-time color correction is assumed here. |
+ qcms_profile* profile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size()); |
+ RefPtr<ColorSpaceProfile> imageColorProfile = ColorSpaceProfile::create(profile); |
+ m_hasColorProfile = !!imageColorProfile->profile(); |
+ m_colorProfile = m_hasColorProfile ? imageColorProfile : nullptr; |
+ // Don't color correct decoded frames during decoding. |
+ m_reader->clearColorTransform(); |
+ ASSERT(!m_reader->colorTransform()); |
+ } |
} |
#endif |