diff options
author | Leon Scroggins III <scroggo@google.com> | 2017-07-18 16:22:52 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-19 14:43:26 +0000 |
commit | e726e7ca0c99c75f447e6c22b7d341ce921c4e50 (patch) | |
tree | 209aa6a36236ab395c38810f1378c50e8a260b29 /src/codec/SkGifCodec.cpp | |
parent | d81977f51b865de191a859309055b8992f25698b (diff) |
Report first GIF frame after knowing its meta data
Previously, we reported the first image as soon as it was available. As
a result, in crrev.com/2565323003, InitializeNewFrame might be called
before the metadata is known, meaning it would read the wrong metadata.
Instead of looking at the imagesCount(), SkGifCodec::NewFromStream looks
at frameContext(0), which may still exist even if it's not yet counted
in imagesCount().
Add a test that confirms the desired behavior.
Change-Id: Ib392721ecd2218ba0fcd35aaa64117c0ba3e4ea6
Reviewed-on: https://skia-review.googlesource.com/24405
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec/SkGifCodec.cpp')
-rw-r--r-- | src/codec/SkGifCodec.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp index 9b3d4b5ed5..7b31a618ea 100644 --- a/src/codec/SkGifCodec.cpp +++ b/src/codec/SkGifCodec.cpp @@ -76,7 +76,8 @@ SkCodec* SkGifCodec::NewFromStream(SkStream* stream, Result* result) { // If no images are in the data, or the first header is not yet defined, we cannot // create a codec. In either case, the width and height are not yet known. - if (0 == reader->imagesCount() || !reader->frameContext(0)->isHeaderDefined()) { + auto* frame = reader->frameContext(0); + if (!frame || !frame->isHeaderDefined()) { *result = kInvalidInput; return nullptr; } @@ -136,9 +137,7 @@ bool SkGifCodec::onGetFrameInfo(int i, SkCodec::FrameInfo* frameInfo) const { } const SkGIFFrameContext* frameContext = fReader->frameContext(i); - if (!frameContext->reachedStartOfData()) { - return false; - } + SkASSERT(frameContext->reachedStartOfData()); if (frameInfo) { frameInfo->fDuration = frameContext->getDuration(); |