OLD | NEW |
| (Empty) |
1 // Copyright 2012 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 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_ | |
6 #define CC_ANIMATION_TIMING_FUNCTION_H_ | |
7 | |
8 #include "cc/base/cc_export.h" | |
9 #include "ui/gfx/geometry/cubic_bezier.h" | |
10 | |
11 namespace cc { | |
12 | |
13 // See http://www.w3.org/TR/css3-transitions/. | |
14 class CC_EXPORT TimingFunction { | |
15 public: | |
16 virtual ~TimingFunction(); | |
17 | |
18 virtual float GetValue(double t) const = 0; | |
19 virtual float Velocity(double time) const = 0; | |
20 // The smallest and largest values returned by GetValue for inputs in [0, 1]. | |
21 virtual void Range(float* min, float* max) const = 0; | |
22 virtual scoped_ptr<TimingFunction> Clone() const = 0; | |
23 | |
24 protected: | |
25 TimingFunction(); | |
26 | |
27 private: | |
28 DISALLOW_ASSIGN(TimingFunction); | |
29 }; | |
30 | |
31 class CC_EXPORT CubicBezierTimingFunction : public TimingFunction { | |
32 public: | |
33 static scoped_ptr<CubicBezierTimingFunction> Create(double x1, double y1, | |
34 double x2, double y2); | |
35 ~CubicBezierTimingFunction() override; | |
36 | |
37 // TimingFunction implementation. | |
38 float GetValue(double time) const override; | |
39 float Velocity(double time) const override; | |
40 void Range(float* min, float* max) const override; | |
41 scoped_ptr<TimingFunction> Clone() const override; | |
42 | |
43 protected: | |
44 CubicBezierTimingFunction(double x1, double y1, double x2, double y2); | |
45 | |
46 gfx::CubicBezier bezier_; | |
47 | |
48 private: | |
49 DISALLOW_ASSIGN(CubicBezierTimingFunction); | |
50 }; | |
51 | |
52 class CC_EXPORT EaseTimingFunction { | |
53 public: | |
54 static scoped_ptr<TimingFunction> Create(); | |
55 | |
56 private: | |
57 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseTimingFunction); | |
58 }; | |
59 | |
60 class CC_EXPORT EaseInTimingFunction { | |
61 public: | |
62 static scoped_ptr<TimingFunction> Create(); | |
63 | |
64 private: | |
65 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInTimingFunction); | |
66 }; | |
67 | |
68 class CC_EXPORT EaseOutTimingFunction { | |
69 public: | |
70 static scoped_ptr<TimingFunction> Create(); | |
71 | |
72 private: | |
73 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseOutTimingFunction); | |
74 }; | |
75 | |
76 class CC_EXPORT EaseInOutTimingFunction { | |
77 public: | |
78 static scoped_ptr<TimingFunction> Create(); | |
79 | |
80 private: | |
81 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInOutTimingFunction); | |
82 }; | |
83 | |
84 class CC_EXPORT StepsTimingFunction : public TimingFunction { | |
85 public: | |
86 static scoped_ptr<StepsTimingFunction> Create(int steps, | |
87 float steps_start_offset); | |
88 ~StepsTimingFunction() override; | |
89 | |
90 float GetValue(double t) const override; | |
91 scoped_ptr<TimingFunction> Clone() const override; | |
92 | |
93 void Range(float* min, float* max) const override; | |
94 float Velocity(double time) const override; | |
95 | |
96 protected: | |
97 StepsTimingFunction(int steps, float steps_start_offset); | |
98 | |
99 private: | |
100 int steps_; | |
101 float steps_start_offset_; | |
102 | |
103 DISALLOW_ASSIGN(StepsTimingFunction); | |
104 }; | |
105 | |
106 } // namespace cc | |
107 | |
108 #endif // CC_ANIMATION_TIMING_FUNCTION_H_ | |
OLD | NEW |