mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Previously codec.cc needed all required frames to already be decoded before it could decode any of their dependent frames. To accomplish this it would always cache required frames, regardless of cache limit. However both GIF and WEBP (the only currently supported animated image formats) only allow the image to depend on one decoded frame at a time. This means that there's no reason to cache all the required frames since it's only valid for the image formats to require one previously decoded frame at a time. (For example, frame 10 and frame 11 in a hypothetical animated image could all depend on frame 9. But no subsequent frame after frame 9 could depend on frames 0-8.) Frames are always added to the cache as long as they're under the limit, and never removed. Required frames are always stored as a separate member on `MultiFrameCodec`. Warning: this logic will break if we decide to support more animated formats in the future. Fixes flutter/flutter#24835.