From 622098073e132995994fac4d61e3629d08ee1801 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 21 Nov 2018 12:57:17 +0100 Subject: Bug 1462355 - Part 1b. Update Decoder and SurfacePipe plumbing to use updated imgFrame methods. --- image/Decoder.cpp | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'image/Decoder.cpp') diff --git a/image/Decoder.cpp b/image/Decoder.cpp index f9b1034cf..a6fd67c3f 100644 --- a/image/Decoder.cpp +++ b/image/Decoder.cpp @@ -278,14 +278,14 @@ Decoder::Telemetry() const } nsresult -Decoder::AllocateFrame(uint32_t aFrameNum, - const gfx::IntSize& aOutputSize, +Decoder::AllocateFrame(const gfx::IntSize& aOutputSize, const gfx::IntRect& aFrameRect, gfx::SurfaceFormat aFormat, - uint8_t aPaletteDepth) + uint8_t aPaletteDepth, + const Maybe& aAnimParams) { - mCurrentFrame = AllocateFrameInternal(aFrameNum, aOutputSize, aFrameRect, - aFormat, aPaletteDepth, + mCurrentFrame = AllocateFrameInternal(aOutputSize, aFrameRect, aFormat, + aPaletteDepth, aAnimParams, mCurrentFrame.get()); if (mCurrentFrame) { @@ -295,7 +295,7 @@ Decoder::AllocateFrame(uint32_t aFrameNum, // We should now be on |aFrameNum|. (Note that we're comparing the frame // number, which is zero-based, with the frame count, which is one-based.) - MOZ_ASSERT(aFrameNum + 1 == mFrameCount); + MOZ_ASSERT(aAnimParams, aAnimParams->mFrameNum + 1 == mFrameCount); // If we're past the first frame, PostIsAnimated() should've been called. MOZ_ASSERT_IF(mFrameCount > 1, HasAnimation()); @@ -309,18 +309,19 @@ Decoder::AllocateFrame(uint32_t aFrameNum, } RawAccessFrameRef -Decoder::AllocateFrameInternal(uint32_t aFrameNum, - const gfx::IntSize& aOutputSize, +Decoder::AllocateFrameInternal(const gfx::IntSize& aOutputSize, const gfx::IntRect& aFrameRect, SurfaceFormat aFormat, uint8_t aPaletteDepth, + const Maybe& aAnimParams, imgFrame* aPreviousFrame) { if (HasError()) { return RawAccessFrameRef(); } - if (aFrameNum != mFrameCount) { + uint32_t frameNum = aAnimParams ? aAnimParams->mFrameNum : 0; + if (frameNum != mFrameCount) { MOZ_ASSERT_UNREACHABLE("Allocating frames out of order"); return RawAccessFrameRef(); } @@ -334,7 +335,8 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum, NotNull> frame = WrapNotNull(new imgFrame()); bool nonPremult = bool(mSurfaceFlags & SurfaceFlags::NO_PREMULTIPLY_ALPHA); if (NS_FAILED(frame->InitForDecoder(aOutputSize, aFrameRect, aFormat, - aPaletteDepth, nonPremult))) { + aPaletteDepth, nonPremult, + aAnimParams))) { NS_WARNING("imgFrame::Init should succeed"); return RawAccessFrameRef(); } @@ -345,22 +347,22 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum, return RawAccessFrameRef(); } - if (aFrameNum == 1) { + if (frameNum == 1) { MOZ_ASSERT(aPreviousFrame, "Must provide a previous frame when animated"); aPreviousFrame->SetRawAccessOnly(); // If we dispose of the first frame by clearing it, then the first frame's // refresh area is all of itself. // RESTORE_PREVIOUS is invalid (assumed to be DISPOSE_CLEAR). - AnimationData previousFrameData = aPreviousFrame->GetAnimationData(); - if (previousFrameData.mDisposalMethod == DisposalMethod::CLEAR || - previousFrameData.mDisposalMethod == DisposalMethod::CLEAR_ALL || - previousFrameData.mDisposalMethod == DisposalMethod::RESTORE_PREVIOUS) { - mFirstFrameRefreshArea = previousFrameData.mRect; + DisposalMethod prevDisposal = aPreviousFrame->GetDisposalMethod(); + if (prevDisposal == DisposalMethod::CLEAR || + prevDisposal == DisposalMethod::CLEAR_ALL || + prevDisposal == DisposalMethod::RESTORE_PREVIOUS) { + mFirstFrameRefreshArea = aPreviousFrame->GetRect(); } } - if (aFrameNum > 0) { + if (frameNum > 0) { ref->SetRawAccessOnly(); // Some GIFs are huge but only have a small area that they animate. We only @@ -432,13 +434,7 @@ Decoder::PostIsAnimated(FrameTimeout aFirstFrameTimeout) } void -Decoder::PostFrameStop(Opacity aFrameOpacity - /* = Opacity::SOME_TRANSPARENCY */, - DisposalMethod aDisposalMethod - /* = DisposalMethod::KEEP */, - FrameTimeout aTimeout /* = FrameTimeout::Forever() */, - BlendMethod aBlendMethod /* = BlendMethod::OVER */, - const Maybe& aBlendRect /* = Nothing() */) +Decoder::PostFrameStop(Opacity aFrameOpacity) { // We should be mid-frame MOZ_ASSERT(!IsMetadataDecode(), "Stopping frame during metadata decode"); @@ -449,12 +445,11 @@ Decoder::PostFrameStop(Opacity aFrameOpacity mInFrame = false; mFinishedNewFrame = true; - mCurrentFrame->Finish(aFrameOpacity, aDisposalMethod, aTimeout, - aBlendMethod, aBlendRect); + mCurrentFrame->Finish(aFrameOpacity); mProgress |= FLAG_FRAME_COMPLETE; - mLoopLength += aTimeout; + mLoopLength += mCurrentFrame->GetTimeout(); // If we're not sending partial invalidations, then we send an invalidation // here when the first frame is complete. -- cgit v1.2.3