diff options
author | scroggo <scroggo@chromium.org> | 2016-10-26 13:48:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-26 13:48:03 -0700 |
commit | 1285f413950910782d5439b5072ccfa14bdf80f7 (patch) | |
tree | f206f8a5097984ba33cf20df74a13009ed31f949 /third_party/gif | |
parent | d187af90c7a3dc945eb91a7d3ade0311d1d111f0 (diff) |
Write transparent pixels more often (SkGifCodec)
Writing transparent pixels is faster than the alternative, and we can
skip clearing the frame to transparent. We'll still clear if the image
is incomplete.
I ran
./out/Release/nanobench --images <images> --samples 100 --sourceType image --simpleCodec -v
over the GIFs we have on our bots, and found an average ~13% speedup.
Raw data is on sheet 2 of
https://docs.google.com/spreadsheets/d/19V-t9BfbFw5eiwBTKA1qOBkZbchjlTC5EIz6HFy-6RI/
(the sheet is named WriteTransparentPixels).
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2436183002
Review-Url: https://codereview.chromium.org/2436183002
Diffstat (limited to 'third_party/gif')
-rw-r--r-- | third_party/gif/SkGifImageReader.cpp | 6 | ||||
-rw-r--r-- | third_party/gif/SkGifImageReader.h | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/third_party/gif/SkGifImageReader.cpp b/third_party/gif/SkGifImageReader.cpp index 228c8ec16e..c40c27203e 100644 --- a/third_party/gif/SkGifImageReader.cpp +++ b/third_party/gif/SkGifImageReader.cpp @@ -146,9 +146,11 @@ bool SkGIFLZWContext::outputRow(const unsigned char* rowBegin) if ((unsigned)drowStart >= m_frameContext->height()) return true; + bool writeTransparentPixels = alwaysWriteTransparentPixels || + (m_frameContext->progressiveDisplay() && m_frameContext->interlaced() && ipass > 1); // CALLBACK: Let the client know we have decoded a row. if (!m_client->haveDecodedRow(m_frameContext->frameId(), rowBegin, - drowStart, drowEnd - drowStart + 1, m_frameContext->progressiveDisplay() && m_frameContext->interlaced() && ipass > 1)) + drowStart, drowEnd - drowStart + 1, writeTransparentPixels)) return false; if (!m_frameContext->interlaced()) @@ -904,6 +906,8 @@ bool SkGIFLZWContext::prepareToDecode() datum = bits = 0; ipass = m_frameContext->interlaced() ? 1 : 0; irow = 0; + alwaysWriteTransparentPixels = !m_frameContext->interlaced() + && m_frameContext->getRequiredFrame() == SkCodec::kNone; // We want to know the longest sequence encodable by a dictionary with // SK_MAX_DICTIONARY_ENTRIES entries. If we ignore the need to encode the base diff --git a/third_party/gif/SkGifImageReader.h b/third_party/gif/SkGifImageReader.h index 45a1ce6dc6..fee1a5f3c7 100644 --- a/third_party/gif/SkGifImageReader.h +++ b/third_party/gif/SkGifImageReader.h @@ -102,6 +102,7 @@ public: , ipass(0) , irow(0) , rowsRemaining(0) + , alwaysWriteTransparentPixels(false) , rowIter(0) , m_client(client) , m_frameContext(frameContext) @@ -125,6 +126,10 @@ private: int ipass; // Interlace pass; Ranges 1-4 if interlaced. size_t irow; // Current output row, starting at zero. size_t rowsRemaining; // Rows remaining to be output. + // This depends on the GIFFrameContext. If the frame is not + // interlaced and it is independent, it is always safe to + // write transparent pixels. + bool alwaysWriteTransparentPixels; unsigned short prefix[SK_MAX_DICTIONARY_ENTRIES]; unsigned char suffix[SK_MAX_DICTIONARY_ENTRIES]; |