Fix build with png-1.5.

This commit is contained in:
Thomas Klausner 2011-01-19 07:57:49 +00:00
parent bb70737773
commit 5f90b51e3f
2 changed files with 86 additions and 1 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.6 2010/12/16 14:31:38 rxg Exp $
$NetBSD: distinfo,v 1.7 2011/01/19 07:57:49 thomasklausner Exp $
SHA1 (chromium-7.0.517.43.tar.bz2) = e8294b6cd50aa41f28aaa7e5d10b2ca80be314cd
RMD160 (chromium-7.0.517.43.tar.bz2) = 5136c9d8b7ef458f5bc58b3c3e92876b8d195cf3
@ -124,3 +124,4 @@ SHA1 (patch-eo) = 1bd3e925ac7f9c6fd1f1c961b766360d551d9bf9
SHA1 (patch-ep) = 064e875d9642420145f542050e17301ab64a545e
SHA1 (patch-eq) = e5d71943a6464b6c65da6a17223a92f28e5e4a31
SHA1 (patch-er) = 609079f9baf3446d0de74828b698391ec66264ca
SHA1 (patch-es) = c3305058e78c7fd0a1741ed594a2cdb449fd8824

84
chromium/patches/patch-es Normal file
View file

@ -0,0 +1,84 @@
$NetBSD: patch-es,v 1.1 2011/01/19 07:57:49 thomasklausner Exp $
Fix build with png-1.5, from John Bowler.
--- third_party/WebKit/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp.orig 2010-10-15 08:32:39.000000000 +0000
+++ third_party/WebKit/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -136,14 +136,31 @@ public:
const char* segment;
while (unsigned segmentLength = data.getSomeData(segment, m_readOffset)) {
- m_readOffset += segmentLength;
- m_currentBufferSize = m_readOffset;
- png_process_data(m_png, m_info, reinterpret_cast<png_bytep>(const_cast<char*>(segment)), segmentLength);
- // We explicitly specify the superclass isSizeAvailable() because we
- // merely want to check if we've managed to set the size, not
- // (recursively) trigger additional decoding if we haven't.
- if (sizeOnly ? decoder->ImageDecoder::isSizeAvailable() : decoder->isComplete())
- return true;
+ if (sizeOnly) {
+ while (segmentLength > 0) {
+ // Unfortunately if we read the image at this point it will be ignored,
+ // therefore take small steps through the data until the head is read.
+ // This is crude but effective.
+ m_currentBufferSize = ++m_readOffset;
+ png_process_data(m_png, m_info, reinterpret_cast<png_bytep>(const_cast<char*>(segment)), 1);
+
+ // We explicitly specify the superclass isSizeAvailable() because we
+ // merely want to check if we've managed to set the size, not
+ // (recursively) trigger additional decoding if we haven't.
+ if (decoder->ImageDecoder::isSizeAvailable())
+ return true;
+
+ --segmentLength;
+ ++segment;
+ }
+ } else {
+ // Just process the whole segment at once:
+ m_readOffset += segmentLength;
+ m_currentBufferSize = m_readOffset;
+ png_process_data(m_png, m_info, reinterpret_cast<png_bytep>(const_cast<char*>(segment)), segmentLength);
+ if (decoder->isComplete())
+ return true;
+ }
}
return false;
}
@@ -224,11 +241,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;
}
@@ -289,12 +306,6 @@ void PNGImageDecoder::headerAvailable()
ASSERT(channels == 3 || channels == 4);
m_reader->setHasAlpha(channels == 4);
-
- if (m_reader->decodingSizeOnly()) {
- // If we only needed the size, halt the reader.
- m_reader->setReadOffset(m_reader->currentBufferSize() - png->buffer_size);
- png->buffer_size = 0;
- }
}
void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int interlacePass)
@@ -315,7 +326,8 @@ void PNGImageDecoder::rowAvailable(unsig
// For PNGs, the frame always fills the entire image.
buffer.setRect(IntRect(IntPoint(), size()));
- if (m_reader->pngPtr()->interlaced)
+ if (png_get_interlace_type(m_reader->pngPtr(), m_reader->infoPtr())
+ != PNG_INTERLACE_NONE)
m_reader->createInterlaceBuffer((m_reader->hasAlpha() ? 4 : 3) * size().width() * size().height());
}