Skip to content

Commit

Permalink
Backed out 6 changesets (bug 1337111) for build bustages at builds/wo…
Browse files Browse the repository at this point in the history
…rker/workspace/build/src/image/SurfaceFilters.h on a CLOSED TREE

Backed out changeset ca0caa556dc9 (bug 1337111)
Backed out changeset d7d7fa868d0d (bug 1337111)
Backed out changeset 93e956e89a21 (bug 1337111)
Backed out changeset f36337c1309b (bug 1337111)
Backed out changeset 1b1e25b0b345 (bug 1337111)
Backed out changeset 3785cdebe6a3 (bug 1337111)
  • Loading branch information
ccoroiu committed Sep 17, 2018
1 parent 9e357d1 commit de54117
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 1,316 deletions.
1 change: 0 additions & 1 deletion gfx/thebes/gfxPrefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ class gfxPrefs final

DECL_GFX_PREF(Live, "image.animated.decode-on-demand.threshold-kb", ImageAnimatedDecodeOnDemandThresholdKB, uint32_t, 20480);
DECL_GFX_PREF(Live, "image.animated.decode-on-demand.batch-size", ImageAnimatedDecodeOnDemandBatchSize, uint32_t, 6);
DECL_GFX_PREF(Live, "image.animated.generate-full-frames", ImageAnimatedGenerateFullFrames, bool, false);
DECL_GFX_PREF(Live, "image.animated.resume-from-last-displayed", ImageAnimatedResumeFromLastDisplayed, bool, false);
DECL_GFX_PREF(Live, "image.cache.factor2.threshold-surfaces", ImageCacheFactor2ThresholdSurfaces, int32_t, -1);
DECL_GFX_PREF(Once, "image.cache.size", ImageCacheSize, int32_t, 5*1024*1024);
Expand Down
8 changes: 4 additions & 4 deletions image/AnimationSurfaceProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ AnimationSurfaceProvider::AnimationSurfaceProvider(NotNull<RasterImage*> aImage,
MOZ_ASSERT(!mDecoder->IsFirstFrameDecode(),
"Use DecodedSurfaceProvider for single-frame image decodes");

// We may produce paletted surfaces for GIF which means the frames are smaller
// than one would expect.
size_t pixelSize = !aDecoder->ShouldBlendAnimation() &&
aDecoder->GetType() == DecoderType::GIF
// We still produce paletted surfaces for GIF which means the frames are
// smaller than one would expect for APNG. This may be removed if/when
// bug 1337111 lands and it is enabled by default.
size_t pixelSize = aDecoder->GetType() == DecoderType::GIF
? sizeof(uint8_t) : sizeof(uint32_t);

// Calculate how many frames we need to decode in this animation before we
Expand Down
28 changes: 4 additions & 24 deletions image/Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Decoder::AllocateFrame(const gfx::IntSize& aOutputSize,
{
mCurrentFrame = AllocateFrameInternal(aOutputSize, aFrameRect, aFormat,
aPaletteDepth, aAnimParams,
std::move(mCurrentFrame));
mCurrentFrame.get());

if (mCurrentFrame) {
mHasFrameToTake = true;
Expand Down Expand Up @@ -321,7 +321,7 @@ Decoder::AllocateFrameInternal(const gfx::IntSize& aOutputSize,
SurfaceFormat aFormat,
uint8_t aPaletteDepth,
const Maybe<AnimationParams>& aAnimParams,
RawAccessFrameRef&& aPreviousFrame)
imgFrame* aPreviousFrame)
{
if (HasError()) {
return RawAccessFrameRef();
Expand All @@ -343,7 +343,7 @@ Decoder::AllocateFrameInternal(const gfx::IntSize& aOutputSize,
bool nonPremult = bool(mSurfaceFlags & SurfaceFlags::NO_PREMULTIPLY_ALPHA);
if (NS_FAILED(frame->InitForDecoder(aOutputSize, aFrameRect, aFormat,
aPaletteDepth, nonPremult,
aAnimParams, ShouldBlendAnimation()))) {
aAnimParams))) {
NS_WARNING("imgFrame::Init should succeed");
return RawAccessFrameRef();
}
Expand Down Expand Up @@ -374,27 +374,7 @@ Decoder::AllocateFrameInternal(const gfx::IntSize& aOutputSize,

// Some GIFs are huge but only have a small area that they animate. We only
// need to refresh that small area when frame 0 comes around again.
mFirstFrameRefreshArea.UnionRect(mFirstFrameRefreshArea,
ref->GetBoundedBlendRect());

if (ShouldBlendAnimation()) {
if (aPreviousFrame->GetDisposalMethod() !=
DisposalMethod::RESTORE_PREVIOUS) {
// If the new restore frame is the direct previous frame, then we know
// the dirty rect is composed only of the current frame's blend rect and
// the restore frame's clear rect (if applicable) which are handled in
// filters.
mRestoreFrame = std::move(aPreviousFrame);
mRestoreDirtyRect.SetBox(0, 0, 0, 0);
} else {
// We only need the previous frame's dirty rect, because while there may
// have been several frames between us and mRestoreFrame, the only areas
// that changed are the restore frame's clear rect, the current frame
// blending rect, and the previous frame's blending rect. All else is
// forgotten due to us restoring the same frame again.
mRestoreDirtyRect = aPreviousFrame->GetBoundedBlendRect();
}
}
mFirstFrameRefreshArea.UnionRect(mFirstFrameRefreshArea, frame->GetRect());
}

mFrameCount++;
Expand Down
50 changes: 2 additions & 48 deletions image/Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,6 @@ class Decoder
return bool(mDecoderFlags & DecoderFlags::FIRST_FRAME_ONLY);
}

/**
* Should blend the current frame with the previous frames to produce a
* complete frame instead of a partial frame for animated images.
*/
bool ShouldBlendAnimation() const
{
return bool(mDecoderFlags & DecoderFlags::BLEND_ANIMATION);
}

/**
* @return the number of complete animation frames which have been decoded so
* far, if it has changed since the last call to TakeCompleteFrameCount();
Expand Down Expand Up @@ -419,32 +410,6 @@ class Decoder
: RawAccessFrameRef();
}

/**
* For use during decoding only. Allows the BlendAnimationFilter to get the
* current frame we are producing for its animation parameters.
*/
imgFrame* GetCurrentFrame()
{
MOZ_ASSERT(ShouldBlendAnimation());
return mCurrentFrame.get();
}

/**
* For use during decoding only. Allows the BlendAnimationFilter to get the
* frame it should be pulling the previous frame data from.
*/
const RawAccessFrameRef& GetRestoreFrameRef() const
{
MOZ_ASSERT(ShouldBlendAnimation());
return mRestoreFrame;
}

const gfx::IntRect& GetRestoreDirtyRect() const
{
MOZ_ASSERT(ShouldBlendAnimation());
return mRestoreDirtyRect;
}

bool HasFrameToTake() const { return mHasFrameToTake; }
void ClearHasFrameToTake() {
MOZ_ASSERT(mHasFrameToTake);
Expand All @@ -453,7 +418,6 @@ class Decoder

protected:
friend class AutoRecordDecoderTelemetry;
friend class DecoderTestHelper;
friend class nsICODecoder;
friend class PalettedSurfaceSink;
friend class SurfaceSink;
Expand Down Expand Up @@ -580,7 +544,7 @@ class Decoder
gfx::SurfaceFormat aFormat,
uint8_t aPaletteDepth,
const Maybe<AnimationParams>& aAnimParams,
RawAccessFrameRef&& aPreviousFrame);
imgFrame* aPreviousFrame);

protected:
Maybe<Downscaler> mDownscaler;
Expand All @@ -593,19 +557,9 @@ class Decoder
private:
RefPtr<RasterImage> mImage;
Maybe<SourceBufferIterator> mIterator;

// The current frame the decoder is producing.
RawAccessFrameRef mCurrentFrame;

// The complete frame to combine with the current partial frame to produce
// a complete current frame.
RawAccessFrameRef mRestoreFrame;

ImageMetadata mImageMetadata;

gfx::IntRect mInvalidRect; // Tracks new rows as the current frame is decoded.
gfx::IntRect mRestoreDirtyRect; // Tracks an invalidation region between the
// restore frame and the previous frame.
gfx::IntRect mInvalidRect; // Tracks an invalidation region in the current frame.
Maybe<gfx::IntSize> mOutputSize; // The size of our output surface.
Maybe<gfx::IntSize> mExpectedSize; // The expected size of the image.
Progress mProgress;
Expand Down
10 changes: 8 additions & 2 deletions image/DecoderFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ DecoderFactory::CreateDecoderForICOResource(DecoderType aType,
DecoderFactory::CreateAnonymousDecoder(DecoderType aType,
NotNull<SourceBuffer*> aSourceBuffer,
const Maybe<IntSize>& aOutputSize,
DecoderFlags aDecoderFlags,
SurfaceFlags aSurfaceFlags)
{
if (aType == DecoderType::UNKNOWN) {
Expand All @@ -351,7 +350,14 @@ DecoderFactory::CreateAnonymousDecoder(DecoderType aType,
// or do any other expensive work that might be wasted.
DecoderFlags decoderFlags = DecoderFlags::IMAGE_IS_TRANSIENT;

decoder->SetDecoderFlags(aDecoderFlags | decoderFlags);
// Without an image, the decoder can't store anything in the SurfaceCache, so
// callers will only be able to retrieve the most recent frame via
// Decoder::GetCurrentFrame(). That means that anonymous decoders should
// always be first-frame-only decoders, because nobody ever wants the *last*
// frame.
decoderFlags |= DecoderFlags::FIRST_FRAME_ONLY;

decoder->SetDecoderFlags(decoderFlags);
decoder->SetSurfaceFlags(aSurfaceFlags);

// Set an output size for downscale-during-decode if requested.
Expand Down
2 changes: 0 additions & 2 deletions image/DecoderFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,13 @@ class DecoderFactory
* smaller than the intrinsic size, the decoder will
* downscale the image. If Nothing(), the output size will
* be the intrinsic size.
* @param aDecoderFlags Flags specifying the behavior of this decoder.
* @param aSurfaceFlags Flags specifying the type of output this decoder
* should produce.
*/
static already_AddRefed<Decoder>
CreateAnonymousDecoder(DecoderType aType,
NotNull<SourceBuffer*> aSourceBuffer,
const Maybe<gfx::IntSize>& aOutputSize,
DecoderFlags aDecoderFlags,
SurfaceFlags aSurfaceFlags);

/**
Expand Down
10 changes: 1 addition & 9 deletions image/DecoderFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ enum class DecoderFlags : uint8_t
* a specific size and won't accept alternatives, then this flag should be
* set.
*/
CANNOT_SUBSTITUTE = 1 << 4,

/**
* By default, an animation decoder will produce partial frames that need to
* be combined with the previously displayed/composited frame by FrameAnimator
* to produce a complete frame. If this flag is set, the decoder will perform
* this blending at decode time, and the frames produced are complete.
*/
BLEND_ANIMATION = 1 << 5
CANNOT_SUBSTITUTE = 1 << 4
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DecoderFlags)

Expand Down
15 changes: 4 additions & 11 deletions image/FrameAnimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ FrameAnimator::AdvanceFrame(AnimationState& aState,
}

if (nextFrameIndex == 0) {
MOZ_ASSERT(nextFrame->IsFullFrame());
ret.mDirtyRect = aState.FirstFrameRefreshArea();
} else if (!nextFrame->IsFullFrame()) {
} else {
MOZ_ASSERT(nextFrameIndex == currentFrameIndex + 1);

// Change frame
if (!DoBlend(aCurrentFrame, nextFrame, nextFrameIndex, &ret.mDirtyRect)) {
// something went wrong, move on to next
Expand All @@ -336,8 +336,6 @@ FrameAnimator::AdvanceFrame(AnimationState& aState,
}

nextFrame->SetCompositingFailed(false);
} else {
ret.mDirtyRect = nextFrame->GetDirtyRect();
}

aState.mCurrentAnimationFrameTime =
Expand Down Expand Up @@ -485,13 +483,8 @@ FrameAnimator::RequestRefresh(AnimationState& aState,
}
}

// We should only mark the composited frame as valid and reset the dirty rect
// if we advanced (meaning the next frame was actually produced somehow), the
// composited frame was previously invalid (so we may need to repaint
// everything) and the frame index is valid (to know we were doing blending
// on the main thread, instead of on the decoder threads in advance).
if (currentFrameEndTime > aTime && aState.mCompositedFrameInvalid &&
mLastCompositedFrameIndex >= 0) {
// Advanced to the correct frame, the composited frame is now valid to be drawn.
if (currentFrameEndTime > aTime) {
aState.mCompositedFrameInvalid = false;
ret.mDirtyRect = IntRect(IntPoint(0,0), mSize);
}
Expand Down
4 changes: 1 addition & 3 deletions image/ImageOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ ImageOps::DecodeToSurface(ImageBuffer* aBuffer,
RefPtr<Decoder> decoder =
DecoderFactory::CreateAnonymousDecoder(decoderType,
WrapNotNull(sourceBuffer),
aSize,
DecoderFlags::FIRST_FRAME_ONLY,
ToSurfaceFlags(aFlags));
aSize, ToSurfaceFlags(aFlags));
if (!decoder) {
return nullptr;
}
Expand Down
4 changes: 0 additions & 4 deletions image/RasterImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,6 @@ RasterImage::Decode(const IntSize& aSize,
nsresult rv;
bool animated = mAnimationState && aPlaybackType == PlaybackType::eAnimated;
if (animated) {
if (gfxPrefs::ImageAnimatedGenerateFullFrames()) {
decoderFlags |= DecoderFlags::BLEND_ANIMATION;
}

size_t currentFrame = mAnimationState->GetCurrentAnimationFrameIndex();
rv = DecoderFactory::CreateAnimationDecoder(mDecoderType, WrapNotNull(this),
mSourceBuffer, mSize,
Expand Down
Loading

0 comments on commit de54117

Please sign in to comment.