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

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

Issue 15466004: Make image decoders faster by refactoring hot loops that fills the lines of ImageFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make image decoders faster by refactoring hot loops that fills the lines of ImageFrame. Created 7 years, 6 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 481 }
482 482
483 #if USE(QCMSLIB) 483 #if USE(QCMSLIB)
484 if (qcms_transform* transform = m_reader->colorTransform()) { 484 if (qcms_transform* transform = m_reader->colorTransform()) {
485 qcms_transform_data(transform, row, m_reader->rowBuffer(), size().width( )); 485 qcms_transform_data(transform, row, m_reader->rowBuffer(), size().width( ));
486 row = m_reader->rowBuffer(); 486 row = m_reader->rowBuffer();
487 } 487 }
488 #endif 488 #endif
489 489
490 // Write the decoded row pixels to the frame buffer. 490 // Write the decoded row pixels to the frame buffer.
491 ImageFrame::PixelData* address = buffer.getAddr(0, y);
492 bool nonTrivialAlpha = false; 491 bool nonTrivialAlpha = false;
493 int width = size().width(); 492 if (hasAlpha)
494 493 buffer.fillRowFromRGBASourceWithNonTrivialAlphaDetection(y, row, nonTriv ialAlpha);
495 png_bytep pixel = row; 494 else
496 for (int x = 0; x < width; ++x, pixel += colorChannels) { 495 buffer.fillRowFromRGBSource(y, row);
497 unsigned alpha = hasAlpha ? pixel[3] : 255;
498 buffer.setRGBA(address++, pixel[0], pixel[1], pixel[2], alpha);
499 nonTrivialAlpha |= alpha < 255;
500 }
501 496
502 if (nonTrivialAlpha && !buffer.hasAlpha()) 497 if (nonTrivialAlpha && !buffer.hasAlpha())
503 buffer.setHasAlpha(nonTrivialAlpha); 498 buffer.setHasAlpha(nonTrivialAlpha);
504 } 499 }
505 500
506 void PNGImageDecoder::pngComplete() 501 void PNGImageDecoder::pngComplete()
507 { 502 {
508 if (!m_frameBufferCache.isEmpty()) 503 if (!m_frameBufferCache.isEmpty())
509 m_frameBufferCache.first().setStatus(ImageFrame::FrameComplete); 504 m_frameBufferCache.first().setStatus(ImageFrame::FrameComplete);
510 } 505 }
(...skipping 10 matching lines...) Expand all
521 // has failed. 516 // has failed.
522 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 517 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
523 setFailed(); 518 setFailed();
524 // If we're done decoding the image, we don't need the PNGImageReader 519 // If we're done decoding the image, we don't need the PNGImageReader
525 // anymore. (If we failed, |m_reader| has already been cleared.) 520 // anymore. (If we failed, |m_reader| has already been cleared.)
526 else if (isComplete()) 521 else if (isComplete())
527 m_reader.clear(); 522 m_reader.clear();
528 } 523 }
529 524
530 } // namespace WebCore 525 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698