aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/gif
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2016-11-03 14:52:28 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-03 19:25:39 +0000
commit4ef986db65027f53999174279252092ba9b03c9e (patch)
tree03b86da82b058053fe0ea99fd85f343815a96205 /third_party/gif
parentf0348c2413c5c72820a42749879d41c6dd4ab16c (diff)
Write transparent pixels more often in SkGifImageReader
This stems from a behavior difference between Skia and Chrome. In Skia, we want to write transparent pixels as often as possible. (It's faster than checking if we should skip each pixel.) In Chrome, they avoid writing transparent pixels unless absolutely necessary. We were cautious about changing behavior when this first landed, but this is easier to think about in a smaller change (right now). (1) We can always write transparent pixels when we are writing an independent frame. (2) There is no need for the progressiveDisplay() check. We only ever use progressive display methods on the first frame - and the first frame is always independent. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4379 Change-Id: I82048a08e2003aac216f483c7db8df997b687149 Reviewed-on: https://skia-review.googlesource.com/4379 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'third_party/gif')
-rw-r--r--third_party/gif/SkGifImageReader.cpp32
-rw-r--r--third_party/gif/SkGifImageReader.h5
2 files changed, 1 insertions, 36 deletions
diff --git a/third_party/gif/SkGifImageReader.cpp b/third_party/gif/SkGifImageReader.cpp
index 0ffc7ca72a..59e3d6969c 100644
--- a/third_party/gif/SkGifImageReader.cpp
+++ b/third_party/gif/SkGifImageReader.cpp
@@ -146,9 +146,8 @@ 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.
+ const bool writeTransparentPixels = (SkCodec::kNone == m_frameContext->getRequiredFrame());
if (!m_client->haveDecodedRow(m_frameContext->frameId(), rowBegin,
drowStart, drowEnd - drowStart + 1, writeTransparentPixels))
return false;
@@ -918,35 +917,6 @@ bool SkGIFLZWContext::prepareToDecode(const SkGIFColorMap& globalMap)
datum = bits = 0;
ipass = m_frameContext->interlaced() ? 1 : 0;
irow = 0;
- alwaysWriteTransparentPixels = false;
- if (m_frameContext->getRequiredFrame() == SkCodec::kNone) {
- if (!m_frameContext->interlaced()) {
- alwaysWriteTransparentPixels = true;
- } else {
- // The frame is interlaced, so we do not want to write transparent
- // pixels. But if there are no transparent pixels anyway, there is
- // no harm in taking the alwaysWriteTransparentPixels path, which
- // is faster, and it also supports 565.
- // Since the frame is independent, it does not matter whether the
- // frame is subset (nothing behind it needs to show through). So we
- // only need to know whether there is a valid transparent pixel.
- // This is a little counterintuitive - we want to "always write
- // transparent pixels" if there ARE NO transparent pixels, so we
- // check to see whether the pixel index is >= numColors.
- const auto& localMap = m_frameContext->localColorMap();
- const auto trans = m_frameContext->transparentPixel();
- if (localMap.isDefined()) {
- alwaysWriteTransparentPixels = trans >= localMap.numColors();
- } else {
- // Note that if the map is not defined, the value of
- // alwaysWriteTransparentPixels is meaningless, since without
- // any color table, we will skip drawing entirely.
- // FIXME: We could even skip calling prepareToDecode in that
- // case, meaning we can SkASSERT(globalMap.isDefined())
- alwaysWriteTransparentPixels = trans >= globalMap.numColors();
- }
- }
- }
// 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 2b1b2d9423..67868ae4d7 100644
--- a/third_party/gif/SkGifImageReader.h
+++ b/third_party/gif/SkGifImageReader.h
@@ -103,7 +103,6 @@ public:
, ipass(0)
, irow(0)
, rowsRemaining(0)
- , alwaysWriteTransparentPixels(false)
, rowIter(0)
, m_client(client)
, m_frameContext(frameContext)
@@ -127,10 +126,6 @@ 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];