diff options
author | Leon Scroggins III <scroggo@google.com> | 2017-04-11 10:32:02 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-11 15:05:05 +0000 |
commit | a4db9be6a28c3a2c24c31e721ac804aec47ad379 (patch) | |
tree | c57209e4f3ce29e137ad228d4ad9c65f0f6e6657 /third_party/gif/SkGifImageReader.h | |
parent | 0f3fdfacf32261f943dcac5cdfd14475011f40db (diff) |
Correct GIF frame dependencies and track alpha
Add SkCodec::FrameInfo::fAlphaType. The SkImageInfo for the SkCodec
specifies the SkAlphaType for the first frame, but the opacity can vary
from frame to frame.
When determining the required frame, also compute whether a frame has
alpha. Update how we determine the required frame, which had bugs.
(Update a test that had an incorrect required frame as a result.)
Add new test images covering cases that have been fixed:
- randPixelsAnim2.gif
It has the following frames:
A (keep)
B (keep) (subset)
C (disposePrevious) (covers B)
D (any) (does *not* cover B)
B and C depend on A, but D depends on B, since after disposing C, B
should be visible again.
- alphabetAnim.gif
Includes frames which fill the image size, with different disposal
methods and transparencies.
Change-Id: Ie086167711c4cac4931ed8c4ddaeb9c9b0b91fdb
Reviewed-on: https://skia-review.googlesource.com/9810
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'third_party/gif/SkGifImageReader.h')
-rw-r--r-- | third_party/gif/SkGifImageReader.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/third_party/gif/SkGifImageReader.h b/third_party/gif/SkGifImageReader.h index 24c917af2a..9d69e48823 100644 --- a/third_party/gif/SkGifImageReader.h +++ b/third_party/gif/SkGifImageReader.h @@ -201,6 +201,7 @@ public: , m_width(0) , m_height(0) , m_transparentPixel(SkGIFColorMap::kNotFound) + , m_hasAlpha(false) , m_disposalMethod(SkCodecAnimation::Keep_DisposalMethod) , m_requiredFrame(kUninitialized) , m_dataSize(0) @@ -240,6 +241,8 @@ public: unsigned height() const { return m_height; } size_t transparentPixel() const { return m_transparentPixel; } void setTransparentPixel(size_t pixel) { m_transparentPixel = pixel; } + bool hasAlpha() const { return m_hasAlpha; } + void setHasAlpha(bool alpha) { m_hasAlpha = alpha; } SkCodecAnimation::DisposalMethod getDisposalMethod() const { return m_disposalMethod; } void setDisposalMethod(SkCodecAnimation::DisposalMethod disposalMethod) { m_disposalMethod = disposalMethod; } @@ -282,6 +285,11 @@ private: unsigned m_width; unsigned m_height; size_t m_transparentPixel; // Index of transparent pixel. Value is kNotFound if there is no transparent pixel. + // Cached value, taking into account: + // - m_transparentPixel + // - frameRect + // - previous required frame + bool m_hasAlpha; SkCodecAnimation::DisposalMethod m_disposalMethod; // Restore to background, leave in place, etc. size_t m_requiredFrame; int m_dataSize; @@ -407,7 +415,7 @@ private: void addFrameIfNecessary(); // Must be called *after* the SkGIFFrameContext's color table (if any) has been parsed. - void setRequiredFrame(SkGIFFrameContext*); + void setAlphaAndRequiredFrame(SkGIFFrameContext*); // This method is sometimes called before creating a SkGIFFrameContext, so it cannot rely // on SkGIFFrameContext::localColorMap(). bool hasTransparentPixel(size_t frameIndex, bool hasLocalColorMap, size_t localMapColors); |