Bug 1462355 - Part 1c. Make individual image decoders to use updated Decoder/SurfacePipe methods.

Extend this change to nsWebPDecoder.cpp
This commit is contained in:
wolfbeast 2018-11-21 13:34:01 +01:00 committed by Roy Tam
commit 7937138cb0
6 changed files with 49 additions and 33 deletions

View file

@ -208,6 +208,25 @@ nsPNGDecoder::CreateFrame(const FrameInfo& aFrameInfo)
MOZ_ASSERT_IF(Size() != OutputSize(),
transparency != TransparencyType::eFrameRect);
Maybe<AnimationParams> animParams;
#ifdef PNG_APNG_SUPPORTED
if (png_get_valid(mPNG, mInfo, PNG_INFO_acTL)) {
mAnimInfo = AnimFrameInfo(mPNG, mInfo);
if (mAnimInfo.mDispose == DisposalMethod::CLEAR) {
// We may have to display the background under this image during
// animation playback, so we regard it as transparent.
PostHasTransparency();
}
animParams.emplace(AnimationParams {
aFrameInfo.mFrameRect,
FrameTimeout::FromRawMilliseconds(mAnimInfo.mTimeout),
mNumFrames, mAnimInfo.mBlend, mAnimInfo.mDispose
});
}
#endif
// If this image is interlaced, we can display better quality intermediate
// results to the user by post processing them with ADAM7InterpolatingFilter.
SurfacePipeFlags pipeFlags = aFrameInfo.mIsInterlaced
@ -220,9 +239,9 @@ nsPNGDecoder::CreateFrame(const FrameInfo& aFrameInfo)
}
Maybe<SurfacePipe> pipe =
SurfacePipeFactory::CreateSurfacePipe(this, mNumFrames, Size(),
OutputSize(), aFrameInfo.mFrameRect,
format, pipeFlags);
SurfacePipeFactory::CreateSurfacePipe(this, Size(), OutputSize(),
aFrameInfo.mFrameRect, format,
animParams, pipeFlags);
if (!pipe) {
mPipe = SurfacePipe();
@ -239,18 +258,6 @@ nsPNGDecoder::CreateFrame(const FrameInfo& aFrameInfo)
"image frame with %dx%d pixels for decoder %p",
mFrameRect.width, mFrameRect.height, this));
#ifdef PNG_APNG_SUPPORTED
if (png_get_valid(mPNG, mInfo, PNG_INFO_acTL)) {
mAnimInfo = AnimFrameInfo(mPNG, mInfo);
if (mAnimInfo.mDispose == DisposalMethod::CLEAR) {
// We may have to display the background under this image during
// animation playback, so we regard it as transparent.
PostHasTransparency();
}
}
#endif
return NS_OK;
}
@ -269,9 +276,7 @@ nsPNGDecoder::EndImageFrame()
opacity = Opacity::FULLY_OPAQUE;
}
PostFrameStop(opacity, mAnimInfo.mDispose,
FrameTimeout::FromRawMilliseconds(mAnimInfo.mTimeout),
mAnimInfo.mBlend, Some(mFrameRect));
PostFrameStop(opacity);
}
nsresult