| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
| 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 2001 mozilla.org | 5 * Portions are Copyright (C) 2001 mozilla.org |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Stuart Parmenter <stuart@mozilla.com> | 8 * Stuart Parmenter <stuart@mozilla.com> |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 class PNGImageReader final { | 86 class PNGImageReader final { |
| 87 USING_FAST_MALLOC(PNGImageReader); | 87 USING_FAST_MALLOC(PNGImageReader); |
| 88 WTF_MAKE_NONCOPYABLE(PNGImageReader); | 88 WTF_MAKE_NONCOPYABLE(PNGImageReader); |
| 89 public: | 89 public: |
| 90 PNGImageReader(PNGImageDecoder* decoder, size_t readOffset) | 90 PNGImageReader(PNGImageDecoder* decoder, size_t readOffset) |
| 91 : m_decoder(decoder) | 91 : m_decoder(decoder) |
| 92 , m_readOffset(readOffset) | 92 , m_readOffset(readOffset) |
| 93 , m_currentBufferSize(0) | 93 , m_currentBufferSize(0) |
| 94 , m_decodingSizeOnly(false) | 94 , m_decodingSizeOnly(false) |
| 95 , m_hasAlpha(false) | 95 , m_hasAlpha(true) |
| 96 #if USE(QCMSLIB) | 96 #if USE(QCMSLIB) |
| 97 , m_rowBuffer() | 97 , m_rowBuffer() |
| 98 #endif | 98 #endif |
| 99 { | 99 { |
| 100 m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, pngFailed, 0); | 100 m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, pngFailed, 0); |
| 101 m_info = png_create_info_struct(m_png); | 101 m_info = png_create_info_struct(m_png); |
| 102 png_set_progressive_read_fn(m_png, m_decoder, pngHeaderAvailable, pngRow
Available, pngComplete); | 102 png_set_progressive_read_fn(m_png, m_decoder, pngHeaderAvailable, pngRow
Available, pngComplete); |
| 103 } | 103 } |
| 104 | 104 |
| 105 ~PNGImageReader() | 105 ~PNGImageReader() |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp
tion colorOptions, size_t maxDecodedBytes, size_t offset) | 163 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp
tion colorOptions, size_t maxDecodedBytes, size_t offset) |
| 164 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) | 164 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) |
| 165 , m_offset(offset) | 165 , m_offset(offset) |
| 166 { | 166 { |
| 167 } | 167 } |
| 168 | 168 |
| 169 PNGImageDecoder::~PNGImageDecoder() | 169 PNGImageDecoder::~PNGImageDecoder() |
| 170 { | 170 { |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool PNGImageDecoder::frameHasAlphaAtIndex(size_t index) const |
| 174 { |
| 175 if (index == 0 && isAllDataReceived() && m_reader && !m_reader->hasAlpha()) |
| 176 return false; |
| 177 return ImageDecoder::frameHasAlphaAtIndex(index); |
| 178 } |
| 179 |
| 173 void PNGImageDecoder::headerAvailable() | 180 void PNGImageDecoder::headerAvailable() |
| 174 { | 181 { |
| 175 png_structp png = m_reader->pngPtr(); | 182 png_structp png = m_reader->pngPtr(); |
| 176 png_infop info = m_reader->infoPtr(); | 183 png_infop info = m_reader->infoPtr(); |
| 177 png_uint_32 width = png_get_image_width(png, info); | 184 png_uint_32 width = png_get_image_width(png, info); |
| 178 png_uint_32 height = png_get_image_height(png, info); | 185 png_uint_32 height = png_get_image_height(png, info); |
| 179 | 186 |
| 180 // Protect against large PNGs. See http://bugzil.la/251381 for more details. | 187 // Protect against large PNGs. See http://bugzil.la/251381 for more details. |
| 181 const unsigned long maxPNGSize = 1000000UL; | 188 const unsigned long maxPNGSize = 1000000UL; |
| 182 if (width > maxPNGSize || height > maxPNGSize) { | 189 if (width > maxPNGSize || height > maxPNGSize) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // has failed. | 439 // has failed. |
| 433 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) | 440 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) |
| 434 setFailed(); | 441 setFailed(); |
| 435 | 442 |
| 436 // If decoding is done or failed, we don't need the PNGImageReader anymore. | 443 // If decoding is done or failed, we don't need the PNGImageReader anymore. |
| 437 if (isComplete(this) || failed()) | 444 if (isComplete(this) || failed()) |
| 438 m_reader.clear(); | 445 m_reader.clear(); |
| 439 } | 446 } |
| 440 | 447 |
| 441 } // namespace blink | 448 } // namespace blink |
| OLD | NEW |