Bug 828173 patch 3: Add a concept of pending animations to Layer, like pending transform. r=mattwoodrow

This commit is contained in:
L. David Baron 2014-03-04 20:13:21 -08:00
parent 4bc85751cb
commit 365f5250f9
2 changed files with 42 additions and 0 deletions

View File

@ -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<TransformFunction>& 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

View File

@ -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<AnimationArray> mPendingAnimations;
InfallibleTArray<AnimData> mAnimationData;
float mOpacity;
gfx::CompositionOp mMixBlendMode;