diff --git a/gfx/layers/ipc/SharedSurfacesChild.cpp b/gfx/layers/ipc/SharedSurfacesChild.cpp index 970c50f8b164..534e36229527 100644 --- a/gfx/layers/ipc/SharedSurfacesChild.cpp +++ b/gfx/layers/ipc/SharedSurfacesChild.cpp @@ -13,6 +13,7 @@ #include "mozilla/layers/SourceSurfaceSharedData.h" #include "mozilla/layers/WebRenderBridgeChild.h" #include "mozilla/layers/RenderRootStateManager.h" +#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/SystemGroup.h" // for SystemGroup namespace mozilla { @@ -480,18 +481,15 @@ nsresult SharedSurfacesChild::UpdateAnimation(ImageContainer* aContainer, AnimationImageKeyData::AnimationImageKeyData(RenderRootStateManager* aManager, const wr::ImageKey& aImageKey) - : SharedSurfacesChild::ImageKeyData(aManager, aImageKey), - mRecycling(false) {} + : SharedSurfacesChild::ImageKeyData(aManager, aImageKey) {} AnimationImageKeyData::AnimationImageKeyData(AnimationImageKeyData&& aOther) : SharedSurfacesChild::ImageKeyData(std::move(aOther)), - mPendingRelease(std::move(aOther.mPendingRelease)), - mRecycling(aOther.mRecycling) {} + mPendingRelease(std::move(aOther.mPendingRelease)) {} AnimationImageKeyData& AnimationImageKeyData::operator=( AnimationImageKeyData&& aOther) { mPendingRelease = std::move(aOther.mPendingRelease); - mRecycling = aOther.mRecycling; SharedSurfacesChild::ImageKeyData::operator=(std::move(aOther)); return *this; } @@ -517,7 +515,7 @@ void SharedSurfacesAnimation::Destroy() { for (const auto& entry : mKeys) { MOZ_ASSERT(!entry.mManager->IsDestroyed()); - if (entry.mRecycling) { + if (StaticPrefs::ImageAnimatedDecodeOnDemandRecycle()) { entry.mManager->DeregisterAsyncAnimation(entry.mImageKey); } entry.mManager->AddImageKeyForDiscard(entry.mImageKey); @@ -533,11 +531,7 @@ void SharedSurfacesAnimation::HoldSurfaceForRecycling( return; } - if (!aEntry.mRecycling) { - aEntry.mManager->RegisterAsyncAnimation(aEntry.mImageKey, this); - aEntry.mRecycling = true; - } - + MOZ_ASSERT(StaticPrefs::ImageAnimatedDecodeOnDemandRecycle()); aEntry.mPendingRelease.AppendElement(aParentSurface); } @@ -626,6 +620,10 @@ nsresult SharedSurfacesAnimation::UpdateKey( if (!found) { aKey = aManager->WrBridge()->GetNextImageKey(); + if (StaticPrefs::ImageAnimatedDecodeOnDemandRecycle()) { + aManager->RegisterAsyncAnimation(aKey, this); + } + AnimationImageKeyData data(aManager, aKey); HoldSurfaceForRecycling(data, aParentSurface, aSurface); mKeys.AppendElement(std::move(data)); diff --git a/gfx/layers/ipc/SharedSurfacesChild.h b/gfx/layers/ipc/SharedSurfacesChild.h index 863cf9ab2ac2..2fccc4f6f82d 100644 --- a/gfx/layers/ipc/SharedSurfacesChild.h +++ b/gfx/layers/ipc/SharedSurfacesChild.h @@ -200,7 +200,6 @@ class AnimationImageKeyData final : public SharedSurfacesChild::ImageKeyData { AnimationImageKeyData& operator=(AnimationImageKeyData&& aOther); AutoTArray, 2> mPendingRelease; - bool mRecycling; }; /** diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index f8550a8d7b74..ade2caf28dc5 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -2859,10 +2859,10 @@ VARCACHE_PREF( ) VARCACHE_PREF( - Live, + Once, "image.animated.decode-on-demand.recycle", ImageAnimatedDecodeOnDemandRecycle, - RelaxedAtomicBool, false + bool, false ) VARCACHE_PREF(