Bug 1343341. Only set the animation state as discarded if we discarded the animated frames (and not a static frame from a first-frame-only decode). r=aosmond

The SurfaceCache can hold the first frame of a "static" decode as well as the animated frames in two seperate entries. We only care about what happens to the animated frames, so ignore OnSurfaceDiscarded for anything else.

To accomplish this we must pass the SurfaceKey to OnSurfaceDiscarded.
This commit is contained in:
Timothy Nikkel 2017-03-16 03:06:06 -05:00
parent d69ec52e66
commit 23f3425afe
10 changed files with 13 additions and 13 deletions

View File

@ -80,7 +80,7 @@ DynamicImage::OnImageDataComplete(nsIRequest* aRequest,
}
void
DynamicImage::OnSurfaceDiscarded()
DynamicImage::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey)
{ }
void

View File

@ -53,7 +53,7 @@ public:
nsresult aStatus,
bool aLastPart) override;
virtual void OnSurfaceDiscarded() override;
virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
virtual uint64_t InnerWindowID() const override;

View File

@ -216,7 +216,7 @@ public:
/**
* Called when the SurfaceCache discards a surface belonging to this image.
*/
virtual void OnSurfaceDiscarded() = 0;
virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) = 0;
virtual void SetInnerWindowID(uint64_t aInnerWindowId) = 0;
virtual uint64_t InnerWindowID() const = 0;
@ -256,7 +256,7 @@ public:
}
#endif
virtual void OnSurfaceDiscarded() override { }
virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override { }
virtual void SetInnerWindowID(uint64_t aInnerWindowId) override
{

View File

@ -88,9 +88,9 @@ ImageWrapper::OnImageDataComplete(nsIRequest* aRequest,
}
void
ImageWrapper::OnSurfaceDiscarded()
ImageWrapper::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey)
{
return mInnerImage->OnSurfaceDiscarded();
return mInnerImage->OnSurfaceDiscarded(aSurfaceKey);
}
void

View File

@ -45,7 +45,7 @@ public:
nsresult aStatus,
bool aLastPart) override;
virtual void OnSurfaceDiscarded() override;
virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
virtual uint64_t InnerWindowID() const override;

View File

@ -420,11 +420,11 @@ RasterImage::WillDrawOpaqueNow()
}
void
RasterImage::OnSurfaceDiscarded()
RasterImage::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey)
{
MOZ_ASSERT(mProgressTracker);
if (mAnimationState) {
if (mAnimationState && aSurfaceKey.Playback() == PlaybackType::eAnimated) {
MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable());
mAnimationState->SetDiscarded(true);
}

View File

@ -164,7 +164,7 @@ public:
virtual nsresult StopAnimation() override;
// Methods inherited from Image
virtual void OnSurfaceDiscarded() override;
virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
virtual size_t SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf)
const override;

View File

@ -502,7 +502,7 @@ public:
// If the surface was not a placeholder, tell its image that we discarded it.
if (!aSurface->IsPlaceholder()) {
static_cast<Image*>(imageKey)->OnSurfaceDiscarded();
static_cast<Image*>(imageKey)->OnSurfaceDiscarded(aSurface->GetSurfaceKey());
}
StopTracking(aSurface);

View File

@ -1123,7 +1123,7 @@ VectorImage::RequestDiscard()
}
void
VectorImage::OnSurfaceDiscarded()
VectorImage::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey)
{
MOZ_ASSERT(mProgressTracker);

View File

@ -49,7 +49,7 @@ public:
nsresult aResult,
bool aLastPart) override;
virtual void OnSurfaceDiscarded() override;
virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
/**
* Callback for SVGRootRenderingObserver.