Bug 523950 - Part 5. Pass the currently displayed frame of an animation to its decoder. r=tnikkel

When we need to recreate an animated image decoder because it was
discarded, the animation may have progressed beyond the first frame.
Given that later in the patch series we need FrameAnimator to be driving
the decoding more actively, it simplifies its role by making it assume
the initial state of the decoder matches its initial state. Passing in
the currently displayed frame allows the decoder to advance its frame
buffer (and potentially discard unnecessary frames), such that when the
animation actually wants to advance as it normally would, the decoder
state matches what it would have been if it had never been discarded.
This commit is contained in:
Andrew Osmond
2018-02-28 13:34:52 -05:00
parent 2eb54b3cae
commit d78c35476d
4 changed files with 8 additions and 3 deletions

View File

@@ -175,6 +175,7 @@ DecoderFactory::CreateAnimationDecoder(DecoderType aType,
const IntSize& aIntrinsicSize,
DecoderFlags aDecoderFlags,
SurfaceFlags aSurfaceFlags,
size_t aCurrentFrame,
IDecodingTask** aOutTask)
{
if (aType == DecoderType::UNKNOWN) {
@@ -205,7 +206,7 @@ DecoderFactory::CreateAnimationDecoder(DecoderType aType,
SurfaceKey surfaceKey =
RasterSurfaceKey(aIntrinsicSize, aSurfaceFlags, PlaybackType::eAnimated);
auto provider = MakeNotNull<RefPtr<AnimationSurfaceProvider>>(
aImage, surfaceKey, WrapNotNull(decoder));
aImage, surfaceKey, WrapNotNull(decoder), aCurrentFrame);
// Attempt to insert the surface provider into the surface cache right away so
// we won't trigger any more decoders with the same parameters.