Bug 1462355 - Part 1b. Update Decoder and SurfacePipe plumbing to use updated imgFrame methods.

This commit is contained in:
wolfbeast 2018-11-21 12:57:17 +01:00 • committed by Roy Tam
commit a08160ac44
15 changed files with 84 additions and 92 deletions

View file

@ -278,14 +278,14 @@ Decoder::Telemetry() const
} }
nsresult nsresult
Decoder::AllocateFrame(uint32_t aFrameNum, Decoder::AllocateFrame(const gfx::IntSize& aOutputSize,
const gfx::IntSize& aOutputSize,
const gfx::IntRect& aFrameRect, const gfx::IntRect& aFrameRect,
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
uint8_t aPaletteDepth) uint8_t aPaletteDepth,
const Maybe<AnimationParams>& aAnimParams)
{ {
mCurrentFrame = AllocateFrameInternal(aFrameNum, aOutputSize, aFrameRect, mCurrentFrame = AllocateFrameInternal(aOutputSize, aFrameRect, aFormat,
aFormat, aPaletteDepth, aPaletteDepth, aAnimParams,
mCurrentFrame.get()); mCurrentFrame.get());
if (mCurrentFrame) { if (mCurrentFrame) {
@ -295,7 +295,7 @@ Decoder::AllocateFrame(uint32_t aFrameNum,
// We should now be on |aFrameNum|. (Note that we're comparing the frame // 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.) // 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. // If we're past the first frame, PostIsAnimated() should've been called.
MOZ_ASSERT_IF(mFrameCount > 1, HasAnimation()); MOZ_ASSERT_IF(mFrameCount > 1, HasAnimation());
@ -309,18 +309,19 @@ Decoder::AllocateFrame(uint32_t aFrameNum,
} }
RawAccessFrameRef RawAccessFrameRef
Decoder::AllocateFrameInternal(uint32_t aFrameNum, Decoder::AllocateFrameInternal(const gfx::IntSize& aOutputSize,
const gfx::IntSize& aOutputSize,
const gfx::IntRect& aFrameRect, const gfx::IntRect& aFrameRect,
SurfaceFormat aFormat, SurfaceFormat aFormat,
uint8_t aPaletteDepth, uint8_t aPaletteDepth,
const Maybe<AnimationParams>& aAnimParams,
imgFrame* aPreviousFrame) imgFrame* aPreviousFrame)
{ {
if (HasError()) { if (HasError()) {
return RawAccessFrameRef(); return RawAccessFrameRef();
} }
if (aFrameNum != mFrameCount) { uint32_t frameNum = aAnimParams ? aAnimParams->mFrameNum : 0;
if (frameNum != mFrameCount) {
MOZ_ASSERT_UNREACHABLE("Allocating frames out of order"); MOZ_ASSERT_UNREACHABLE("Allocating frames out of order");
return RawAccessFrameRef(); return RawAccessFrameRef();
} }
@ -334,7 +335,8 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum,
NotNull<RefPtr<imgFrame>> frame = WrapNotNull(new imgFrame()); NotNull<RefPtr<imgFrame>> frame = WrapNotNull(new imgFrame());
bool nonPremult = bool(mSurfaceFlags & SurfaceFlags::NO_PREMULTIPLY_ALPHA); bool nonPremult = bool(mSurfaceFlags & SurfaceFlags::NO_PREMULTIPLY_ALPHA);
if (NS_FAILED(frame->InitForDecoder(aOutputSize, aFrameRect, aFormat, if (NS_FAILED(frame->InitForDecoder(aOutputSize, aFrameRect, aFormat,
aPaletteDepth, nonPremult))) { aPaletteDepth, nonPremult,
aAnimParams))) {
NS_WARNING("imgFrame::Init should succeed"); NS_WARNING("imgFrame::Init should succeed");
return RawAccessFrameRef(); return RawAccessFrameRef();
} }
@ -345,22 +347,22 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum,
return RawAccessFrameRef(); return RawAccessFrameRef();
} }
if (aFrameNum == 1) { if (frameNum == 1) {
MOZ_ASSERT(aPreviousFrame, "Must provide a previous frame when animated"); MOZ_ASSERT(aPreviousFrame, "Must provide a previous frame when animated");
aPreviousFrame->SetRawAccessOnly(); aPreviousFrame->SetRawAccessOnly();
// If we dispose of the first frame by clearing it, then the first frame's // If we dispose of the first frame by clearing it, then the first frame's
// refresh area is all of itself. // refresh area is all of itself.
// RESTORE_PREVIOUS is invalid (assumed to be DISPOSE_CLEAR). // RESTORE_PREVIOUS is invalid (assumed to be DISPOSE_CLEAR).
AnimationData previousFrameData = aPreviousFrame->GetAnimationData(); DisposalMethod prevDisposal = aPreviousFrame->GetDisposalMethod();
if (previousFrameData.mDisposalMethod == DisposalMethod::CLEAR || if (prevDisposal == DisposalMethod::CLEAR ||
previousFrameData.mDisposalMethod == DisposalMethod::CLEAR_ALL || prevDisposal == DisposalMethod::CLEAR_ALL ||
previousFrameData.mDisposalMethod == DisposalMethod::RESTORE_PREVIOUS) { prevDisposal == DisposalMethod::RESTORE_PREVIOUS) {
mFirstFrameRefreshArea = previousFrameData.mRect; mFirstFrameRefreshArea = aPreviousFrame->GetRect();
} }
} }
if (aFrameNum > 0) { if (frameNum > 0) {
ref->SetRawAccessOnly(); ref->SetRawAccessOnly();
// Some GIFs are huge but only have a small area that they animate. We only // Some GIFs are huge but only have a small area that they animate. We only
@ -432,13 +434,7 @@ Decoder::PostIsAnimated(FrameTimeout aFirstFrameTimeout)
} }
void void
Decoder::PostFrameStop(Opacity aFrameOpacity Decoder::PostFrameStop(Opacity aFrameOpacity)
/* = Opacity::SOME_TRANSPARENCY */,
DisposalMethod aDisposalMethod
/* = DisposalMethod::KEEP */,
FrameTimeout aTimeout /* = FrameTimeout::Forever() */,
BlendMethod aBlendMethod /* = BlendMethod::OVER */,
const Maybe<nsIntRect>& aBlendRect /* = Nothing() */)
{ {
// We should be mid-frame // We should be mid-frame
MOZ_ASSERT(!IsMetadataDecode(), "Stopping frame during metadata decode"); MOZ_ASSERT(!IsMetadataDecode(), "Stopping frame during metadata decode");
@ -449,12 +445,11 @@ Decoder::PostFrameStop(Opacity aFrameOpacity
mInFrame = false; mInFrame = false;
mFinishedNewFrame = true; mFinishedNewFrame = true;
mCurrentFrame->Finish(aFrameOpacity, aDisposalMethod, aTimeout, mCurrentFrame->Finish(aFrameOpacity);
aBlendMethod, aBlendRect);
mProgress |= FLAG_FRAME_COMPLETE; mProgress |= FLAG_FRAME_COMPLETE;
mLoopLength += aTimeout; mLoopLength += mCurrentFrame->GetTimeout();
// If we're not sending partial invalidations, then we send an invalidation // If we're not sending partial invalidations, then we send an invalidation
// here when the first frame is complete. // here when the first frame is complete.

View file

@ -11,6 +11,7 @@
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
#include "mozilla/NotNull.h" #include "mozilla/NotNull.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "AnimationParams.h"
#include "DecodePool.h" #include "DecodePool.h"
#include "DecoderFlags.h" #include "DecoderFlags.h"
#include "Downscaler.h" #include "Downscaler.h"
@ -28,6 +29,8 @@ namespace Telemetry {
namespace image { namespace image {
class imgFrame;
struct DecoderFinalStatus final struct DecoderFinalStatus final
{ {
DecoderFinalStatus(bool aWasMetadataDecode, DecoderFinalStatus(bool aWasMetadataDecode,
@ -443,11 +446,7 @@ protected:
// Specify whether this frame is opaque as an optimization. // Specify whether this frame is opaque as an optimization.
// For animated images, specify the disposal, blend method and timeout for // For animated images, specify the disposal, blend method and timeout for
// this frame. // this frame.
void PostFrameStop(Opacity aFrameOpacity = Opacity::SOME_TRANSPARENCY, void PostFrameStop(Opacity aFrameOpacity = Opacity::SOME_TRANSPARENCY);
DisposalMethod aDisposalMethod = DisposalMethod::KEEP,
FrameTimeout aTimeout = FrameTimeout::Forever(),
BlendMethod aBlendMethod = BlendMethod::OVER,
const Maybe<nsIntRect>& aBlendRect = Nothing());
/** /**
* Called by the decoders when they have a region to invalidate. We may not * Called by the decoders when they have a region to invalidate. We may not
@ -476,16 +475,13 @@ protected:
/** /**
* Allocates a new frame, making it our current frame if successful. * Allocates a new frame, making it our current frame if successful.
* *
* The @aFrameNum parameter only exists as a sanity check; it's illegal to
* create a new frame anywhere but immediately after the existing frames.
*
* If a non-paletted frame is desired, pass 0 for aPaletteDepth. * If a non-paletted frame is desired, pass 0 for aPaletteDepth.
*/ */
nsresult AllocateFrame(uint32_t aFrameNum, nsresult AllocateFrame(const gfx::IntSize& aOutputSize,
const gfx::IntSize& aOutputSize,
const gfx::IntRect& aFrameRect, const gfx::IntRect& aFrameRect,
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
uint8_t aPaletteDepth = 0); uint8_t aPaletteDepth = 0,
const Maybe<AnimationParams>& aAnimParams = Nothing());
private: private:
/// Report that an error was encountered while decoding. /// Report that an error was encountered while decoding.
@ -509,11 +505,11 @@ private:
return mInFrame ? mFrameCount - 1 : mFrameCount; return mInFrame ? mFrameCount - 1 : mFrameCount;
} }
RawAccessFrameRef AllocateFrameInternal(uint32_t aFrameNum, RawAccessFrameRef AllocateFrameInternal(const gfx::IntSize& aOutputSize,
const gfx::IntSize& aOutputSize,
const gfx::IntRect& aFrameRect, const gfx::IntRect& aFrameRect,
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
uint8_t aPaletteDepth, uint8_t aPaletteDepth,
const Maybe<AnimationParams>& aAnimParams,
imgFrame* aPreviousFrame); imgFrame* aPreviousFrame);
protected: protected:

View file

@ -74,7 +74,7 @@ public:
Maybe<SurfaceInvalidRect> TakeInvalidRect() override { return Nothing(); } Maybe<SurfaceInvalidRect> TakeInvalidRect() override { return Nothing(); }
template <typename... Rest> template <typename... Rest>
nsresult Configure(const DownscalingConfig& aConfig, Rest... aRest) nsresult Configure(const DownscalingConfig& aConfig, const Rest&... aRest)
{ {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -115,7 +115,7 @@ public:
} }
template <typename... Rest> template <typename... Rest>
nsresult Configure(const DownscalingConfig& aConfig, Rest... aRest) nsresult Configure(const DownscalingConfig& aConfig, const Rest&... aRest)
{ {
nsresult rv = mNext.Configure(aRest...); nsresult rv = mNext.Configure(aRest...);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {

View file

@ -70,7 +70,7 @@ public:
{ } { }
template <typename... Rest> template <typename... Rest>
nsresult Configure(const DeinterlacingConfig<PixelType>& aConfig, Rest... aRest) nsresult Configure(const DeinterlacingConfig<PixelType>& aConfig, const Rest&... aRest)
{ {
nsresult rv = mNext.Configure(aRest...); nsresult rv = mNext.Configure(aRest...);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -360,7 +360,7 @@ public:
{ } { }
template <typename... Rest> template <typename... Rest>
nsresult Configure(const RemoveFrameRectConfig& aConfig, Rest... aRest) nsresult Configure(const RemoveFrameRectConfig& aConfig, const Rest&... aRest)
{ {
nsresult rv = mNext.Configure(aRest...); nsresult rv = mNext.Configure(aRest...);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -590,7 +590,7 @@ public:
{ } { }
template <typename... Rest> template <typename... Rest>
nsresult Configure(const ADAM7InterpolatingConfig& aConfig, Rest... aRest) nsresult Configure(const ADAM7InterpolatingConfig& aConfig, const Rest&... aRest)
{ {
nsresult rv = mNext.Configure(aRest...); nsresult rv = mNext.Configure(aRest...);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {

View file

@ -104,10 +104,11 @@ SurfaceSink::Configure(const SurfaceConfig& aConfig)
// XXX(seth): Once every Decoder subclass uses SurfacePipe, we probably want // XXX(seth): Once every Decoder subclass uses SurfacePipe, we probably want
// to allocate the frame directly here and get rid of Decoder::AllocateFrame // to allocate the frame directly here and get rid of Decoder::AllocateFrame
// altogether. // altogether.
nsresult rv = aConfig.mDecoder->AllocateFrame(aConfig.mFrameNum, nsresult rv = aConfig.mDecoder->AllocateFrame(surfaceSize,
surfaceSize,
frameRect, frameRect,
aConfig.mFormat); aConfig.mFormat,
/* aPaletteDepth */ 0,
aConfig.mAnimParams);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -154,11 +155,11 @@ PalettedSurfaceSink::Configure(const PalettedSurfaceConfig& aConfig)
// XXX(seth): Once every Decoder subclass uses SurfacePipe, we probably want // XXX(seth): Once every Decoder subclass uses SurfacePipe, we probably want
// to allocate the frame directly here and get rid of Decoder::AllocateFrame // to allocate the frame directly here and get rid of Decoder::AllocateFrame
// altogether. // altogether.
nsresult rv = aConfig.mDecoder->AllocateFrame(aConfig.mFrameNum, nsresult rv = aConfig.mDecoder->AllocateFrame(aConfig.mOutputSize,
aConfig.mOutputSize,
aConfig.mFrameRect, aConfig.mFrameRect,
aConfig.mFormat, aConfig.mFormat,
aConfig.mPaletteDepth); aConfig.mPaletteDepth,
aConfig.mAnimParams);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }

View file

@ -34,6 +34,8 @@
#include "mozilla/Variant.h" #include "mozilla/Variant.h"
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
#include "AnimationParams.h"
namespace mozilla { namespace mozilla {
namespace image { namespace image {
@ -722,10 +724,10 @@ struct SurfaceConfig
{ {
using Filter = SurfaceSink; using Filter = SurfaceSink;
Decoder* mDecoder; /// Which Decoder to use to allocate the surface. Decoder* mDecoder; /// Which Decoder to use to allocate the surface.
uint32_t mFrameNum; /// Which frame of animation this surface is for.
gfx::IntSize mOutputSize; /// The size of the surface. gfx::IntSize mOutputSize; /// The size of the surface.
gfx::SurfaceFormat mFormat; /// The surface format (BGRA or BGRX). gfx::SurfaceFormat mFormat; /// The surface format (BGRA or BGRX).
bool mFlipVertically; /// If true, write the rows from bottom to top. bool mFlipVertically; /// If true, write the rows from bottom to top.
Maybe<AnimationParams> mAnimParams; /// Given for animated images.
}; };
/** /**
@ -750,12 +752,12 @@ struct PalettedSurfaceConfig
{ {
using Filter = PalettedSurfaceSink; using Filter = PalettedSurfaceSink;
Decoder* mDecoder; /// Which Decoder to use to allocate the surface. Decoder* mDecoder; /// Which Decoder to use to allocate the surface.
uint32_t mFrameNum; /// Which frame of animation this surface is for.
gfx::IntSize mOutputSize; /// The logical size of the surface. gfx::IntSize mOutputSize; /// The logical size of the surface.
gfx::IntRect mFrameRect; /// The surface subrect which contains data. gfx::IntRect mFrameRect; /// The surface subrect which contains data.
gfx::SurfaceFormat mFormat; /// The surface format (BGRA or BGRX). gfx::SurfaceFormat mFormat; /// The surface format (BGRA or BGRX).
uint8_t mPaletteDepth; /// The palette depth of this surface. uint8_t mPaletteDepth; /// The palette depth of this surface.
bool mFlipVertically; /// If true, write the rows from bottom to top. bool mFlipVertically; /// If true, write the rows from bottom to top.
Maybe<AnimationParams> mAnimParams; /// Given for animated images.
}; };
/** /**

View file

@ -70,8 +70,6 @@ public:
* *
* @param aDecoder The decoder whose current frame the SurfacePipe will write * @param aDecoder The decoder whose current frame the SurfacePipe will write
* to. * to.
* @param aFrameNum Which frame the SurfacePipe will write to. This will be 0
* for non-animated images.
* @param aInputSize The original size of the image. * @param aInputSize The original size of the image.
* @param aOutputSize The size the SurfacePipe should output. Must be the same * @param aOutputSize The size the SurfacePipe should output. Must be the same
* as @aInputSize or smaller. If smaller, the image will be * as @aInputSize or smaller. If smaller, the image will be
@ -79,6 +77,7 @@ public:
* @param aFrameRect The portion of the image that actually contains data. * @param aFrameRect The portion of the image that actually contains data.
* @param aFormat The surface format of the image; generally B8G8R8A8 or * @param aFormat The surface format of the image; generally B8G8R8A8 or
* B8G8R8X8. * B8G8R8X8.
* @param aAnimParams Extra parameters used by animated images.
* @param aFlags Flags enabling or disabling various functionality for the * @param aFlags Flags enabling or disabling various functionality for the
* SurfacePipe; see the SurfacePipeFlags documentation for more * SurfacePipe; see the SurfacePipeFlags documentation for more
* information. * information.
@ -89,11 +88,11 @@ public:
*/ */
static Maybe<SurfacePipe> static Maybe<SurfacePipe>
CreateSurfacePipe(Decoder* aDecoder, CreateSurfacePipe(Decoder* aDecoder,
uint32_t aFrameNum,
const nsIntSize& aInputSize, const nsIntSize& aInputSize,
const nsIntSize& aOutputSize, const nsIntSize& aOutputSize,
const nsIntRect& aFrameRect, const nsIntRect& aFrameRect,
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
const Maybe<AnimationParams>& aAnimParams,
SurfacePipeFlags aFlags) SurfacePipeFlags aFlags)
{ {
const bool deinterlace = bool(aFlags & SurfacePipeFlags::DEINTERLACE); const bool deinterlace = bool(aFlags & SurfacePipeFlags::DEINTERLACE);
@ -125,8 +124,8 @@ public:
ADAM7InterpolatingConfig interpolatingConfig; ADAM7InterpolatingConfig interpolatingConfig;
RemoveFrameRectConfig removeFrameRectConfig { aFrameRect }; RemoveFrameRectConfig removeFrameRectConfig { aFrameRect };
DownscalingConfig downscalingConfig { aInputSize, aFormat }; DownscalingConfig downscalingConfig { aInputSize, aFormat };
SurfaceConfig surfaceConfig { aDecoder, aFrameNum, aOutputSize, SurfaceConfig surfaceConfig { aDecoder, aOutputSize, aFormat,
aFormat, flipVertically }; flipVertically, aAnimParams };
Maybe<SurfacePipe> pipe; Maybe<SurfacePipe> pipe;
@ -181,13 +180,12 @@ public:
* *
* @param aDecoder The decoder whose current frame the SurfacePipe will write * @param aDecoder The decoder whose current frame the SurfacePipe will write
* to. * to.
* @param aFrameNum Which frame the SurfacePipe will write to. This will be 0
* for non-animated images.
* @param aInputSize The original size of the image. * @param aInputSize The original size of the image.
* @param aFrameRect The portion of the image that actually contains data. * @param aFrameRect The portion of the image that actually contains data.
* @param aFormat The surface format of the image; generally B8G8R8A8 or * @param aFormat The surface format of the image; generally B8G8R8A8 or
* B8G8R8X8. * B8G8R8X8.
* @param aPaletteDepth The palette depth of the image. * @param aPaletteDepth The palette depth of the image.
* @param aAnimParams Extra parameters used by animated images.
* @param aFlags Flags enabling or disabling various functionality for the * @param aFlags Flags enabling or disabling various functionality for the
* SurfacePipe; see the SurfacePipeFlags documentation for more * SurfacePipe; see the SurfacePipeFlags documentation for more
* information. * information.
@ -198,11 +196,11 @@ public:
*/ */
static Maybe<SurfacePipe> static Maybe<SurfacePipe>
CreatePalettedSurfacePipe(Decoder* aDecoder, CreatePalettedSurfacePipe(Decoder* aDecoder,
uint32_t aFrameNum,
const nsIntSize& aInputSize, const nsIntSize& aInputSize,
const nsIntRect& aFrameRect, const nsIntRect& aFrameRect,
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
uint8_t aPaletteDepth, uint8_t aPaletteDepth,
const Maybe<AnimationParams>& aAnimParams,
SurfacePipeFlags aFlags) SurfacePipeFlags aFlags)
{ {
const bool deinterlace = bool(aFlags & SurfacePipeFlags::DEINTERLACE); const bool deinterlace = bool(aFlags & SurfacePipeFlags::DEINTERLACE);
@ -211,9 +209,9 @@ public:
// Construct configurations for the SurfaceFilters. // Construct configurations for the SurfaceFilters.
DeinterlacingConfig<uint8_t> deinterlacingConfig { progressiveDisplay }; DeinterlacingConfig<uint8_t> deinterlacingConfig { progressiveDisplay };
PalettedSurfaceConfig palettedSurfaceConfig { aDecoder, aFrameNum, aInputSize, PalettedSurfaceConfig palettedSurfaceConfig { aDecoder, aInputSize, aFrameRect,
aFrameRect, aFormat, aPaletteDepth, aFormat, aPaletteDepth,
flipVertically }; flipVertically, aAnimParams };
Maybe<SurfacePipe> pipe; Maybe<SurfacePipe> pipe;
@ -229,7 +227,7 @@ public:
private: private:
template <typename... Configs> template <typename... Configs>
static Maybe<SurfacePipe> static Maybe<SurfacePipe>
MakePipe(Configs... aConfigs) MakePipe(const Configs&... aConfigs)
{ {
auto pipe = MakeUnique<typename detail::FilterPipeline<Configs...>::Type>(); auto pipe = MakeUnique<typename detail::FilterPipeline<Configs...>::Type>();
nsresult rv = pipe->Configure(aConfigs...); nsresult rv = pipe->Configure(aConfigs...);

View file

@ -245,7 +245,7 @@ already_AddRefed<Decoder> CreateTrivialDecoder();
* @param aConfigs The configuration for the pipeline. * @param aConfigs The configuration for the pipeline.
*/ */
template <typename Func, typename... Configs> template <typename Func, typename... Configs>
void WithFilterPipeline(Decoder* aDecoder, Func aFunc, Configs... aConfigs) void WithFilterPipeline(Decoder* aDecoder, Func aFunc, const Configs&... aConfigs)
{ {
auto pipe = MakeUnique<typename detail::FilterPipeline<Configs...>::Type>(); auto pipe = MakeUnique<typename detail::FilterPipeline<Configs...>::Type>();
nsresult rv = pipe->Configure(aConfigs...); nsresult rv = pipe->Configure(aConfigs...);
@ -268,7 +268,7 @@ void WithFilterPipeline(Decoder* aDecoder, Func aFunc, Configs... aConfigs)
* @param aConfigs The configuration for the pipeline. * @param aConfigs The configuration for the pipeline.
*/ */
template <typename... Configs> template <typename... Configs>
void AssertConfiguringPipelineFails(Decoder* aDecoder, Configs... aConfigs) void AssertConfiguringPipelineFails(Decoder* aDecoder, const Configs&... aConfigs)
{ {
auto pipe = MakeUnique<typename detail::FilterPipeline<Configs...>::Type>(); auto pipe = MakeUnique<typename detail::FilterPipeline<Configs...>::Type>();
nsresult rv = pipe->Configure(aConfigs...); nsresult rv = pipe->Configure(aConfigs...);

View file

@ -33,7 +33,7 @@ WithADAM7InterpolatingFilter(const IntSize& aSize, Func aFunc)
WithFilterPipeline(decoder, Forward<Func>(aFunc), WithFilterPipeline(decoder, Forward<Func>(aFunc),
ADAM7InterpolatingConfig { }, ADAM7InterpolatingConfig { },
SurfaceConfig { decoder, 0, aSize, SurfaceConfig { decoder, aSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -45,7 +45,7 @@ AssertConfiguringADAM7InterpolatingFilterFails(const IntSize& aSize)
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
ADAM7InterpolatingConfig { }, ADAM7InterpolatingConfig { },
SurfaceConfig { decoder, 0, aSize, SurfaceConfig { decoder, aSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -664,7 +664,7 @@ TEST(ImageADAM7InterpolatingFilter, ConfiguringPalettedADAM7InterpolatingFilterF
// should fail. // should fail.
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
ADAM7InterpolatingConfig { }, ADAM7InterpolatingConfig { },
PalettedSurfaceConfig { decoder, 0, IntSize(100, 100), PalettedSurfaceConfig { decoder, IntSize(100, 100),
IntRect(0, 0, 50, 50), IntRect(0, 0, 50, 50),
SurfaceFormat::B8G8R8A8, 8, SurfaceFormat::B8G8R8A8, 8,
false }); false });

View file

@ -28,7 +28,7 @@ WithDeinterlacingFilter(const IntSize& aSize,
WithFilterPipeline(decoder, Forward<Func>(aFunc), WithFilterPipeline(decoder, Forward<Func>(aFunc),
DeinterlacingConfig<uint32_t> { aProgressiveDisplay }, DeinterlacingConfig<uint32_t> { aProgressiveDisplay },
SurfaceConfig { decoder, 0, aSize, SurfaceConfig { decoder, aSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -41,7 +41,7 @@ WithPalettedDeinterlacingFilter(const IntSize& aSize,
WithFilterPipeline(decoder, Forward<Func>(aFunc), WithFilterPipeline(decoder, Forward<Func>(aFunc),
DeinterlacingConfig<uint8_t> { /* mProgressiveDisplay = */ true }, DeinterlacingConfig<uint8_t> { /* mProgressiveDisplay = */ true },
PalettedSurfaceConfig { decoder, 0, aSize, PalettedSurfaceConfig { decoder, aSize,
IntRect(0, 0, 100, 100), IntRect(0, 0, 100, 100),
SurfaceFormat::B8G8R8A8, 8, SurfaceFormat::B8G8R8A8, 8,
false }); false });
@ -55,7 +55,7 @@ AssertConfiguringDeinterlacingFilterFails(const IntSize& aSize)
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true}, DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true},
SurfaceConfig { decoder, 0, aSize, SurfaceConfig { decoder, aSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }

View file

@ -29,7 +29,7 @@ WithDownscalingFilter(const IntSize& aInputSize,
WithFilterPipeline(decoder, Forward<Func>(aFunc), WithFilterPipeline(decoder, Forward<Func>(aFunc),
DownscalingConfig { aInputSize, DownscalingConfig { aInputSize,
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, aOutputSize, SurfaceConfig { decoder, aOutputSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -43,7 +43,7 @@ AssertConfiguringDownscalingFilterFails(const IntSize& aInputSize,
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
DownscalingConfig { aInputSize, DownscalingConfig { aInputSize,
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, aOutputSize, SurfaceConfig { decoder, aOutputSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -224,7 +224,7 @@ TEST(ImageDownscalingFilter, ConfiguringPalettedDownscaleFails)
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
PalettedSurfaceConfig { decoder, 0, IntSize(20, 20), PalettedSurfaceConfig { decoder, IntSize(20, 20),
IntRect(0, 0, 20, 20), IntRect(0, 0, 20, 20),
SurfaceFormat::B8G8R8A8, 8, SurfaceFormat::B8G8R8A8, 8,
false }); false });

View file

@ -52,6 +52,6 @@ TEST(ImageDownscalingFilter, NoSkia)
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, IntSize(50, 50), SurfaceConfig { decoder, IntSize(50, 50),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }

View file

@ -28,7 +28,7 @@ WithRemoveFrameRectFilter(const IntSize& aSize,
WithFilterPipeline(decoder, Forward<Func>(aFunc), WithFilterPipeline(decoder, Forward<Func>(aFunc),
RemoveFrameRectConfig { aFrameRect }, RemoveFrameRectConfig { aFrameRect },
SurfaceConfig { decoder, 0, aSize, SurfaceConfig { decoder, aSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -41,7 +41,7 @@ AssertConfiguringRemoveFrameRectFilterFails(const IntSize& aSize,
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
RemoveFrameRectConfig { aFrameRect }, RemoveFrameRectConfig { aFrameRect },
SurfaceConfig { decoder, 0, aSize, SurfaceConfig { decoder, aSize,
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -320,7 +320,7 @@ TEST(ImageRemoveFrameRectFilter, ConfiguringPalettedRemoveFrameRectFails)
// should fail. // should fail.
AssertConfiguringPipelineFails(decoder, AssertConfiguringPipelineFails(decoder,
RemoveFrameRectConfig { IntRect(0, 0, 50, 50) }, RemoveFrameRectConfig { IntRect(0, 0, 50, 50) },
PalettedSurfaceConfig { decoder, 0, IntSize(100, 100), PalettedSurfaceConfig { decoder, IntSize(100, 100),
IntRect(0, 0, 50, 50), IntRect(0, 0, 50, 50),
SurfaceFormat::B8G8R8A8, 8, SurfaceFormat::B8G8R8A8, 8,
false }); false });

View file

@ -149,7 +149,7 @@ TEST_F(ImageSurfacePipeIntegration, SurfacePipe)
auto sink = MakeUnique<SurfaceSink>(); auto sink = MakeUnique<SurfaceSink>();
nsresult rv = nsresult rv =
sink->Configure(SurfaceConfig { decoder, 0, IntSize(100, 100), sink->Configure(SurfaceConfig { decoder, IntSize(100, 100),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
ASSERT_TRUE(NS_SUCCEEDED(rv)); ASSERT_TRUE(NS_SUCCEEDED(rv));
@ -227,7 +227,7 @@ TEST_F(ImageSurfacePipeIntegration, PalettedSurfacePipe)
auto sink = MakeUnique<PalettedSurfaceSink>(); auto sink = MakeUnique<PalettedSurfaceSink>();
nsresult rv = nsresult rv =
sink->Configure(PalettedSurfaceConfig { decoder, 0, IntSize(100, 100), sink->Configure(PalettedSurfaceConfig { decoder, IntSize(100, 100),
IntRect(0, 0, 100, 100), IntRect(0, 0, 100, 100),
SurfaceFormat::B8G8R8A8, SurfaceFormat::B8G8R8A8,
8, false }); 8, false });
@ -313,7 +313,7 @@ TEST_F(ImageSurfacePipeIntegration, DeinterlaceDownscaleWritePixels)
DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true }, DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true },
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, IntSize(25, 25), SurfaceConfig { decoder, IntSize(25, 25),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -369,7 +369,7 @@ TEST_F(ImageSurfacePipeIntegration, RemoveFrameRectBottomRightDownscaleWritePixe
RemoveFrameRectConfig { IntRect(50, 50, 100, 100) }, RemoveFrameRectConfig { IntRect(50, 50, 100, 100) },
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, IntSize(20, 20), SurfaceConfig { decoder, IntSize(20, 20),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -403,7 +403,7 @@ TEST_F(ImageSurfacePipeIntegration, RemoveFrameRectTopLeftDownscaleWritePixels)
RemoveFrameRectConfig { IntRect(-50, -50, 100, 100) }, RemoveFrameRectConfig { IntRect(-50, -50, 100, 100) },
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, IntSize(20, 20), SurfaceConfig { decoder, IntSize(20, 20),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -427,7 +427,7 @@ TEST_F(ImageSurfacePipeIntegration, DeinterlaceRemoveFrameRectWritePixels)
WithFilterPipeline(decoder, test, WithFilterPipeline(decoder, test,
DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true }, DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true },
RemoveFrameRectConfig { IntRect(50, 50, 100, 100) }, RemoveFrameRectConfig { IntRect(50, 50, 100, 100) },
SurfaceConfig { decoder, 0, IntSize(100, 100), SurfaceConfig { decoder, IntSize(100, 100),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -450,7 +450,7 @@ TEST_F(ImageSurfacePipeIntegration, DeinterlaceRemoveFrameRectDownscaleWritePixe
RemoveFrameRectConfig { IntRect(50, 50, 100, 100) }, RemoveFrameRectConfig { IntRect(50, 50, 100, 100) },
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, IntSize(20, 20), SurfaceConfig { decoder, IntSize(20, 20),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }
@ -465,7 +465,7 @@ TEST_F(ImageSurfacePipeIntegration, ConfiguringPalettedRemoveFrameRectDownscaleF
RemoveFrameRectConfig { IntRect(0, 0, 50, 50) }, RemoveFrameRectConfig { IntRect(0, 0, 50, 50) },
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
PalettedSurfaceConfig { decoder, 0, IntSize(100, 100), PalettedSurfaceConfig { decoder, IntSize(100, 100),
IntRect(0, 0, 50, 50), IntRect(0, 0, 50, 50),
SurfaceFormat::B8G8R8A8, 8, SurfaceFormat::B8G8R8A8, 8,
false }); false });
@ -482,7 +482,7 @@ TEST_F(ImageSurfacePipeIntegration, ConfiguringPalettedDeinterlaceDownscaleFails
DeinterlacingConfig<uint8_t> { /* mProgressiveDisplay = */ true}, DeinterlacingConfig<uint8_t> { /* mProgressiveDisplay = */ true},
DownscalingConfig { IntSize(100, 100), DownscalingConfig { IntSize(100, 100),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
PalettedSurfaceConfig { decoder, 0, IntSize(100, 100), PalettedSurfaceConfig { decoder, IntSize(100, 100),
IntRect(0, 0, 20, 20), IntRect(0, 0, 20, 20),
SurfaceFormat::B8G8R8A8, 8, SurfaceFormat::B8G8R8A8, 8,
false }); false });
@ -503,6 +503,6 @@ TEST_F(ImageSurfacePipeIntegration, ConfiguringHugeDeinterlacingBufferFails)
DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true}, DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true},
DownscalingConfig { IntSize(60000, 60000), DownscalingConfig { IntSize(60000, 60000),
SurfaceFormat::B8G8R8A8 }, SurfaceFormat::B8G8R8A8 },
SurfaceConfig { decoder, 0, IntSize(600, 600), SurfaceConfig { decoder, IntSize(600, 600),
SurfaceFormat::B8G8R8A8, false }); SurfaceFormat::B8G8R8A8, false });
} }

View file

@ -32,7 +32,7 @@ WithSurfaceSink(Func aFunc)
const bool flipVertically = Orientation == Orient::FLIP_VERTICALLY; const bool flipVertically = Orientation == Orient::FLIP_VERTICALLY;
WithFilterPipeline(decoder, Forward<Func>(aFunc), WithFilterPipeline(decoder, Forward<Func>(aFunc),
SurfaceConfig { decoder, 0, IntSize(100, 100), SurfaceConfig { decoder, IntSize(100, 100),
SurfaceFormat::B8G8R8A8, flipVertically }); SurfaceFormat::B8G8R8A8, flipVertically });
} }
@ -43,7 +43,7 @@ WithPalettedSurfaceSink(const IntRect& aFrameRect, Func aFunc)
ASSERT_TRUE(decoder != nullptr); ASSERT_TRUE(decoder != nullptr);
WithFilterPipeline(decoder, Forward<Func>(aFunc), WithFilterPipeline(decoder, Forward<Func>(aFunc),
PalettedSurfaceConfig { decoder, 0, IntSize(100, 100), PalettedSurfaceConfig { decoder, IntSize(100, 100),
aFrameRect, SurfaceFormat::B8G8R8A8, aFrameRect, SurfaceFormat::B8G8R8A8,
8, false }); 8, false });
} }