From e726e7ca0c99c75f447e6c22b7d341ce921c4e50 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Tue, 18 Jul 2017 16:22:52 -0400 Subject: 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 Commit-Queue: Leon Scroggins --- third_party/gif/SkGifImageReader.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'third_party/gif') diff --git a/third_party/gif/SkGifImageReader.h b/third_party/gif/SkGifImageReader.h index 0b89b04818..0ba767ee89 100644 --- a/third_party/gif/SkGifImageReader.h +++ b/third_party/gif/SkGifImageReader.h @@ -321,11 +321,9 @@ public: int imagesCount() const { - // Report the first frame immediately, so the parser can stop when it - // sees the size on a SizeQuery. const size_t frames = m_frames.size(); - if (frames <= 1) { - return static_cast(frames); + if (!frames) { + return 0; } // This avoids counting an empty frame when the file is truncated (or -- cgit v1.2.3