Chromium Code Reviews| Index: Source/core/animation/CompositorAnimations.cpp |
| diff --git a/Source/core/animation/CompositorAnimations.cpp b/Source/core/animation/CompositorAnimations.cpp |
| index 505e2942160d04005bcddb342eefbdc56d3a9069..0e69d22c3e800cbe1d8192c4b52d975ebcff18f2 100644 |
| --- a/Source/core/animation/CompositorAnimations.cpp |
| +++ b/Source/core/animation/CompositorAnimations.cpp |
| @@ -43,6 +43,70 @@ |
| namespace WebCore { |
| +// ----------------------------------------------------------------------- |
| + |
| +PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(const LinearTimingFunction* timefunc) |
| +{ |
| + return const_cast<LinearTimingFunction*>(timefunc); |
| +} |
| + |
| +PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(const CubicBezierTimingFunction* timefunc) |
| +{ |
| + switch (timefunc->subType()) { |
| + case CubicBezierTimingFunction::EaseIn: |
| + return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut); |
| + case CubicBezierTimingFunction::EaseOut: |
| + return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn); |
| + case CubicBezierTimingFunction::EaseInOut: |
| + return const_cast<CubicBezierTimingFunction*>(timefunc); |
| + case CubicBezierTimingFunction::Ease: // Ease is not symmetrical |
| + case CubicBezierTimingFunction::Custom: |
| + // Flip the timing function in x. We also have to flip it in y to |
| + // maintain the invariant that it runs from (0, 0) to (1, 1). |
|
Steve Block
2013/11/06 06:06:23
You can probably remove this, given the comment in
mithro-old
2013/11/07 00:56:59
Done.
|
| + return CubicBezierTimingFunction::create(1 - timefunc->x2(), 1 - timefunc->y2(), 1 - timefunc->x1(), 1 - timefunc->y1()); |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| +} |
| + |
| +PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(const ChainedTimingFunction* timefunc) |
| +{ |
| + RefPtr<ChainedTimingFunction> reversed = ChainedTimingFunction::create(); |
| + for (size_t i = 0; i < timefunc->m_segments.size(); i++) { |
| + size_t index = timefunc->m_segments.size() - i - 1; |
| + |
| + RefPtr<TimingFunction> rtf = reverse(timefunc->m_segments[index].m_timingFunction.get()); |
| + reversed->appendSegment(1 - timefunc->m_segments[index].m_min, rtf.get()); |
| + } |
| + return reversed; |
| +} |
| + |
| +PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(const TimingFunction* timefunc) |
| +{ |
| + switch (timefunc->type()) { |
| + case TimingFunction::LinearFunction: { |
| + const LinearTimingFunction* linear = static_cast<const LinearTimingFunction*>(timefunc); |
| + return reverse(linear); |
| + } |
| + case TimingFunction::CubicBezierFunction: { |
| + const CubicBezierTimingFunction* cubic = static_cast<const CubicBezierTimingFunction*>(timefunc); |
| + return reverse(cubic); |
| + } |
| + case TimingFunction::ChainedFunction: { |
| + const ChainedTimingFunction* chained = static_cast<const ChainedTimingFunction*>(timefunc); |
| + return reverse(chained); |
| + } |
| + |
| + // Steps function can not be reversed. |
| + case TimingFunction::StepsFunction: |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| +} |
| + |
| +// ----------------------------------------------------------------------- |
| + |
| + |
| bool CompositorAnimations::isCandidateForCompositorAnimation(const Timing& timing, const AnimationEffect* effect) |
| { |
| // FIXME: Implement. |