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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp

Issue 1460523002: GIF decoding to Index8, unit tests and misusing unit test as benchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment #25 processed. Created 4 years, 11 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/gif/GIFImageReader.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp
index 4c6631dfe2b4ea139902f443fdf716cde83a9c68..707381c03fd8a04ea1b70aad9aa6865336f1f0bc 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp
@@ -145,9 +145,8 @@ bool GIFLZWContext::outputRow(GIFRow::const_iterator rowBegin)
return true;
// CALLBACK: Let the client know we have decoded a row.
- if (!m_client->haveDecodedRow(m_frameContext->frameId(), rowBegin, m_frameContext->width(),
- drowStart, drowEnd - drowStart + 1, m_frameContext->progressiveDisplay() && m_frameContext->interlaced() && ipass > 1))
- return false;
+ m_client->haveDecodedRow(*m_frameContext, rowBegin,
+ drowStart, drowEnd - drowStart + 1, m_frameContext->progressiveDisplay() && m_frameContext->interlaced() && ipass > 1);
if (!m_frameContext->interlaced())
irow++;
@@ -283,18 +282,19 @@ bool GIFLZWContext::doLZW(const unsigned char* block, size_t bytesInBlock)
// Output as many rows as possible.
GIFRow::iterator rowBegin = rowBuffer.begin();
- for (; rowBegin + width <= rowIter; rowBegin += width) {
- if (!outputRow(rowBegin))
- return false;
- rowsRemaining--;
- if (!rowsRemaining)
- return true;
- }
+ if (rowBegin + width <= rowIter) {
scroggo_chromium 2016/04/29 19:48:15 These changes (i.e. this if block) might be better
+ for (; rowBegin + width <= rowIter; rowBegin += width) {
+ if (!outputRow(rowBegin))
+ return false;
+ rowsRemaining--;
+ if (!rowsRemaining)
+ return true;
+ }
- if (rowBegin != rowBuffer.begin()) {
// Move the remaining bytes to the beginning of the buffer.
const size_t bytesToCopy = rowIter - rowBegin;
- memcpy(rowBuffer.begin(), rowBegin, bytesToCopy);
+ if (bytesToCopy)
+ memcpy(rowBuffer.begin(), rowBegin, bytesToCopy);
rowIter = rowBuffer.begin() + bytesToCopy;
}
}
@@ -342,6 +342,11 @@ bool GIFFrameContext::decode(blink::FastSharedBufferReader* reader, blink::GIFIm
m_currentLzwBlock = 0;
}
+ if (m_lzwContext->hasRemainingRows()) {
+ if (!client->initFrameBuffer(m_frameId))
scroggo_chromium 2016/04/29 19:48:15 Why is this needed now?
+ return false;
+ }
+
// Some bad GIFs have extra blocks beyond the last row, which we don't want to decode.
while (m_currentLzwBlock < m_lzwBlocks.size() && m_lzwContext->hasRemainingRows()) {
size_t blockPosition = m_lzwBlocks[m_currentLzwBlock].blockPosition;
@@ -453,7 +458,7 @@ bool GIFImageReader::parseData(size_t dataPosition, size_t len, GIFImageDecoder:
case GIFGlobalHeader: {
const unsigned char* currentComponent =
reinterpret_cast<const unsigned char*>(
- reader.getConsecutiveData(currentComponentPosition, 5, readBuffer));
+ reader.getConsecutiveData(currentComponentPosition, 6, readBuffer));
// This is the height and width of the "screen" or frame into which
// images are rendered. The individual images can be smaller than
@@ -465,6 +470,7 @@ bool GIFImageReader::parseData(size_t dataPosition, size_t len, GIFImageDecoder:
m_screenHeight = GETINT16(currentComponent + 2);
const size_t globalColorMapColors = 2 << (currentComponent[4] & 0x07);
+ m_backgroundIndex = currentComponent[5];
scroggo_chromium 2016/04/29 19:48:15 It looks like we never looked at this color before
if ((currentComponent[4] & 0x80) && globalColorMapColors > 0) { /* global map */
m_globalColorMap.setTablePositionAndSize(dataPosition, globalColorMapColors);

Powered by Google App Engine
This is Rietveld 408576698