Bug 1373836 - Generate fixed animation id per layer if animations exist, r?kats draft
authorpeter chang <pchang@mozilla.com>
Wed, 28 Jun 2017 09:31:10 -0700
changeset 602208 f435bfb474f43cf25e51932b602f06e50c0754a6
parent 602051 f3483af8ecf997453064201c49c48a682c7f3c29
child 635516 f65dec70e0af5c27c4fe5f8ec356a3df5e85a563
push id66340
push userbmo:howareyou322@gmail.com
push dateThu, 29 Jun 2017 20:51:12 +0000
reviewerskats
bugs1373836
milestone56.0a1
Bug 1373836 - Generate fixed animation id per layer if animations exist, r?kats In gecko, it's possible to generate lots of animation ids per layer if animations are changed. It also introduces lots of memory allocation/deallocation in CompositorAnimationStorage(HashTable). Generate fixed animations id per layer should help the memory usage and reduce CPU time for memory allocation. MozReview-Commit-ID: 1hWUD5gNBJH
gfx/layers/Layers.cpp
gfx/layers/ipc/LayerTransactionParent.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -237,17 +237,16 @@ Layer::ClearAnimations()
   mPendingAnimations = nullptr;
 
   if (mAnimations.IsEmpty() && mAnimationData.IsEmpty()) {
     return;
   }
 
   MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClearAnimations", this));
   mAnimations.Clear();
-  mCompositorAnimationsId = 0;
   mAnimationData.Clear();
   Mutated();
 }
 
 Animation*
 Layer::AddAnimationForNextTransaction()
 {
   MOZ_ASSERT(mPendingAnimations,
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -525,16 +525,27 @@ LayerTransactionParent::SetLayerAttribut
     layer->SetClipRect(clipRect);
   }
   if (LayerHandle maskLayer = common.maskLayer()) {
     layer->SetMaskLayer(AsLayer(maskLayer));
   } else {
     layer->SetMaskLayer(nullptr);
   }
   layer->SetCompositorAnimations(common.compositorAnimations());
+  // Clean up the Animations by id in the CompositorAnimationStorage
+  // if there are no active animations on the layer
+  if (layer->GetCompositorAnimationsId() &&
+      layer->GetAnimations().IsEmpty()) {
+    CompositorAnimationStorage* storage =
+      mCompositorBridge->GetAnimationStorage(GetId());
+
+    if (storage) {
+      storage->ClearById(layer->GetCompositorAnimationsId());
+    }
+  }
   if (common.scrollMetadata() != layer->GetAllScrollMetadata()) {
     UpdateHitTestingTree(layer, "scroll metadata changed");
     layer->SetScrollMetadata(common.scrollMetadata());
   }
   layer->SetDisplayListLog(common.displayListLog().get());
 
   // The updated invalid region is added to the existing one, since we can
   // update multiple times before the next composite.