Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.cpp

Issue 2019613002: Blink Compositor Animation: Make Animation and Curve methods non-virtual. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix codereview issues. Add cc::TimingFunction::Type enum. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 (const 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 const cc::TimingFunction* timingFunction = m_curve->timing_function_for_test ing();
47 DCHECK(timingFunction);
48 DCHECK_EQ(timingFunction->GetType(), cc::TimingFunction::Type::CUBIC_BEZIER) ;
49 auto cubicTimingFunction = static_cast<const cc::CubicBezierTimingFunction*> (timingFunction);
50 return cubicTimingFunction->ease_type();
51 }
52
53 bool CompositorFloatAnimationCurve::curveHasLinearTimingFunctionForTesting() con st
54 {
55 return !m_curve->timing_function_for_testing();
56 }
57
58 CubicBezierTimingFunction::EaseType CompositorFloatAnimationCurve::getKeyframeEa seTypeForTesting(unsigned long index) const
59 {
60 DCHECK_LT(index, m_curve->keyframes_for_testing().size());
61 const cc::TimingFunction* timingFunction = m_curve->keyframes_for_testing()[ index]->timing_function();
62 DCHECK(timingFunction);
63 DCHECK_EQ(timingFunction->GetType(), cc::TimingFunction::Type::CUBIC_BEZIER) ;
64 auto cubicTimingFunction = static_cast<const cc::CubicBezierTimingFunction*> (timingFunction);
65 return cubicTimingFunction->ease_type();
66 }
67
68 bool CompositorFloatAnimationCurve::keyframeHasLinearTimingFunctionForTesting(un signed long index) const
69 {
70 DCHECK_LT(index, m_curve->keyframes_for_testing().size());
71 return !m_curve->keyframes_for_testing()[index]->timing_function();
72 }
73
24 void CompositorFloatAnimationCurve::addLinearKeyframe(const CompositorFloatKeyfr ame& keyframe) 74 void CompositorFloatAnimationCurve::addLinearKeyframe(const CompositorFloatKeyfr ame& keyframe)
25 { 75 {
26 m_curve->AddKeyframe( 76 m_curve->AddKeyframe(
27 cc::FloatKeyframe::Create(base::TimeDelta::FromSecondsD(keyframe.time), 77 cc::FloatKeyframe::Create(base::TimeDelta::FromSecondsD(keyframe.time),
28 keyframe.value, nullptr)); 78 keyframe.value, nullptr));
29 } 79 }
30 80
31 void CompositorFloatAnimationCurve::addCubicBezierKeyframe(const CompositorFloat Keyframe& keyframe, 81 void CompositorFloatAnimationCurve::addCubicBezierKeyframe(const CompositorFloat Keyframe& keyframe,
32 CubicBezierTimingFunction::EaseType easeType) 82 CubicBezierTimingFunction::EaseType easeType)
33 { 83 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 { 124 {
75 return m_curve->GetValue(base::TimeDelta::FromSecondsD(time)); 125 return m_curve->GetValue(base::TimeDelta::FromSecondsD(time));
76 } 126 }
77 127
78 std::unique_ptr<cc::AnimationCurve> CompositorFloatAnimationCurve::cloneToAnimat ionCurve() const 128 std::unique_ptr<cc::AnimationCurve> CompositorFloatAnimationCurve::cloneToAnimat ionCurve() const
79 { 129 {
80 return m_curve->Clone(); 130 return m_curve->Clone();
81 } 131 }
82 132
83 } // namespace blink 133 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698