mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-30 19:17:31 +09:00
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:
parent
a08160ac44
commit
7937138cb0
6 changed files with 49 additions and 33 deletions
|
|
@ -674,8 +674,7 @@ nsBMPDecoder::ReadBitfields(const char* aData, size_t aLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(!mImageData, "Already have a buffer allocated?");
|
MOZ_ASSERT(!mImageData, "Already have a buffer allocated?");
|
||||||
nsresult rv = AllocateFrame(/* aFrameNum = */ 0, OutputSize(),
|
nsresult rv = AllocateFrame(OutputSize(), FullOutputFrame(),
|
||||||
FullOutputFrame(),
|
|
||||||
mMayHaveTransparency ? SurfaceFormat::B8G8R8A8
|
mMayHaveTransparency ? SurfaceFormat::B8G8R8A8
|
||||||
: SurfaceFormat::B8G8R8X8);
|
: SurfaceFormat::B8G8R8X8);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,14 @@ nsGIFDecoder2::BeginImageFrame(const IntRect& aFrameRect,
|
||||||
// Make sure there's no animation if we're downscaling.
|
// Make sure there's no animation if we're downscaling.
|
||||||
MOZ_ASSERT_IF(Size() != OutputSize(), !GetImageMetadata().HasAnimation());
|
MOZ_ASSERT_IF(Size() != OutputSize(), !GetImageMetadata().HasAnimation());
|
||||||
|
|
||||||
|
AnimationParams animParams {
|
||||||
|
aFrameRect,
|
||||||
|
FrameTimeout::FromRawMilliseconds(mGIFStruct.delay_time),
|
||||||
|
uint32_t(mGIFStruct.images_decoded),
|
||||||
|
BlendMethod::OVER,
|
||||||
|
DisposalMethod(mGIFStruct.disposal_method)
|
||||||
|
};
|
||||||
|
|
||||||
SurfacePipeFlags pipeFlags = aIsInterlaced
|
SurfacePipeFlags pipeFlags = aIsInterlaced
|
||||||
? SurfacePipeFlags::DEINTERLACE
|
? SurfacePipeFlags::DEINTERLACE
|
||||||
: SurfacePipeFlags();
|
: SurfacePipeFlags();
|
||||||
|
|
@ -198,17 +206,18 @@ nsGIFDecoder2::BeginImageFrame(const IntRect& aFrameRect,
|
||||||
|
|
||||||
// The first frame is always decoded into an RGB surface.
|
// The first frame is always decoded into an RGB surface.
|
||||||
pipe =
|
pipe =
|
||||||
SurfacePipeFactory::CreateSurfacePipe(this, mGIFStruct.images_decoded,
|
SurfacePipeFactory::CreateSurfacePipe(this, Size(), OutputSize(),
|
||||||
Size(), OutputSize(),
|
aFrameRect, format,
|
||||||
aFrameRect, format, pipeFlags);
|
Some(animParams), pipeFlags);
|
||||||
} else {
|
} else {
|
||||||
// This is an animation frame (and not the first). To minimize the memory
|
// This is an animation frame (and not the first). To minimize the memory
|
||||||
// usage of animations, the image data is stored in paletted form.
|
// usage of animations, the image data is stored in paletted form.
|
||||||
MOZ_ASSERT(Size() == OutputSize());
|
MOZ_ASSERT(Size() == OutputSize());
|
||||||
pipe =
|
pipe =
|
||||||
SurfacePipeFactory::CreatePalettedSurfacePipe(this, mGIFStruct.images_decoded,
|
SurfacePipeFactory::CreatePalettedSurfacePipe(this, Size(), aFrameRect,
|
||||||
Size(), aFrameRect, format,
|
format,
|
||||||
aDepth, pipeFlags);
|
aDepth, Some(animParams),
|
||||||
|
pipeFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurrentFrameIndex = mGIFStruct.images_decoded;
|
mCurrentFrameIndex = mGIFStruct.images_decoded;
|
||||||
|
|
@ -249,9 +258,7 @@ nsGIFDecoder2::EndImageFrame()
|
||||||
mGIFStruct.images_decoded++;
|
mGIFStruct.images_decoded++;
|
||||||
|
|
||||||
// Tell the superclass we finished a frame
|
// Tell the superclass we finished a frame
|
||||||
PostFrameStop(opacity,
|
PostFrameStop(opacity);
|
||||||
DisposalMethod(mGIFStruct.disposal_method),
|
|
||||||
FrameTimeout::FromRawMilliseconds(mGIFStruct.delay_time));
|
|
||||||
|
|
||||||
// Reset the transparent pixel
|
// Reset the transparent pixel
|
||||||
if (mOldColor) {
|
if (mOldColor) {
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,9 @@ nsIconDecoder::ReadHeader(const char* aData)
|
||||||
|
|
||||||
MOZ_ASSERT(!mImageData, "Already have a buffer allocated?");
|
MOZ_ASSERT(!mImageData, "Already have a buffer allocated?");
|
||||||
Maybe<SurfacePipe> pipe =
|
Maybe<SurfacePipe> pipe =
|
||||||
SurfacePipeFactory::CreateSurfacePipe(this, 0, Size(), OutputSize(),
|
SurfacePipeFactory::CreateSurfacePipe(this, Size(), OutputSize(),
|
||||||
FullFrame(), SurfaceFormat::B8G8R8A8,
|
FullFrame(), SurfaceFormat::B8G8R8A8,
|
||||||
|
/* aAnimParams */ Nothing(),
|
||||||
SurfacePipeFlags());
|
SurfacePipeFlags());
|
||||||
if (!pipe) {
|
if (!pipe) {
|
||||||
return Transition::TerminateFailure();
|
return Transition::TerminateFailure();
|
||||||
|
|
|
||||||
|
|
@ -388,8 +388,8 @@ nsJPEGDecoder::ReadJPEGData(const char* aData, size_t aLength)
|
||||||
jpeg_has_multiple_scans(&mInfo);
|
jpeg_has_multiple_scans(&mInfo);
|
||||||
|
|
||||||
MOZ_ASSERT(!mImageData, "Already have a buffer allocated?");
|
MOZ_ASSERT(!mImageData, "Already have a buffer allocated?");
|
||||||
nsresult rv = AllocateFrame(/* aFrameNum = */ 0, OutputSize(),
|
nsresult rv = AllocateFrame(OutputSize(), FullOutputFrame(),
|
||||||
FullOutputFrame(), SurfaceFormat::B8G8R8X8);
|
SurfaceFormat::B8G8R8X8);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mState = JPEG_ERROR;
|
mState = JPEG_ERROR;
|
||||||
MOZ_LOG(sJPEGDecoderAccountingLog, LogLevel::Debug,
|
MOZ_LOG(sJPEGDecoderAccountingLog, LogLevel::Debug,
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,25 @@ nsPNGDecoder::CreateFrame(const FrameInfo& aFrameInfo)
|
||||||
MOZ_ASSERT_IF(Size() != OutputSize(),
|
MOZ_ASSERT_IF(Size() != OutputSize(),
|
||||||
transparency != TransparencyType::eFrameRect);
|
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
|
// If this image is interlaced, we can display better quality intermediate
|
||||||
// results to the user by post processing them with ADAM7InterpolatingFilter.
|
// results to the user by post processing them with ADAM7InterpolatingFilter.
|
||||||
SurfacePipeFlags pipeFlags = aFrameInfo.mIsInterlaced
|
SurfacePipeFlags pipeFlags = aFrameInfo.mIsInterlaced
|
||||||
|
|
@ -220,9 +239,9 @@ nsPNGDecoder::CreateFrame(const FrameInfo& aFrameInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<SurfacePipe> pipe =
|
Maybe<SurfacePipe> pipe =
|
||||||
SurfacePipeFactory::CreateSurfacePipe(this, mNumFrames, Size(),
|
SurfacePipeFactory::CreateSurfacePipe(this, Size(), OutputSize(),
|
||||||
OutputSize(), aFrameInfo.mFrameRect,
|
aFrameInfo.mFrameRect, format,
|
||||||
format, pipeFlags);
|
animParams, pipeFlags);
|
||||||
|
|
||||||
if (!pipe) {
|
if (!pipe) {
|
||||||
mPipe = SurfacePipe();
|
mPipe = SurfacePipe();
|
||||||
|
|
@ -239,18 +258,6 @@ nsPNGDecoder::CreateFrame(const FrameInfo& aFrameInfo)
|
||||||
"image frame with %dx%d pixels for decoder %p",
|
"image frame with %dx%d pixels for decoder %p",
|
||||||
mFrameRect.width, mFrameRect.height, this));
|
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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,9 +276,7 @@ nsPNGDecoder::EndImageFrame()
|
||||||
opacity = Opacity::FULLY_OPAQUE;
|
opacity = Opacity::FULLY_OPAQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PostFrameStop(opacity, mAnimInfo.mDispose,
|
PostFrameStop(opacity);
|
||||||
FrameTimeout::FromRawMilliseconds(mAnimInfo.mTimeout),
|
|
||||||
mAnimInfo.mBlend, Some(mFrameRect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
||||||
|
|
@ -234,8 +234,12 @@ nsWebPDecoder::CreateFrame(const nsIntRect& aFrameRect)
|
||||||
|
|
||||||
SurfacePipeFlags pipeFlags = SurfacePipeFlags();
|
SurfacePipeFlags pipeFlags = SurfacePipeFlags();
|
||||||
|
|
||||||
|
AnimationParams animParams {
|
||||||
|
aFrameRect, mTimeout, mCurrentFrame, mBlend, mDisposal
|
||||||
|
};
|
||||||
|
|
||||||
Maybe<SurfacePipe> pipe = SurfacePipeFactory::CreateSurfacePipe(this,
|
Maybe<SurfacePipe> pipe = SurfacePipeFactory::CreateSurfacePipe(this,
|
||||||
mCurrentFrame, Size(), OutputSize(), aFrameRect, mFormat, pipeFlags);
|
Size(), OutputSize(), aFrameRect, mFormat, Some(animParams), pipeFlags);
|
||||||
if (!pipe) {
|
if (!pipe) {
|
||||||
MOZ_LOG(sWebPLog, LogLevel::Error,
|
MOZ_LOG(sWebPLog, LogLevel::Error,
|
||||||
("[this=%p] nsWebPDecoder::CreateFrame -- no pipe\n", this));
|
("[this=%p] nsWebPDecoder::CreateFrame -- no pipe\n", this));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue