Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: Source/platform/image-decoders/png/PNGImageDecoder.cpp

Issue 1316203008: Never consolidate data in ICO decoder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@FastSharedBuffer
Patch Set: Respond to pkasting@'s comments in patch set 2 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/image-decoders/png/PNGImageDecoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) 92 PNGImageReader(PNGImageDecoder* decoder, unsigned readOffset)
93 : m_decoder(decoder) 93 : m_decoder(decoder)
94 , m_readOffset(0) 94 , m_readOffset(readOffset)
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
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) 207 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp tion colorOptions, size_t maxDecodedBytes, unsigned offset)
208 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) 208 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes)
209 , m_hasColorProfile(false) 209 , m_hasColorProfile(false)
210 , m_offset(offset)
210 { 211 {
211 } 212 }
212 213
213 PNGImageDecoder::~PNGImageDecoder() 214 PNGImageDecoder::~PNGImageDecoder()
214 { 215 {
215 } 216 }
216 217
217 #if USE(QCMSLIB) 218 #if USE(QCMSLIB)
218 static void getColorProfile(png_structp png, png_infop info, ColorProfile& color Profile, bool& sRGB) 219 static void getColorProfile(png_structp png, png_infop info, ColorProfile& color Profile, bool& sRGB)
219 { 220 {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 { 489 {
489 return decoder->frameIsCompleteAtIndex(0); 490 return decoder->frameIsCompleteAtIndex(0);
490 } 491 }
491 492
492 void PNGImageDecoder::decode(bool onlySize) 493 void PNGImageDecoder::decode(bool onlySize)
493 { 494 {
494 if (failed()) 495 if (failed())
495 return; 496 return;
496 497
497 if (!m_reader) 498 if (!m_reader)
498 m_reader = adoptPtr(new PNGImageReader(this)); 499 m_reader = adoptPtr(new PNGImageReader(this, m_offset));
499 500
500 // If we couldn't decode the image but have received all the data, decoding 501 // If we couldn't decode the image but have received all the data, decoding
501 // has failed. 502 // has failed.
502 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 503 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
503 setFailed(); 504 setFailed();
504 505
505 // If decoding is done or failed, we don't need the PNGImageReader anymore. 506 // If decoding is done or failed, we don't need the PNGImageReader anymore.
506 if (isComplete(this) || failed()) 507 if (isComplete(this) || failed())
507 m_reader.clear(); 508 m_reader.clear();
508 } 509 }
509 510
510 } // namespace blink 511 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/image-decoders/png/PNGImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698