summaryrefslogtreecommitdiffstats
path: root/image/Decoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'image/Decoder.cpp')
-rw-r--r--image/Decoder.cpp49
1 files changed, 22 insertions, 27 deletions
diff --git a/image/Decoder.cpp b/image/Decoder.cpp
index f9b1034cf..5ff8c72b5 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<AnimationParams>& 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_IF(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<AnimationParams>& 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<RefPtr<imgFrame>> 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<nsIntRect>& 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.