Bug 1396471 - Keep the running compositorAnimationsId alive on the compositor, r?kats
If the compositor animations are still valid, we don't need to add its id to the discarded list.
This patch also reduces unnecessary SendDeleteCompositorAnimations calls.
MozReview-Commit-ID: AcbVUk3MUo7
--- a/gfx/layers/AnimationInfo.cpp
+++ b/gfx/layers/AnimationInfo.cpp
@@ -38,16 +38,21 @@ AnimationInfo::AddAnimation()
// Here generates a new id when the first animation is added and
// this id is used to represent the animations in this layer.
EnsureAnimationsId();
MOZ_ASSERT(!mPendingAnimations, "should have called ClearAnimations first");
Animation* anim = mAnimations.AppendElement();
+ if (mManager->AsWebRenderLayerManager()) {
+ mManager->AsWebRenderLayerManager()->
+ KeepCompositorAnimationsIdAlive(mCompositorAnimationsId);
+ }
+
mMutated = true;
return anim;
}
Animation*
AnimationInfo::AddAnimationForNextTransaction()
{
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -960,16 +960,22 @@ WebRenderLayerManager::DiscardImages()
void
WebRenderLayerManager::AddCompositorAnimationsIdForDiscard(uint64_t aId)
{
mDiscardedCompositorAnimationsIds.AppendElement(aId);
}
void
+WebRenderLayerManager::KeepCompositorAnimationsIdAlive(uint64_t aId)
+{
+ mDiscardedCompositorAnimationsIds.RemoveElement(aId);
+}
+
+void
WebRenderLayerManager::DiscardCompositorAnimations()
{
if (WrBridge()->IPCOpen() && !mDiscardedCompositorAnimationsIds.IsEmpty()) {
WrBridge()->
SendDeleteCompositorAnimations(mDiscardedCompositorAnimationsIds);
}
mDiscardedCompositorAnimationsIds.Clear();
}
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -169,16 +169,19 @@ public:
// transaction or destruction
void AddImageKeyForDiscard(wr::ImageKey);
void DiscardImages();
void DiscardLocalImages();
// Before destroying a layer with animations, add its compositorAnimationsId
// to a list of ids that will be discarded on the next transaction
void AddCompositorAnimationsIdForDiscard(uint64_t aId);
+ // If the animations are valid and running on the compositor,
+ // we should keep the compositorAnimationsId alive on the compositor side.
+ void KeepCompositorAnimationsIdAlive(uint64_t aId);
void DiscardCompositorAnimations();
WebRenderBridgeChild* WrBridge() const { return mWrChild; }
virtual void Mutated(Layer* aLayer) override;
virtual void MutatedSimple(Layer* aLayer) override;
void Hold(Layer* aLayer);