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
--- 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.