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

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

Issue 1962563002: Fix ImageDecoder::frameIsCompleteAtIndex - fully received instead of decoded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BMPDecoder + remove partial Created 4 years, 7 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
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 bool m_hasAlpha; 156 bool m_hasAlpha;
157 OwnPtr<png_byte[]> m_interlaceBuffer; 157 OwnPtr<png_byte[]> m_interlaceBuffer;
158 #if USE(QCMSLIB) 158 #if USE(QCMSLIB)
159 OwnPtr<png_byte[]> m_rowBuffer; 159 OwnPtr<png_byte[]> m_rowBuffer;
160 #endif 160 #endif
161 }; 161 };
162 162
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 , m_hasPixelsWithAlpha(false)
166 { 167 {
167 } 168 }
168 169
169 PNGImageDecoder::~PNGImageDecoder() 170 PNGImageDecoder::~PNGImageDecoder()
170 { 171 {
171 } 172 }
172 173
173 void PNGImageDecoder::headerAvailable() 174 void PNGImageDecoder::headerAvailable()
174 { 175 {
175 png_structp png = m_reader->pngPtr(); 176 png_structp png = m_reader->pngPtr();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 307
307 #if USE(QCMSLIB) 308 #if USE(QCMSLIB)
308 if (colorTransform()) { 309 if (colorTransform()) {
309 m_reader->createRowBuffer(colorChannels * size().width()); 310 m_reader->createRowBuffer(colorChannels * size().width());
310 if (!m_reader->rowBuffer()) { 311 if (!m_reader->rowBuffer()) {
311 longjmp(JMPBUF(png), 1); 312 longjmp(JMPBUF(png), 1);
312 return; 313 return;
313 } 314 }
314 } 315 }
315 #endif 316 #endif
316 buffer.setStatus(ImageFrame::FramePartial); 317 buffer.setStatus(ImageFrame::FramePartial);
scroggo_chromium 2016/05/16 20:32:08 Previously, a partially decoded PNG file will repo
317 buffer.setHasAlpha(false);
318 318
319 // For PNGs, the frame always fills the entire image. 319 // For PNGs, the frame always fills the entire image.
320 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); 320 buffer.setOriginalFrameRect(IntRect(IntPoint(), size()));
321 } 321 }
322 322
323 /* libpng comments (here to explain what follows). 323 /* libpng comments (here to explain what follows).
324 * 324 *
325 * this function is called for every row in the image. If the 325 * this function is called for every row in the image. If the
326 * image is interlacing, and you turned on the interlace handler, 326 * image is interlacing, and you turned on the interlace handler,
327 * this function will be called for every row in every pass. 327 * this function will be called for every row in every pass.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 buffer.setRGBARaw(address++, pixel[0], pixel[1], pixel[2], pixel [3]); 394 buffer.setRGBARaw(address++, pixel[0], pixel[1], pixel[2], pixel [3]);
395 alphaMask &= pixel[3]; 395 alphaMask &= pixel[3];
396 } 396 }
397 } 397 }
398 } else { 398 } else {
399 for (int x = 0; x < width; ++x, pixel += 3) { 399 for (int x = 0; x < width; ++x, pixel += 3) {
400 buffer.setRGBARaw(address++, pixel[0], pixel[1], pixel[2], 255); 400 buffer.setRGBARaw(address++, pixel[0], pixel[1], pixel[2], 255);
401 } 401 }
402 } 402 }
403 403
404 if (alphaMask != 255 && !buffer.hasAlpha()) 404 if (alphaMask != 255 && !m_hasPixelsWithAlpha)
405 buffer.setHasAlpha(true); 405 m_hasPixelsWithAlpha = true;
406 406
407 buffer.setPixelsChanged(true); 407 buffer.setPixelsChanged(true);
408 } 408 }
409 409
410 void PNGImageDecoder::complete() 410 void PNGImageDecoder::complete()
411 { 411 {
412 if (m_frameBufferCache.isEmpty()) 412 if (m_frameBufferCache.isEmpty())
413 return; 413 return;
414 414
415 m_frameBufferCache[0].setHasAlpha(m_hasPixelsWithAlpha);
415 m_frameBufferCache[0].setStatus(ImageFrame::FrameComplete); 416 m_frameBufferCache[0].setStatus(ImageFrame::FrameComplete);
416 } 417 }
417 418
418 inline bool isComplete(const PNGImageDecoder* decoder)
419 {
420 return decoder->frameIsCompleteAtIndex(0);
421 }
422
423 void PNGImageDecoder::decode(bool onlySize) 419 void PNGImageDecoder::decode(bool onlySize)
424 { 420 {
425 if (failed()) 421 if (failed())
426 return; 422 return;
427 423
428 if (!m_reader) 424 if (!m_reader) {
scroggo_chromium 2016/05/16 20:32:08 This change is unnecessary.
aleksandar.stojiljkovic 2016/05/22 15:41:53 Done.
429 m_reader = adoptPtr(new PNGImageReader(this, m_offset)); 425 m_reader = adoptPtr(new PNGImageReader(this, m_offset));
426 }
430 427
431 // If we couldn't decode the image but have received all the data, decoding 428 // If we couldn't decode the image but have received all the data, decoding
432 // has failed. 429 // has failed.
433 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 430 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
434 setFailed(); 431 setFailed();
435 432
436 // If decoding is done or failed, we don't need the PNGImageReader anymore. 433 // If decoding is done or failed, we don't need the PNGImageReader anymore.
437 if (isComplete(this) || failed()) 434 if (frameIsCompleteAtIndex(0) || failed())
438 m_reader.clear(); 435 m_reader.clear();
439 } 436 }
440 437
441 } // namespace blink 438 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698