diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 8574afc886d..022a1ed3b1e 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -190,6 +190,8 @@ Layer::AddAnimation() { MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) AddAnimation", this)); + MOZ_ASSERT(!mPendingAnimations, "should have called ClearAnimations first"); + Animation* anim = mAnimations.AppendElement(); Mutated(); @@ -199,6 +201,8 @@ Layer::AddAnimation() void Layer::ClearAnimations() { + mPendingAnimations = nullptr; + if (mAnimations.IsEmpty() && mAnimationData.IsEmpty()) { return; } @@ -209,6 +213,28 @@ Layer::ClearAnimations() Mutated(); } +Animation* +Layer::AddAnimationForNextTransaction() +{ + MOZ_ASSERT(mPendingAnimations, + "should have called ClearAnimationsForNextTransaction first"); + + Animation* anim = mPendingAnimations->AppendElement(); + + return anim; +} + +void +Layer::ClearAnimationsForNextTransaction() +{ + // Ensure we have a non-null mPendingAnimations to mark a future clear. + if (!mPendingAnimations) { + mPendingAnimations = new AnimationArray; + } + + mPendingAnimations->Clear(); +} + static nsCSSValueSharedList* CreateCSSValueList(const InfallibleTArray& aFunctions) { @@ -641,6 +667,13 @@ Layer::ApplyPendingUpdatesForThisTransaction() Mutated(); } mPendingTransform = nullptr; + + if (mPendingAnimations) { + MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PendingUpdatesForThisTransaction", this)); + mPendingAnimations->SwapElements(mAnimations); + mPendingAnimations = nullptr; + Mutated(); + } } const float diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 679ffef14e9..56f04b6d648 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -950,6 +950,13 @@ public: // layout code. To add an animation to this layer, use AddAnimation. void SetAnimations(const AnimationArray& aAnimations); + // These are a parallel to AddAnimation and clearAnimations, except + // they add pending animations that apply only when the next + // transaction is begun. (See also + // SetBaseTransformForNextTransaction.) + Animation* AddAnimationForNextTransaction(); + void ClearAnimationsForNextTransaction(); + /** * CONSTRUCTION PHASE ONLY * If a layer is "fixed position", this determines which point on the layer @@ -1410,6 +1417,8 @@ protected: float mPostYScale; gfx::Matrix4x4 mEffectiveTransform; AnimationArray mAnimations; + // See mPendingTransform above. + nsAutoPtr mPendingAnimations; InfallibleTArray mAnimationData; float mOpacity; gfx::CompositionOp mMixBlendMode;