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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
index 5f787b50ea0044779301c303903b7c7591902ef3..008852e71d0898a0807234e843b61f8a276b6386 100644
--- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -163,6 +163,7 @@ private:
PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption colorOptions, size_t maxDecodedBytes, size_t offset)
: ImageDecoder(alphaOption, colorOptions, maxDecodedBytes)
, m_offset(offset)
+ , m_hasPixelsWithAlpha(false)
{
}
@@ -314,7 +315,6 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
}
#endif
buffer.setStatus(ImageFrame::FramePartial);
scroggo_chromium 2016/05/16 20:32:08 Previously, a partially decoded PNG file will repo
- buffer.setHasAlpha(false);
// For PNGs, the frame always fills the entire image.
buffer.setOriginalFrameRect(IntRect(IntPoint(), size()));
@@ -401,8 +401,8 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
}
}
- if (alphaMask != 255 && !buffer.hasAlpha())
- buffer.setHasAlpha(true);
+ if (alphaMask != 255 && !m_hasPixelsWithAlpha)
+ m_hasPixelsWithAlpha = true;
buffer.setPixelsChanged(true);
}
@@ -412,21 +412,18 @@ void PNGImageDecoder::complete()
if (m_frameBufferCache.isEmpty())
return;
+ m_frameBufferCache[0].setHasAlpha(m_hasPixelsWithAlpha);
m_frameBufferCache[0].setStatus(ImageFrame::FrameComplete);
}
-inline bool isComplete(const PNGImageDecoder* decoder)
-{
- return decoder->frameIsCompleteAtIndex(0);
-}
-
void PNGImageDecoder::decode(bool onlySize)
{
if (failed())
return;
- if (!m_reader)
+ if (!m_reader) {
scroggo_chromium 2016/05/16 20:32:08 This change is unnecessary.
aleksandar.stojiljkovic 2016/05/22 15:41:53 Done.
m_reader = adoptPtr(new PNGImageReader(this, m_offset));
+ }
// If we couldn't decode the image but have received all the data, decoding
// has failed.
@@ -434,7 +431,7 @@ void PNGImageDecoder::decode(bool onlySize)
setFailed();
// If decoding is done or failed, we don't need the PNGImageReader anymore.
- if (isComplete(this) || failed())
+ if (frameIsCompleteAtIndex(0) || failed())
m_reader.clear();
}

Powered by Google App Engine
This is Rietveld 408576698