Bug 1438207 - Finalize the current frame of an ICO decoder correctly. r=tnikkel

Originally we attempted to finalize the current frame from the contained
decoder in nsICODecoder::FinishResource. This is wrong because we
haven't acquired the frame from the contained decoder yet. This happens
in nsICODecoder::GetFinalStateFromContainedDecoder, and so
imgFrame::Finalize call should be moved there. This was causing us to
use fallback image sharing with WebRender after a GPU process crash,
instead of shared surfaces, because it can't get a new file handle for
the surface data until we have finished writing all of the image data.
This commit is contained in:
Andrew Osmond 2018-02-16 06:27:36 -05:00
parent 09da568225
commit f6a1a2419b

View File

@ -100,6 +100,13 @@ nsICODecoder::GetFinalStateFromContainedDecoder()
mInvalidRect.UnionRect(mInvalidRect, mContainedDecoder->TakeInvalidRect());
mCurrentFrame = mContainedDecoder->GetCurrentFrameRef();
// Finalize the frame which we deferred to ensure we could modify the final
// result (e.g. to apply the BMP mask).
MOZ_ASSERT(!mContainedDecoder->GetFinalizeFrames());
if (mCurrentFrame) {
mCurrentFrame->FinalizeSurface();
}
// Propagate errors.
nsresult rv = HasError() || mContainedDecoder->HasError()
? NS_ERROR_FAILURE
@ -664,13 +671,6 @@ nsICODecoder::FinishResource()
MOZ_ASSERT_IF(mContainedDecoder->HasSize(),
mContainedDecoder->Size() == mDirEntry->mSize);
// Finalize the frame which we deferred to ensure we could modify the final
// result (e.g. to apply the BMP mask).
MOZ_ASSERT(!mContainedDecoder->GetFinalizeFrames());
if (mCurrentFrame) {
mCurrentFrame->FinalizeSurface();
}
return Transition::TerminateSuccess();
}