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_ANIMATION_CURVE_H_ | 5 #ifndef CC_ANIMATION_ANIMATION_CURVE_H_ |
6 #define CC_ANIMATION_ANIMATION_CURVE_H_ | 6 #define CC_ANIMATION_ANIMATION_CURVE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/animation/animation_export.h" |
12 #include "cc/output/filter_operations.h" | 12 #include "cc/output/filter_operations.h" |
13 #include "ui/gfx/transform.h" | 13 #include "ui/gfx/transform.h" |
14 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 class BoxF; | 16 class BoxF; |
17 } | 17 } |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class ColorAnimationCurve; | 21 class ColorAnimationCurve; |
22 class FilterAnimationCurve; | 22 class FilterAnimationCurve; |
23 class FloatAnimationCurve; | 23 class FloatAnimationCurve; |
24 class ScrollOffsetAnimationCurve; | 24 class ScrollOffsetAnimationCurve; |
25 class TransformAnimationCurve; | 25 class TransformAnimationCurve; |
26 | 26 |
27 // An animation curve is a function that returns a value given a time. | 27 // An animation curve is a function that returns a value given a time. |
28 class CC_EXPORT AnimationCurve { | 28 class CC_ANIMATION_EXPORT AnimationCurve { |
29 public: | 29 public: |
30 enum CurveType { COLOR, FLOAT, TRANSFORM, FILTER, SCROLL_OFFSET }; | 30 enum CurveType { COLOR, FLOAT, TRANSFORM, FILTER, SCROLL_OFFSET }; |
31 | 31 |
32 virtual ~AnimationCurve() {} | 32 virtual ~AnimationCurve() {} |
33 | 33 |
34 virtual base::TimeDelta Duration() const = 0; | 34 virtual base::TimeDelta Duration() const = 0; |
35 virtual CurveType Type() const = 0; | 35 virtual CurveType Type() const = 0; |
36 virtual std::unique_ptr<AnimationCurve> Clone() const = 0; | 36 virtual std::unique_ptr<AnimationCurve> Clone() const = 0; |
37 | 37 |
38 const ColorAnimationCurve* ToColorAnimationCurve() const; | 38 const ColorAnimationCurve* ToColorAnimationCurve() const; |
39 const FloatAnimationCurve* ToFloatAnimationCurve() const; | 39 const FloatAnimationCurve* ToFloatAnimationCurve() const; |
40 const TransformAnimationCurve* ToTransformAnimationCurve() const; | 40 const TransformAnimationCurve* ToTransformAnimationCurve() const; |
41 const FilterAnimationCurve* ToFilterAnimationCurve() const; | 41 const FilterAnimationCurve* ToFilterAnimationCurve() const; |
42 const ScrollOffsetAnimationCurve* ToScrollOffsetAnimationCurve() const; | 42 const ScrollOffsetAnimationCurve* ToScrollOffsetAnimationCurve() const; |
43 | 43 |
44 ScrollOffsetAnimationCurve* ToScrollOffsetAnimationCurve(); | 44 ScrollOffsetAnimationCurve* ToScrollOffsetAnimationCurve(); |
45 }; | 45 }; |
46 | 46 |
47 class CC_EXPORT ColorAnimationCurve : public AnimationCurve { | 47 class CC_ANIMATION_EXPORT ColorAnimationCurve : public AnimationCurve { |
48 public: | 48 public: |
49 ~ColorAnimationCurve() override {} | 49 ~ColorAnimationCurve() override {} |
50 | 50 |
51 virtual SkColor GetValue(base::TimeDelta t) const = 0; | 51 virtual SkColor GetValue(base::TimeDelta t) const = 0; |
52 | 52 |
53 // Partial Animation implementation. | 53 // Partial Animation implementation. |
54 CurveType Type() const override; | 54 CurveType Type() const override; |
55 }; | 55 }; |
56 | 56 |
57 class CC_EXPORT FloatAnimationCurve : public AnimationCurve { | 57 class CC_ANIMATION_EXPORT FloatAnimationCurve : public AnimationCurve { |
58 public: | 58 public: |
59 ~FloatAnimationCurve() override {} | 59 ~FloatAnimationCurve() override {} |
60 | 60 |
61 virtual float GetValue(base::TimeDelta t) const = 0; | 61 virtual float GetValue(base::TimeDelta t) const = 0; |
62 | 62 |
63 // Partial Animation implementation. | 63 // Partial Animation implementation. |
64 CurveType Type() const override; | 64 CurveType Type() const override; |
65 }; | 65 }; |
66 | 66 |
67 class CC_EXPORT TransformAnimationCurve : public AnimationCurve { | 67 class CC_ANIMATION_EXPORT TransformAnimationCurve : public AnimationCurve { |
68 public: | 68 public: |
69 ~TransformAnimationCurve() override {} | 69 ~TransformAnimationCurve() override {} |
70 | 70 |
71 virtual gfx::Transform GetValue(base::TimeDelta t) const = 0; | 71 virtual gfx::Transform GetValue(base::TimeDelta t) const = 0; |
72 | 72 |
73 // Sets |bounds| to be the bounding box for the region within which |box| | 73 // Sets |bounds| to be the bounding box for the region within which |box| |
74 // will move during this animation. If this region cannot be computed, | 74 // will move during this animation. If this region cannot be computed, |
75 // returns false. | 75 // returns false. |
76 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box, | 76 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box, |
77 gfx::BoxF* bounds) const = 0; | 77 gfx::BoxF* bounds) const = 0; |
(...skipping 13 matching lines...) Expand all Loading... |
91 // |forward_direction| is true, the animation curve assumes it plays from | 91 // |forward_direction| is true, the animation curve assumes it plays from |
92 // the first keyframe to the last, otherwise it assumes the opposite. Returns | 92 // the first keyframe to the last, otherwise it assumes the opposite. Returns |
93 // false if the maximum scale cannot be computed. | 93 // false if the maximum scale cannot be computed. |
94 virtual bool MaximumTargetScale(bool forward_direction, | 94 virtual bool MaximumTargetScale(bool forward_direction, |
95 float* max_scale) const = 0; | 95 float* max_scale) const = 0; |
96 | 96 |
97 // Partial Animation implementation. | 97 // Partial Animation implementation. |
98 CurveType Type() const override; | 98 CurveType Type() const override; |
99 }; | 99 }; |
100 | 100 |
101 class CC_EXPORT FilterAnimationCurve : public AnimationCurve { | 101 class CC_ANIMATION_EXPORT FilterAnimationCurve : public AnimationCurve { |
102 public: | 102 public: |
103 ~FilterAnimationCurve() override {} | 103 ~FilterAnimationCurve() override {} |
104 | 104 |
105 virtual FilterOperations GetValue(base::TimeDelta t) const = 0; | 105 virtual FilterOperations GetValue(base::TimeDelta t) const = 0; |
106 virtual bool HasFilterThatMovesPixels() const = 0; | 106 virtual bool HasFilterThatMovesPixels() const = 0; |
107 | 107 |
108 // Partial Animation implementation. | 108 // Partial Animation implementation. |
109 CurveType Type() const override; | 109 CurveType Type() const override; |
110 }; | 110 }; |
111 | 111 |
112 } // namespace cc | 112 } // namespace cc |
113 | 113 |
114 #endif // CC_ANIMATION_ANIMATION_CURVE_H_ | 114 #endif // CC_ANIMATION_ANIMATION_CURVE_H_ |
OLD | NEW |