summaryrefslogtreecommitdiffstats
path: root/image/Decoder.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-11-21 16:28:53 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-11-21 16:28:53 +0100
commita3da925495ab64a3baa69aac4ae35d848a865616 (patch)
treeb91d7275cb8d80b7465425e614c823c06dfca100 /image/Decoder.cpp
parent6a9c2be4eac174c1b44ffb0ff16fd32fca92aa18 (diff)
parent25f4c75d68629a26cbb5433975027cd691a18dd7 (diff)
downloadUXP-a3da925495ab64a3baa69aac4ae35d848a865616.tar
UXP-a3da925495ab64a3baa69aac4ae35d848a865616.tar.gz
UXP-a3da925495ab64a3baa69aac4ae35d848a865616.tar.lz
UXP-a3da925495ab64a3baa69aac4ae35d848a865616.tar.xz
UXP-a3da925495ab64a3baa69aac4ae35d848a865616.zip
Merge branch 'webp-update'
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..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<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(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.