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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp

Issue 2044093002: Blink image-decoders: (lazy) deferred image decoding support for ICO (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Count only completelly received frames. Fixes Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
index a189f8104505aafd491d1a17707f087b3fb92063..4f2aaf6851283d89937a8b06a425fbdcfaad2a77 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
@@ -83,6 +83,14 @@ bool ICOImageDecoder::setSize(unsigned width, unsigned height)
return m_frameSize.isEmpty() ? ImageDecoder::setSize(width, height) : ((IntSize(width, height) == m_frameSize) || setFailed());
}
+bool ICOImageDecoder::frameIsCompleteAtIndex(size_t index) const
+{
+ if (index >= m_dirEntries.size())
+ return false;
+ const IconDirectoryEntry& dirEntry = m_dirEntries[index];
+ return (dirEntry.m_imageOffset + dirEntry.m_byteSize) <= m_data->size();
+}
+
bool ICOImageDecoder::setFailed()
{
m_bmpReaders.clear();
@@ -107,7 +115,6 @@ bool ICOImageDecoder::hotSpotAtIndex(size_t index, IntPoint& hotSpot) const
return true;
}
-
Peter Kasting 2016/06/08 23:16:13 Nit: Don't remove this
aleksandar.stojiljkovic 2016/06/09 20:34:07 Done.
// static
bool ICOImageDecoder::compareEntries(const IconDirectoryEntry& a, const IconDirectoryEntry& b)
{
@@ -120,6 +127,13 @@ bool ICOImageDecoder::compareEntries(const IconDirectoryEntry& a, const IconDire
size_t ICOImageDecoder::decodeFrameCount()
{
decodeSize();
+
+ // Length of sequence of completely received frames.
+ for (size_t i = 0; i < m_dirEntries.size(); ++i) {
+ const IconDirectoryEntry& dirEntry = m_dirEntries[i];
+ if ((dirEntry.m_imageOffset + dirEntry.m_byteSize) > m_data->size())
+ return i;
+ }
return m_dirEntries.size();
}
@@ -173,13 +187,12 @@ bool ICOImageDecoder::decodeAtIndex(size_t index)
if (imageType == BMP) {
if (!m_bmpReaders[index]) {
- // We need to have already sized m_frameBufferCache before this, and
- // we must not resize it again later (see caution in frameCount()).
- ASSERT(m_frameBufferCache.size() == m_dirEntries.size());
m_bmpReaders[index] = adoptPtr(new BMPImageReader(this, dirEntry.m_imageOffset, 0, true));
m_bmpReaders[index]->setData(m_data.get());
- m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]);
}
+ // Update the pointer to the buffer as it could change after
+ // m_frameBufferCache.resize().
+ m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]);
m_frameSize = dirEntry.m_size;
bool result = m_bmpReaders[index]->decodeBMP(false);
m_frameSize = IntSize();
@@ -273,6 +286,7 @@ ICOImageDecoder::IconDirectoryEntry ICOImageDecoder::readDirectoryEntry()
entry.m_bitCount = readUint16(6);
entry.m_hotSpot = IntPoint();
}
+ entry.m_byteSize = readUint32(8);
entry.m_imageOffset = readUint32(12);
// Some icons don't have a bit depth, only a color count. Convert the

Powered by Google App Engine
This is Rietveld 408576698