2011-02-27 Thomas Klausner Reviewed by NOBODY (OOPS!). png-1.5 fixes https://bugs.webkit.org/show_bug.cgi?id=54406 Fix compilation with png-1.5: struct members were hidden, and a new API to terminate data processing was added (especially for WebKit). Compilation fixes, so no new tests. * platform/image-decoders/png/PNGImageDecoder.cpp: (WebCore::PNGImageDecoder::headerAvailable): (WebCore::PNGImageDecoder::rowAvailable): --- .../image-decoders/png/PNGImageDecoder.cpp | 23 +++++++++++++------ .../image-encoders/skia/PNGImageEncoder.cpp | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/third_party/WebKit/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/third_party/WebKit/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp index 8edfe36..df33c3f 100644 --- a/third_party/WebKit/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp +++ b/third_party/WebKit/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp @@ -224,9 +224,13 @@ bool PNGImageDecoder::setFailed() static ColorProfile readColorProfile(png_structp png, png_infop info) { #ifdef PNG_iCCP_SUPPORTED - char* profileName; + png_charp profileName; int compressionType; - char* profile; +#if (PNG_LIBPNG_VER < 10500) + png_charp profile; +#else + png_bytep profile; +#endif png_uint_32 profileLength; if (png_get_iCCP(png, info, &profileName, &compressionType, &profile, &profileLength)) { ColorProfile colorProfile; @@ -241,11 +245,11 @@ void PNGImageDecoder::headerAvailable() { png_structp png = m_reader->pngPtr(); png_infop info = m_reader->infoPtr(); - png_uint_32 width = png->width; - png_uint_32 height = png->height; + png_uint_32 width = png_get_image_width(png, info); + png_uint_32 height = png_get_image_height(png, info); // Protect against large images. - if (png->width > cMaxPNGSize || png->height > cMaxPNGSize) { + if (width > cMaxPNGSize || height > cMaxPNGSize) { longjmp(JMPBUF(png), 1); return; } @@ -318,9 +322,14 @@ void PNGImageDecoder::headerAvailable() m_reader->setHasAlpha(channels == 4); if (m_reader->decodingSizeOnly()) { - // If we only needed the size, halt the reader. + // If we only needed the size, halt the reader. +#if (PNG_LIBPNG_VER < 10501) m_reader->setReadOffset(m_reader->currentBufferSize() - png->buffer_size); png->buffer_size = 0; +#else + /* '0' argument to png_process_data_pause means: do not save the data */ + m_reader->setReadOffset(m_reader->currentBufferSize() - png_process_data_pause(png, 0)); +#endif } } @@ -343,7 +352,7 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, // For PNGs, the frame always fills the entire image. buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); - if (m_reader->pngPtr()->interlaced) + if (png_get_interlace_type(m_reader->pngPtr(), m_reader->infoPtr())) m_reader->createInterlaceBuffer((m_reader->hasAlpha() ? 4 : 3) * size().width() * size().height()); } diff --git a/third_party/WebKit/Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp b/third_party/WebKit/Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp index 2fc758e..3d57987 100644 --- a/third_party/WebKit/Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp +++ b/third_party/WebKit/Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp @@ -44,7 +44,7 @@ namespace WebCore { static void writeOutput(png_structp png, png_bytep data, png_size_t size) { - static_cast*>(png->io_ptr)->append(data, size); + static_cast*>(png_get_io_ptr(png))->append(data, size); } static void preMultipliedBGRAtoRGBA(const void* pixels, int pixelCount, unsigned char* output)