Correct GIF frame dependencies and track alpha
authorLeon Scroggins III <scroggo@google.com>
Tue, 11 Apr 2017 14:32:02 +0000 (10:32 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 11 Apr 2017 15:05:05 +0000 (15:05 +0000)
commita4db9be6a28c3a2c24c31e721ac804aec47ad379
treec57209e4f3ce29e137ad228d4ad9c65f0f6e6657
parent0f3fdfacf32261f943dcac5cdfd14475011f40db
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>
include/codec/SkCodec.h
resources/alphabetAnim.gif [new file with mode: 0644]
resources/randPixelsAnim2.gif [new file with mode: 0644]
src/codec/SkGifCodec.cpp
tests/CodecAnimTest.cpp
third_party/gif/SkGifImageReader.cpp
third_party/gif/SkGifImageReader.h