void DecodedSurfaceProvider::Run() { MutexAutoLock lock(mMutex); if (!mDecoder || !mImage) { MOZ_ASSERT_UNREACHABLE("Running after decoding finished?"); return; } // Run the decoder. LexerResult result = mDecoder->Decode(WrapNotNull(this)); // If there's a new surface available, announce it to the surface cache. CheckForNewSurface(); if (result.is<TerminalState>()) { FinishDecoding(); return; // We're done. } // Notify for the progress we've made so far. if (mDecoder->HasProgress()) { NotifyProgress(WrapNotNull(mImage), WrapNotNull(mDecoder)); } MOZ_ASSERT(result.is<Yield>()); if (result == LexerResult(Yield::NEED_MORE_DATA)) { // We can't make any more progress right now. The decoder itself will ensure // that we get reenqueued when more data is available; just return for now. return; } // Single-frame images shouldn't yield for any reason except NEED_MORE_DATA. MOZ_ASSERT_UNREACHABLE("Unexpected yield for single-frame image"); mDecoder->TerminateFailure(); FinishDecoding(); }
void AnimationSurfaceProvider::Run() { MutexAutoLock lock(mDecodingMutex); if (!mDecoder || !mImage) { MOZ_ASSERT_UNREACHABLE("Running after decoding finished?"); return; } while (true) { // Run the decoder. LexerResult result = mDecoder->Decode(WrapNotNull(this)); if (result.is<TerminalState>()) { // We may have a new frame now, but it's not guaranteed - a decoding // failure or truncated data may mean that no new frame got produced. // Since we're not sure, rather than call CheckForNewFrameAtYield() here // we call CheckForNewFrameAtTerminalState(), which handles both of these // possibilities. CheckForNewFrameAtTerminalState(); // We're done! FinishDecoding(); return; } // Notify for the progress we've made so far. if (mDecoder->HasProgress()) { NotifyProgress(WrapNotNull(mImage), WrapNotNull(mDecoder)); } if (result == LexerResult(Yield::NEED_MORE_DATA)) { // We can't make any more progress right now. The decoder itself will ensure // that we get reenqueued when more data is available; just return for now. return; } // There's new output available - a new frame! Grab it. MOZ_ASSERT(result == LexerResult(Yield::OUTPUT_AVAILABLE)); CheckForNewFrameAtYield(); } }