Reset SkWuffsCodec frame-count decoder less often

Previously, every call to SkWuffsCodec::onGetFrameCountInternal would
reset the decoder, as it might have been suspended in a co-routine.
Resetting also meant re-winding the input stream back to the first byte
of source data, to re-parse the image configuration (not just a
per-frame configuration), since e.g. the overall image bounds can affect
(clip) a frame's bounds.

Now that there are two separate decoders (one for pixel data and one
just for the frame-count), the only co-routine that the frame-count
decoder could be suspended in is the call to decode the next frame
configuration. There is no longer a need to (conditionally) reset the
frame-count decoder; we can just resume that co-routine (provided that
the fIOBuffer is positioned where it left off).

After this commit, the Wuffs decoder should use a little less CPU and
I/O when having getFrameCount called multiple times, interleaved with
incrementally decoding an animation.

Bug: skia:8235
Change-Id: I871ead40ed0acd6d101cf12784ee5da45e7de5aa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254356
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
1 file changed