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

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: Add the check if keframe 0 is linear. 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 (auto& ccKeyframe : m_curve->keyframes_for_testing()) {
jbroman 2016/06/01 14:51:28 nit: prefer "const auto&" unless you're mutation (
loyso (OOO) 2016/06/02 02:16:46 Done.
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);
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698