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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 longjmp(JMPBUF(png), 1); | 82 longjmp(JMPBUF(png), 1); |
83 } | 83 } |
84 | 84 |
85 } // anonymous | 85 } // anonymous |
86 | 86 |
87 namespace blink { | 87 namespace blink { |
88 | 88 |
89 class PNGImageReader { | 89 class PNGImageReader { |
90 WTF_MAKE_FAST_ALLOCATED(PNGImageReader); | 90 WTF_MAKE_FAST_ALLOCATED(PNGImageReader); |
91 public: | 91 public: |
92 PNGImageReader(PNGImageDecoder* decoder, unsigned readOffset) | 92 PNGImageReader(PNGImageDecoder* decoder) |
93 : m_decoder(decoder) | 93 : m_decoder(decoder) |
94 , m_readOffset(readOffset) | 94 , m_readOffset(0) |
95 , m_currentBufferSize(0) | 95 , m_currentBufferSize(0) |
96 , m_decodingSizeOnly(false) | 96 , m_decodingSizeOnly(false) |
97 , m_hasAlpha(false) | 97 , m_hasAlpha(false) |
98 #if USE(QCMSLIB) | 98 #if USE(QCMSLIB) |
99 , m_transform(0) | 99 , m_transform(0) |
100 , m_rowBuffer() | 100 , m_rowBuffer() |
101 #endif | 101 #endif |
102 { | 102 { |
103 m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, pngFailed, 0); | 103 m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, pngFailed, 0); |
104 m_info = png_create_info_struct(m_png); | 104 m_info = png_create_info_struct(m_png); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 unsigned m_currentBufferSize; | 197 unsigned m_currentBufferSize; |
198 bool m_decodingSizeOnly; | 198 bool m_decodingSizeOnly; |
199 bool m_hasAlpha; | 199 bool m_hasAlpha; |
200 OwnPtr<png_byte[]> m_interlaceBuffer; | 200 OwnPtr<png_byte[]> m_interlaceBuffer; |
201 #if USE(QCMSLIB) | 201 #if USE(QCMSLIB) |
202 qcms_transform* m_transform; | 202 qcms_transform* m_transform; |
203 OwnPtr<png_byte[]> m_rowBuffer; | 203 OwnPtr<png_byte[]> m_rowBuffer; |
204 #endif | 204 #endif |
205 }; | 205 }; |
206 | 206 |
207 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp
tion colorOptions, size_t maxDecodedBytes, unsigned offset) | 207 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp
tion colorOptions, size_t maxDecodedBytes) |
208 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) | 208 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) |
209 , m_hasColorProfile(false) | 209 , m_hasColorProfile(false) |
210 , m_offset(offset) | |
211 { | 210 { |
212 } | 211 } |
213 | 212 |
214 PNGImageDecoder::~PNGImageDecoder() | 213 PNGImageDecoder::~PNGImageDecoder() |
215 { | 214 { |
216 } | 215 } |
217 | 216 |
218 #if USE(QCMSLIB) | 217 #if USE(QCMSLIB) |
219 static void getColorProfile(png_structp png, png_infop info, ColorProfile& color
Profile, bool& sRGB) | 218 static void getColorProfile(png_structp png, png_infop info, ColorProfile& color
Profile, bool& sRGB) |
220 { | 219 { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 { | 488 { |
490 return decoder->frameIsCompleteAtIndex(0); | 489 return decoder->frameIsCompleteAtIndex(0); |
491 } | 490 } |
492 | 491 |
493 void PNGImageDecoder::decode(bool onlySize) | 492 void PNGImageDecoder::decode(bool onlySize) |
494 { | 493 { |
495 if (failed()) | 494 if (failed()) |
496 return; | 495 return; |
497 | 496 |
498 if (!m_reader) | 497 if (!m_reader) |
499 m_reader = adoptPtr(new PNGImageReader(this, m_offset)); | 498 m_reader = adoptPtr(new PNGImageReader(this)); |
500 | 499 |
501 // If we couldn't decode the image but have received all the data, decoding | 500 // If we couldn't decode the image but have received all the data, decoding |
502 // has failed. | 501 // has failed. |
503 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) | 502 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) |
504 setFailed(); | 503 setFailed(); |
505 | 504 |
506 // If decoding is done or failed, we don't need the PNGImageReader anymore. | 505 // If decoding is done or failed, we don't need the PNGImageReader anymore. |
507 if (isComplete(this) || failed()) | 506 if (isComplete(this) || failed()) |
508 m_reader.clear(); | 507 m_reader.clear(); |
509 } | 508 } |
510 | 509 |
511 } // namespace blink | 510 } // namespace blink |
OLD | NEW |