Bug 1396471 - Keep the running compositorAnimationsId alive on the compositor, r?kats draft
authorpeter chang <pchang@mozilla.com>
Thu, 21 Sep 2017 16:18:03 +0800
changeset 668184 c81c324cca9c6b31e4e9940815c660b00a97138e
parent 668025 47f7b6c64265bc7bdd22eef7ab71abc97cf3f8bf
child 732619 3a449ec5906e89c1acdcf6d4d4f6e1b56e51533c
push id80958
push userbmo:howareyou322@gmail.com
push dateThu, 21 Sep 2017 08:25:03 +0000
reviewerskats
bugs1396471
milestone57.0a1
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
gfx/layers/AnimationInfo.cpp
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/layers/wr/WebRenderLayerManager.h
--- 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);