Chromium Code Reviews| Index: Source/core/animation/Interpolation.cpp |
| diff --git a/Source/core/animation/Interpolation.cpp b/Source/core/animation/Interpolation.cpp |
| index b1aaee7cc40da8ffb9c617dc4173d0b7b1fba886..4263933a12dd3f8fc7f93bf9cc43962151613d2b 100644 |
| --- a/Source/core/animation/Interpolation.cpp |
| +++ b/Source/core/animation/Interpolation.cpp |
| @@ -5,6 +5,8 @@ |
| #include "config.h" |
| #include "core/animation/Interpolation.h" |
| +#include "platform/animation/AnimationUtilities.h" |
| + |
| namespace blink { |
| namespace { |
| @@ -35,9 +37,12 @@ bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) |
| Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end) |
| : m_start(start) |
| , m_end(end) |
| + , m_compositeStart(AnimationEffect::CompositeReplace) |
| + , m_compositeEnd(AnimationEffect::CompositeReplace) |
| , m_cachedFraction(0) |
| , m_cachedIteration(0) |
| , m_cachedValue(m_start->clone()) |
| + , m_cachedUnderlyingFraction(0) |
| { |
| RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); |
| } |
| @@ -46,12 +51,42 @@ Interpolation::~Interpolation() |
| { |
| } |
| +Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end, |
| + AnimationEffect::CompositeOperation compositeStart, AnimationEffect::CompositeOperation compositeEnd) |
| + : m_start(start) |
| + , m_end(end) |
| + , m_compositeStart(compositeStart) |
| + , m_compositeEnd(compositeEnd) |
| + , m_cachedFraction(0) |
| + , m_cachedIteration(0) |
| + , m_cachedValue(m_start->clone()) |
| + , m_cachedUnderlyingFraction(0) |
| +{ |
| + RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); |
| + |
| + if (m_compositeStart == m_compositeEnd) { |
| + if (m_compositeStart == AnimationEffect::CompositeReplace) |
| + m_cachedUnderlyingFraction = 0; |
| + else if (m_compositeStart == AnimationEffect::CompositeAdd) |
| + m_cachedUnderlyingFraction = 1; |
| + } |
|
alancutter (OOO until 2018)
2015/02/12 05:55:45
Shouldn't this just be "if start == add: UF = 1"?
|
| +} |
| + |
| void Interpolation::interpolate(int iteration, double fraction) const |
| { |
| if (m_cachedFraction != fraction || m_cachedIteration != iteration) { |
| m_start->interpolate(*m_end, fraction, *m_cachedValue); |
| m_cachedIteration = iteration; |
| m_cachedFraction = fraction; |
| + |
| + if (m_compositeStart == AnimationEffect::CompositeReplace && m_compositeEnd == AnimationEffect::CompositeReplace) |
| + m_cachedUnderlyingFraction = 0; |
| + else if (m_compositeStart == AnimationEffect::CompositeAdd && m_compositeEnd == AnimationEffect::CompositeAdd) |
| + m_cachedUnderlyingFraction = 1; |
| + else if (m_compositeStart == AnimationEffect::CompositeAdd && m_compositeEnd == AnimationEffect::CompositeReplace) |
| + m_cachedUnderlyingFraction = blend(1.0, 0.0, fraction); |
|
alancutter (OOO until 2018)
2015/02/12 05:55:45
Just use 1 - fraction.
|
| + else if (m_compositeStart == AnimationEffect::CompositeReplace && m_compositeEnd == AnimationEffect::CompositeAdd) |
| + m_cachedUnderlyingFraction = blend(0.0, 1.0, fraction); |
|
alancutter (OOO until 2018)
2015/02/12 05:55:45
Just use fraction.
|
| } |
| } |