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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp

Issue 2749703002: Refactor ImageFrame::setSizeAndColorSpace() (Closed)
Patch Set: Call setHasAlpha(true); from within zeroFillPixelData() Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp
index a23eca72c8799ea6cd5eec4adbb2d6cc646eccbf..8a849214fc499a71a53c5990f25f06786fd42447 100644
--- a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp
@@ -117,11 +117,12 @@ bool BMPImageReader::decodeBMP(bool onlySize) {
// Initialize the framebuffer if needed.
DCHECK(m_buffer); // Parent should set this before asking us to decode!
if (m_buffer->getStatus() == ImageFrame::FrameEmpty) {
- if (!m_buffer->setSizeAndColorSpace(m_parent->size().width(),
- m_parent->size().height(),
- m_parent->colorSpaceForSkImages())) {
+ if (!m_buffer->allocatePixelData(m_parent->size().width(),
+ m_parent->size().height(),
+ m_parent->colorSpaceForSkImages())) {
return m_parent->setFailed(); // Unable to allocate.
}
+ m_buffer->zeroFillPixelData();
m_buffer->setStatus(ImageFrame::FramePartial);
// setSize() calls eraseARGB(), which resets the alpha flag, so we force
// it back to false here. We'll set it true below in all cases where
@@ -823,6 +824,7 @@ BMPImageReader::ProcessingResult BMPImageReader::processNonRLEData(
m_seenNonZeroAlphaPixel = true;
if (m_seenZeroAlphaPixel) {
m_buffer->zeroFillPixelData();
+ m_buffer->setHasAlpha(false);
m_seenZeroAlphaPixel = false;
} else if (alpha != 255)
m_buffer->setHasAlpha(true);

Powered by Google App Engine
This is Rietveld 408576698