OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_ | 5 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_ |
6 #define CC_ANIMATION_TIMING_FUNCTION_H_ | 6 #define CC_ANIMATION_TIMING_FUNCTION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/animation/animation_export.h" |
12 #include "ui/gfx/geometry/cubic_bezier.h" | 12 #include "ui/gfx/geometry/cubic_bezier.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 // See http://www.w3.org/TR/css3-transitions/. | 16 // See http://www.w3.org/TR/css3-transitions/. |
17 class CC_EXPORT TimingFunction { | 17 class CC_ANIMATION_EXPORT TimingFunction { |
18 public: | 18 public: |
19 virtual ~TimingFunction(); | 19 virtual ~TimingFunction(); |
20 | 20 |
21 // Note that LINEAR is a nullptr TimingFunction (for now). | 21 // Note that LINEAR is a nullptr TimingFunction (for now). |
22 enum class Type { LINEAR, CUBIC_BEZIER, STEPS }; | 22 enum class Type { LINEAR, CUBIC_BEZIER, STEPS }; |
23 | 23 |
24 virtual Type GetType() const = 0; | 24 virtual Type GetType() const = 0; |
25 virtual float GetValue(double t) const = 0; | 25 virtual float GetValue(double t) const = 0; |
26 virtual float Velocity(double time) const = 0; | 26 virtual float Velocity(double time) const = 0; |
27 // The smallest and largest values returned by GetValue for inputs in [0, 1]. | 27 // The smallest and largest values returned by GetValue for inputs in [0, 1]. |
28 virtual void Range(float* min, float* max) const = 0; | 28 virtual void Range(float* min, float* max) const = 0; |
29 virtual std::unique_ptr<TimingFunction> Clone() const = 0; | 29 virtual std::unique_ptr<TimingFunction> Clone() const = 0; |
30 | 30 |
31 protected: | 31 protected: |
32 TimingFunction(); | 32 TimingFunction(); |
33 | 33 |
34 DISALLOW_ASSIGN(TimingFunction); | 34 DISALLOW_ASSIGN(TimingFunction); |
35 }; | 35 }; |
36 | 36 |
37 class CC_EXPORT CubicBezierTimingFunction : public TimingFunction { | 37 class CC_ANIMATION_EXPORT CubicBezierTimingFunction : public TimingFunction { |
38 public: | 38 public: |
39 enum class EaseType { EASE, EASE_IN, EASE_OUT, EASE_IN_OUT, CUSTOM }; | 39 enum class EaseType { EASE, EASE_IN, EASE_OUT, EASE_IN_OUT, CUSTOM }; |
40 | 40 |
41 static std::unique_ptr<CubicBezierTimingFunction> CreatePreset( | 41 static std::unique_ptr<CubicBezierTimingFunction> CreatePreset( |
42 EaseType ease_type); | 42 EaseType ease_type); |
43 static std::unique_ptr<CubicBezierTimingFunction> Create(double x1, | 43 static std::unique_ptr<CubicBezierTimingFunction> Create(double x1, |
44 double y1, | 44 double y1, |
45 double x2, | 45 double x2, |
46 double y2); | 46 double y2); |
47 ~CubicBezierTimingFunction() override; | 47 ~CubicBezierTimingFunction() override; |
(...skipping 14 matching lines...) Expand all Loading... |
62 double y1, | 62 double y1, |
63 double x2, | 63 double x2, |
64 double y2); | 64 double y2); |
65 | 65 |
66 gfx::CubicBezier bezier_; | 66 gfx::CubicBezier bezier_; |
67 EaseType ease_type_; | 67 EaseType ease_type_; |
68 | 68 |
69 DISALLOW_ASSIGN(CubicBezierTimingFunction); | 69 DISALLOW_ASSIGN(CubicBezierTimingFunction); |
70 }; | 70 }; |
71 | 71 |
72 class CC_EXPORT StepsTimingFunction : public TimingFunction { | 72 class CC_ANIMATION_EXPORT StepsTimingFunction : public TimingFunction { |
73 public: | 73 public: |
74 // Web Animations specification, 3.12.4. Timing in discrete steps. | 74 // Web Animations specification, 3.12.4. Timing in discrete steps. |
75 enum class StepPosition { START, MIDDLE, END }; | 75 enum class StepPosition { START, MIDDLE, END }; |
76 | 76 |
77 static std::unique_ptr<StepsTimingFunction> Create( | 77 static std::unique_ptr<StepsTimingFunction> Create( |
78 int steps, | 78 int steps, |
79 StepPosition step_position); | 79 StepPosition step_position); |
80 ~StepsTimingFunction() override; | 80 ~StepsTimingFunction() override; |
81 | 81 |
82 // TimingFunction implementation. | 82 // TimingFunction implementation. |
(...skipping 14 matching lines...) Expand all Loading... |
97 | 97 |
98 int steps_; | 98 int steps_; |
99 StepPosition step_position_; | 99 StepPosition step_position_; |
100 | 100 |
101 DISALLOW_ASSIGN(StepsTimingFunction); | 101 DISALLOW_ASSIGN(StepsTimingFunction); |
102 }; | 102 }; |
103 | 103 |
104 } // namespace cc | 104 } // namespace cc |
105 | 105 |
106 #endif // CC_ANIMATION_TIMING_FUNCTION_H_ | 106 #endif // CC_ANIMATION_TIMING_FUNCTION_H_ |
OLD | NEW |