Chromium Code Reviews| Index: Source/core/animation/Animation.cpp |
| diff --git a/Source/core/animation/Animation.cpp b/Source/core/animation/Animation.cpp |
| index 37715b2c7c078f8c8db951c3607040a4a8d75178..4339b5ed2ab710dcda8d4ed211e581d9b9b99b6a 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); |
| + cancelCompositorAnimations(); |
| m_activeInAnimationStack = false; |
| m_compositableValues.clear(); |
| m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
| @@ -112,14 +114,18 @@ 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 (isRunningCompositorAnimation()) { |
| + // Need service to apply fill / fire events. |
| + const double activeEndTime = activeStartTime + activeDuration(); |
| + 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 +139,58 @@ double Animation::calculateTimeToEffectChange(double localTime, double) const |
| } |
| } |
| +bool Animation::isCandidateForCompositorAnimation() const |
| +{ |
| + if (!effect() || !m_target) |
| + return false; |
| + return CompositorAnimations::instance()->isCandidateForCompositorAnimation(specified(), *effect()); |
| +} |
| + |
| +bool Animation::startCompositorAnimations() |
| +{ |
| + ASSERT(!isRunningCompositorAnimation()); |
| + if (!isCandidateForCompositorAnimation()) |
|
shans
2013/11/18 01:02:06
If this is part of the this method, then it should
dstockwell
2013/11/18 05:30:34
Done.
|
| + return false; |
| + if (!CompositorAnimations::instance()->canStartCompositorAnimation(*m_target.get())) |
| + return false; |
| + if (CompositorAnimations::instance()->startCompositorAnimation(*m_target.get(), specified(), *effect(), m_acceleratedAnimationIds)) { |
| + ASSERT(!m_acceleratedAnimationIds.isEmpty()); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +bool Animation::isRunningCompositorAnimation(const Element* element, CSSPropertyID property) const |
| +{ |
| + if (element && element != m_target) |
| + return false; |
| + |
| + if (m_acceleratedAnimationIds.isEmpty()) |
| + return false; |
| + |
| + return affects(property); |
| +} |
| + |
| +bool Animation::affects(CSSPropertyID property) const |
| +{ |
| + if (property == CSSPropertyInvalid) { |
| + // Can't affect anything if there's no effect. |
| + return m_effect; |
| + } |
| + |
| + return toKeyframeAnimationEffect(m_effect.get())->affects(property); |
| +} |
| + |
| +void Animation::cancelCompositorAnimations() |
| +{ |
| + if (!isRunningCompositorAnimation()) |
| + return; |
| + if (!m_target || !m_target->renderer()) |
| + return; |
| + for (size_t i = 0; i < m_acceleratedAnimationIds.size(); ++i) { |
| + CompositorAnimations::instance()->cancelCompositorAnimation(*m_target.get(), m_acceleratedAnimationIds[i]); |
| + } |
| + m_acceleratedAnimationIds.clear(); |
| +} |
| + |
| } // namespace WebCore |