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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.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 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 7e10d1d10a1a57d2d6724d62ce89a52d1bbad3c1..43736b09c37d33dd9fc6f34bc848d4e08537c173 100644
--- a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp
@@ -79,6 +79,7 @@ BMPImageReader::BMPImageReader(ImageDecoder* parent, size_t decodedAndHeaderOffs
, m_needToProcessColorTable(false)
, m_seenNonZeroAlphaPixel(false)
, m_seenZeroAlphaPixel(false)
+ , m_hasPixelsWithAlpha(false)
, m_isInICO(isInICO)
, m_decodingAndMask(false)
{
@@ -119,10 +120,6 @@ bool BMPImageReader::decodeBMP(bool onlySize)
if (!m_buffer->setSize(m_parent->size().width(), m_parent->size().height()))
return m_parent->setFailed(); // Unable to allocate.
m_buffer->setStatus(ImageFrame::FramePartial);
scroggo_chromium 2016/05/16 20:32:08 Previously, this set the alpha to false for a part
- // 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
- // these 0s could actually show through.
- m_buffer->setHasAlpha(false);
// For BMPs, the frame always fills the entire image.
m_buffer->setOriginalFrameRect(IntRect(IntPoint(), m_parent->size()));
@@ -151,6 +148,7 @@ bool BMPImageReader::decodeBMP(bool onlySize)
return false;
// Done!
+ m_buffer->setHasAlpha(m_hasPixelsWithAlpha);
m_buffer->setStatus(ImageFrame::FrameComplete);
return true;
}
@@ -610,7 +608,7 @@ BMPImageReader::ProcessingResult BMPImageReader::processRLEData()
case 0: // Magic token: EOL
// Skip any remaining pixels in this row.
if (m_coord.x() < m_parent->size().width())
- m_buffer->setHasAlpha(true);
+ m_hasPixelsWithAlpha = true;
moveBufferToNextRow();
m_decodedOffset += 2;
@@ -619,7 +617,7 @@ BMPImageReader::ProcessingResult BMPImageReader::processRLEData()
case 1: // Magic token: EOF
// Skip any remaining pixels in the image.
if ((m_coord.x() < m_parent->size().width()) || (m_isTopDown ? (m_coord.y() < (m_parent->size().height() - 1)) : (m_coord.y() > 0)))
- m_buffer->setHasAlpha(true);
+ m_hasPixelsWithAlpha = true;
// There's no need to move |m_coord| here to trigger the caller
// to call setPixelsChanged(). If the only thing that's changed
// is the alpha state, that will be properly written into the
@@ -637,7 +635,7 @@ BMPImageReader::ProcessingResult BMPImageReader::processRLEData()
const uint8_t dx = readUint8(2);
const uint8_t dy = readUint8(3);
if (dx || dy)
- m_buffer->setHasAlpha(true);
+ m_hasPixelsWithAlpha = true;
if (((m_coord.x() + dx) > m_parent->size().width()) || pastEndOfImage(dy))
return Failure;
@@ -749,7 +747,7 @@ BMPImageReader::ProcessingResult BMPImageReader::processNonRLEData(bool inRLE, i
// web will not be doing a lot of inverting.
if (colorIndex) {
setRGBA(0, 0, 0, 0);
- m_buffer->setHasAlpha(true);
+ m_hasPixelsWithAlpha = true;
} else
m_coord.move(1, 0);
} else {
@@ -785,8 +783,9 @@ BMPImageReader::ProcessingResult BMPImageReader::processNonRLEData(bool inRLE, i
if (m_seenZeroAlphaPixel) {
m_buffer->zeroFillPixelData();
m_seenZeroAlphaPixel = false;
- } else if (alpha != 255)
- m_buffer->setHasAlpha(true);
+ } else if (alpha != 255) {
+ m_hasPixelsWithAlpha = true;
+ }
}
setRGBA(getComponent(pixel, 0), getComponent(pixel, 1),

Powered by Google App Engine
This is Rietveld 408576698