diff options
author | Martok <martok@martoks-place.de> | 2022-12-31 22:55:46 +0100 |
---|---|---|
committer | Martok <martok@martoks-place.de> | 2023-01-04 00:49:04 +0100 |
commit | b618b3fb767e61f73732a0385f733357571314b0 (patch) | |
tree | c7e53031c59f85d10ee167dc999696edc46eaa79 /image/ISurfaceProvider.h | |
parent | e7fd4ba61bec3736df2f50eb0e7b215a805dde06 (diff) | |
download | uxp-b618b3fb767e61f73732a0385f733357571314b0.tar.gz |
Issue #2073 - m-c 523950: Discard decoded frames of very large GIF animations (squashed)
Controlled by image.animated.decode-on-demand.threshold-kb, default 256MB
Includes squashed bugfixes/regressions:
- m-c 1444537: Shutting down the decode pool should make animated decoders bail early
- m-c 1628606: Make sure to mark the surface cache entry available before sending the frame complete notification
- m-c 1502275: Skip recreating the decoder after redecode errors if an animated image is reset
- m-c 1443232: Don't insert frames into our AnimationFrameBuffer that we consider in error and unusable
Diffstat (limited to 'image/ISurfaceProvider.h')
-rw-r--r-- | image/ISurfaceProvider.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/image/ISurfaceProvider.h b/image/ISurfaceProvider.h index 80e1f8e9b0..b4aaf89f9b 100644 --- a/image/ISurfaceProvider.h +++ b/image/ISurfaceProvider.h @@ -54,6 +54,12 @@ public: /// @return true if DrawableRef() will return a completely decoded surface. virtual bool IsFinished() const = 0; + /// @return true if the underlying decoder is currently fully decoded. For + /// animated images, this means that at least every frame has been decoded + /// at least once. It does not guarantee that all of the frames are present, + /// as the surface provider has the option to discard as it deems necessary. + virtual bool IsFullyDecoded() const { return IsFinished(); } + /// @return the number of bytes of memory this ISurfaceProvider is expected to /// require. Optimizations may result in lower real memory usage. Trivial /// overhead is ignored. Because this value is used in bookkeeping, it's @@ -75,6 +81,9 @@ public: ref->AddSizeOfExcludingThis(aMallocSizeOf, aHeapSizeOut, aNonHeapSizeOut); } + virtual void Reset() { } + virtual void Advance(size_t aFrame) { } + /// @return the availability state of this ISurfaceProvider, which indicates /// whether DrawableRef() could successfully return a surface. Should only be /// called from SurfaceCache code as it relies on SurfaceCache for @@ -189,6 +198,36 @@ public: return mDrawableRef ? NS_OK : NS_ERROR_FAILURE; } + void Reset() + { + if (!mProvider) { + MOZ_ASSERT_UNREACHABLE("Trying to reset a static DrawableSurface?"); + return; + } + + mProvider->Reset(); + } + + void Advance(size_t aFrame) + { + if (!mProvider) { + MOZ_ASSERT_UNREACHABLE("Trying to advance a static DrawableSurface?"); + return; + } + + mProvider->Advance(aFrame); + } + + bool IsFullyDecoded() const + { + if (!mProvider) { + MOZ_ASSERT_UNREACHABLE("Trying to check decoding state of a static DrawableSurface?"); + return false; + } + + return mProvider->IsFullyDecoded(); + } + explicit operator bool() const { return mHaveSurface; } imgFrame* operator->() { return DrawableRef().get(); } |