| Index: Source/core/animation/Animation.cpp
|
| diff --git a/Source/core/animation/Animation.cpp b/Source/core/animation/Animation.cpp
|
| index 37715b2c7c078f8c8db951c3607040a4a8d75178..3eebfc6e38082007dc2a5c6af6afc7f29e06fba2 100644
|
| --- a/Source/core/animation/Animation.cpp
|
| +++ b/Source/core/animation/Animation.cpp
|
| @@ -32,6 +32,8 @@
|
| #include "core/animation/Animation.h"
|
|
|
| #include "core/animation/ActiveAnimations.h"
|
| +#include "core/animation/CompositorAnimations.h"
|
| +#include "core/animation/KeyframeAnimationEffect.h"
|
| #include "core/animation/Player.h"
|
| #include "core/dom/Element.h"
|
|
|
| @@ -61,7 +63,6 @@ void Animation::willDetach()
|
| {
|
| if (m_target)
|
| m_target->activeAnimations()->players().remove(player());
|
| -
|
| if (m_activeInAnimationStack)
|
| clearEffects();
|
| }
|
| @@ -92,6 +93,7 @@ void Animation::clearEffects()
|
| ASSERT(player());
|
| ASSERT(m_activeInAnimationStack);
|
| ensureAnimationStack(m_target.get()).remove(this);
|
| + cancelAnimationOnCompositor();
|
| m_activeInAnimationStack = false;
|
| m_compositableValues.clear();
|
| m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer);
|
| @@ -112,14 +114,19 @@ bool Animation::updateChildrenAndEffects() const
|
| return false;
|
| }
|
|
|
| -double Animation::calculateTimeToEffectChange(double localTime, double) const
|
| +double Animation::calculateTimeToEffectChange(double localTime, double timeToNextIteration) const
|
| {
|
| const double activeStartTime = startTime() + specified().startDelay;
|
| -
|
| switch (phase()) {
|
| case PhaseBefore:
|
| return activeStartTime - localTime;
|
| case PhaseActive:
|
| + if (hasActiveAnimationsOnCompositor()) {
|
| + // Need service to apply fill / fire events.
|
| + const double activeEndTime = activeStartTime + activeDuration();
|
| + ASSERT(isNull(timeToNextIteration) || timeToNextIteration <= (activeEndTime - localTime));
|
| + return isNull(timeToNextIteration) ? activeEndTime - localTime : timeToNextIteration;
|
| + }
|
| return 0;
|
| case PhaseAfter:
|
| // If this Animation is still in effect then it will need to update
|
| @@ -133,4 +140,51 @@ double Animation::calculateTimeToEffectChange(double localTime, double) const
|
| }
|
| }
|
|
|
| +bool Animation::isCandidateForAnimationOnCompositor() const
|
| +{
|
| + if (!effect() || !m_target)
|
| + return false;
|
| + return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(specified(), *effect());
|
| +}
|
| +
|
| +bool Animation::maybeStartAnimationOnCompositor()
|
| +{
|
| + ASSERT(!hasActiveAnimationsOnCompositor());
|
| + if (!isCandidateForAnimationOnCompositor())
|
| + return false;
|
| + if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_target.get()))
|
| + return false;
|
| + if (!CompositorAnimations::instance()->startAnimationOnCompositor(*m_target.get(), specified(), *effect(), m_compositorAnimationIds))
|
| + return false;
|
| + ASSERT(!m_compositorAnimationIds.isEmpty());
|
| + return true;
|
| +}
|
| +
|
| +bool Animation::hasActiveAnimationsOnCompositor() const
|
| +{
|
| + return !m_compositorAnimationIds.isEmpty();
|
| +}
|
| +
|
| +bool Animation::hasActiveAnimationsOnCompositor(CSSPropertyID property) const
|
| +{
|
| + return hasActiveAnimationsOnCompositor() && affects(property);
|
| +}
|
| +
|
| +bool Animation::affects(CSSPropertyID property) const
|
| +{
|
| + return m_effect && m_effect->affects(property);
|
| +}
|
| +
|
| +void Animation::cancelAnimationOnCompositor()
|
| +{
|
| + if (!hasActiveAnimationsOnCompositor())
|
| + return;
|
| + if (!m_target || !m_target->renderer())
|
| + return;
|
| + for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) {
|
| + CompositorAnimations::instance()->cancelAnimationOnCompositor(*m_target.get(), m_compositorAnimationIds[i]);
|
| + }
|
| + m_compositorAnimationIds.clear();
|
| +}
|
| +
|
| } // namespace WebCore
|
|
|