Bug 926048. Part 3. Correctly check if we are at the end of an animated image. r=edwin

mImage->GetNumFrames() is the current number of decoded frames (that the RasterImage knows about), so it only represents the last frame of the animation if we are done decoding.

If we are not fully decoded, and we are on the last decoded frame, just stay on the last decoded frame. When more frames get decoded (or we determine that we are the last frame of the animation) we will advance.

One might expect that if |nextFrameIndex == mImage->GetNumFrames()| then |GetRawFrame(nextFrameIndex)| would return a null surface. But that is not the case because the decoding thread can insert frames into the surface cache that the RasterImage hasn't acknowledged yet (because it has to do so on the main thread, which we are currently running on).

This is why moving animated images to the surface cache is likely the cause of this bug.

This introduces an issue that is explained in, and fixed by the next patch.
This commit is contained in:
Timothy Nikkel 2016-03-01 22:34:40 -06:00
Родитель 4bad8c1f9e
Коммит 9199efb919
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -102,6 +102,13 @@ FrameAnimator::AdvanceFrame(TimeStamp aTime)
// If we're done decoding the next frame, go ahead and display it now and
// reinit with the next frame's delay time.
if (mImage->GetNumFrames() == nextFrameIndex) {
// We can only accurately determine if we are at the end of the loop if we are
// done decoding, otherwise we don't know how many frames there will be.
if (!mDoneDecoding) {
// We've already advanced to the last decoded frame, nothing more we can do.
return ret;
}
// End of an animation loop...
// If we are not looping forever, initialize the loop counter