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

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

Issue 1616653002: CC Animation: Move files from cc_blink to Source/platform/animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Fix copyrights and years. Created 4 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "platform/animation/CompositorFloatAnimationCurve.h"
6
7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/keyframed_animation_curve.h"
9 #include "cc/animation/timing_function.h"
10
11 using blink::CompositorFloatKeyframe;
12
13 namespace blink {
14
15 CompositorFloatAnimationCurve::CompositorFloatAnimationCurve()
16 : m_curve(cc::KeyframedFloatAnimationCurve::Create())
17 {
18 }
19
20 CompositorFloatAnimationCurve::~CompositorFloatAnimationCurve()
21 {
22 }
23
24 CompositorAnimationCurve::AnimationCurveType CompositorFloatAnimationCurve::type () const
25 {
26 return CompositorAnimationCurve::AnimationCurveTypeFloat;
27 }
28
29 void CompositorFloatAnimationCurve::add(const CompositorFloatKeyframe& keyframe)
30 {
31 add(keyframe, TimingFunctionTypeEase);
32 }
33
34 void CompositorFloatAnimationCurve::add(const CompositorFloatKeyframe& keyframe,
35 TimingFunctionType type)
36 {
37 m_curve->AddKeyframe(
38 cc::FloatKeyframe::Create(base::TimeDelta::FromSecondsD(keyframe.time),
39 keyframe.value, createTimingFunction(type)));
40 }
41
42 void CompositorFloatAnimationCurve::add(const CompositorFloatKeyframe& keyframe, double x1, double y1, double x2, double y2)
43 {
44 m_curve->AddKeyframe(cc::FloatKeyframe::Create(
45 base::TimeDelta::FromSecondsD(keyframe.time), keyframe.value,
46 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)));
47 }
48
49 void CompositorFloatAnimationCurve::add(const CompositorFloatKeyframe& keyframe, int steps, float stepsStartOffset)
50 {
51 m_curve->AddKeyframe(cc::FloatKeyframe::Create(
52 base::TimeDelta::FromSecondsD(keyframe.time), keyframe.value,
53 cc::StepsTimingFunction::Create(steps, stepsStartOffset)));
54 }
55
56 void CompositorFloatAnimationCurve::setLinearTimingFunction()
57 {
58 m_curve->SetTimingFunction(nullptr);
59 }
60
61 void CompositorFloatAnimationCurve::setCubicBezierTimingFunction(TimingFunctionT ype type)
62 {
63 m_curve->SetTimingFunction(createTimingFunction(type));
64 }
65
66 void CompositorFloatAnimationCurve::setCubicBezierTimingFunction(double x1, doub le y1, double x2, double y2)
67 {
68 m_curve->SetTimingFunction(cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2));
69 }
70
71 void CompositorFloatAnimationCurve::setStepsTimingFunction(int numberOfSteps, fl oat stepsStartOffset)
72 {
73 m_curve->SetTimingFunction(cc::StepsTimingFunction::Create(numberOfSteps, st epsStartOffset));
74 }
75
76 float CompositorFloatAnimationCurve::getValue(double time) const
77 {
78 return m_curve->GetValue(base::TimeDelta::FromSecondsD(time));
79 }
80
81 scoped_ptr<cc::AnimationCurve> CompositorFloatAnimationCurve::cloneToAnimationCu rve() const
82 {
83 return m_curve->Clone();
84 }
85
86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698