Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/animation/CompositorFloatAnimationCurve.h" | 5 #include "platform/animation/CompositorFloatAnimationCurve.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_curve.h" | 7 #include "cc/animation/animation_curve.h" |
| 8 #include "cc/animation/keyframed_animation_curve.h" | 8 #include "cc/animation/keyframed_animation_curve.h" |
| 9 #include "cc/animation/timing_function.h" | 9 #include "cc/animation/timing_function.h" |
| 10 | 10 |
| 11 using blink::CompositorFloatKeyframe; | 11 using blink::CompositorFloatKeyframe; |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 CompositorFloatAnimationCurve::CompositorFloatAnimationCurve() | 15 CompositorFloatAnimationCurve::CompositorFloatAnimationCurve() |
| 16 : m_curve(cc::KeyframedFloatAnimationCurve::Create()) | 16 : m_curve(cc::KeyframedFloatAnimationCurve::Create()) |
| 17 { | 17 { |
| 18 } | 18 } |
| 19 | 19 |
| 20 CompositorFloatAnimationCurve::CompositorFloatAnimationCurve(std::unique_ptr<cc: :KeyframedFloatAnimationCurve> curve) | |
| 21 : m_curve(std::move(curve)) | |
| 22 { | |
| 23 } | |
| 24 | |
| 20 CompositorFloatAnimationCurve::~CompositorFloatAnimationCurve() | 25 CompositorFloatAnimationCurve::~CompositorFloatAnimationCurve() |
| 21 { | 26 { |
| 22 } | 27 } |
| 23 | 28 |
| 29 PassOwnPtr<CompositorFloatAnimationCurve> CompositorFloatAnimationCurve::CreateF orTesting(std::unique_ptr<cc::KeyframedFloatAnimationCurve> curve) | |
| 30 { | |
| 31 return adoptPtr(new CompositorFloatAnimationCurve(std::move(curve))); | |
| 32 } | |
| 33 | |
| 34 Vector<CompositorFloatKeyframe> CompositorFloatAnimationCurve::keyframesForTesti ng() const | |
| 35 { | |
| 36 Vector<CompositorFloatKeyframe> keyframes; | |
| 37 for (auto& ccKeyframe : m_curve->keyframes_for_testing()) { | |
| 38 CompositorFloatKeyframe keyframe(ccKeyframe->Time().InSecondsF(), ccKeyf rame->Value()); | |
| 39 keyframes.append(keyframe); | |
| 40 } | |
| 41 return keyframes; | |
| 42 } | |
| 43 | |
| 44 CubicBezierTimingFunction::EaseType CompositorFloatAnimationCurve::getCurveEaseT ypeForTesting() const | |
| 45 { | |
| 46 auto timingFunction = static_cast<const cc::CubicBezierTimingFunction*>(m_cu rve->timing_function_for_testing()); | |
| 47 DCHECK(timingFunction); | |
| 48 return timingFunction->ease_type(); | |
| 49 } | |
| 50 | |
| 51 bool CompositorFloatAnimationCurve::curveHasLinearTimingFunctionForTesting() con st | |
| 52 { | |
| 53 return !m_curve->timing_function_for_testing(); | |
| 54 } | |
| 55 | |
| 56 CubicBezierTimingFunction::EaseType CompositorFloatAnimationCurve::getKeyframeEa seTypeForTesting(unsigned long index) const | |
| 57 { | |
| 58 DCHECK_LT(index, m_curve->keyframes_for_testing().size()); | |
| 59 const cc::TimingFunction* timingFunction = m_curve->keyframes_for_testing()[ index]->timing_function(); | |
| 60 DCHECK(timingFunction); | |
| 61 auto cubicTimingFunction = static_cast<const cc::CubicBezierTimingFunction*> (timingFunction); | |
|
alancutter (OOO until 2018)
2016/06/01 02:20:55
Need a check that this static_cast is correct.
loyso (OOO)
2016/06/01 02:36:47
This would require an extra data member in cc::Tim
ajuma
2016/06/01 13:16:06
Yeah, that sounds fine.
loyso (OOO)
2016/06/02 02:16:46
Done. Without overhead. :)
| |
| 62 return cubicTimingFunction->ease_type(); | |
| 63 } | |
| 64 | |
| 65 bool CompositorFloatAnimationCurve::keyframeHasLinearTimingFunctionForTesting(un signed long index) const | |
| 66 { | |
| 67 DCHECK_LT(index, m_curve->keyframes_for_testing().size()); | |
| 68 return !m_curve->keyframes_for_testing()[index]->timing_function(); | |
| 69 } | |
| 70 | |
| 24 void CompositorFloatAnimationCurve::addLinearKeyframe(const CompositorFloatKeyfr ame& keyframe) | 71 void CompositorFloatAnimationCurve::addLinearKeyframe(const CompositorFloatKeyfr ame& keyframe) |
| 25 { | 72 { |
| 26 m_curve->AddKeyframe( | 73 m_curve->AddKeyframe( |
| 27 cc::FloatKeyframe::Create(base::TimeDelta::FromSecondsD(keyframe.time), | 74 cc::FloatKeyframe::Create(base::TimeDelta::FromSecondsD(keyframe.time), |
| 28 keyframe.value, nullptr)); | 75 keyframe.value, nullptr)); |
| 29 } | 76 } |
| 30 | 77 |
| 31 void CompositorFloatAnimationCurve::addCubicBezierKeyframe(const CompositorFloat Keyframe& keyframe, | 78 void CompositorFloatAnimationCurve::addCubicBezierKeyframe(const CompositorFloat Keyframe& keyframe, |
| 32 CubicBezierTimingFunction::EaseType easeType) | 79 CubicBezierTimingFunction::EaseType easeType) |
| 33 { | 80 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 { | 121 { |
| 75 return m_curve->GetValue(base::TimeDelta::FromSecondsD(time)); | 122 return m_curve->GetValue(base::TimeDelta::FromSecondsD(time)); |
| 76 } | 123 } |
| 77 | 124 |
| 78 std::unique_ptr<cc::AnimationCurve> CompositorFloatAnimationCurve::cloneToAnimat ionCurve() const | 125 std::unique_ptr<cc::AnimationCurve> CompositorFloatAnimationCurve::cloneToAnimat ionCurve() const |
| 79 { | 126 { |
| 80 return m_curve->Clone(); | 127 return m_curve->Clone(); |
| 81 } | 128 } |
| 82 | 129 |
| 83 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |