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_H_ | 5 #ifndef CC_ANIMATION_ANIMATION_H_ |
6 #define CC_ANIMATION_ANIMATION_H_ | 6 #define CC_ANIMATION_ANIMATION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 enum TargetProperty { | 41 enum TargetProperty { |
42 Transform = 0, | 42 Transform = 0, |
43 Opacity, | 43 Opacity, |
44 Filter, | 44 Filter, |
45 ScrollOffset, | 45 ScrollOffset, |
46 BackgroundColor, | 46 BackgroundColor, |
47 // This sentinel must be last. | 47 // This sentinel must be last. |
48 TargetPropertyEnumSize | 48 TargetPropertyEnumSize |
49 }; | 49 }; |
50 | 50 |
51 enum Direction { Normal, Reverse, Alternate, AlternateReverse }; | |
52 | |
53 static scoped_ptr<Animation> Create(scoped_ptr<AnimationCurve> curve, | 51 static scoped_ptr<Animation> Create(scoped_ptr<AnimationCurve> curve, |
54 int animation_id, | 52 int animation_id, |
55 int group_id, | 53 int group_id, |
56 TargetProperty target_property); | 54 TargetProperty target_property); |
57 | 55 |
58 virtual ~Animation(); | 56 virtual ~Animation(); |
59 | 57 |
60 int id() const { return id_; } | 58 int id() const { return id_; } |
61 int group() const { return group_; } | 59 int group() const { return group_; } |
62 TargetProperty target_property() const { return target_property_; } | 60 TargetProperty target_property() const { return target_property_; } |
(...skipping 10 matching lines...) Expand all Loading... |
73 double start_time() const { return start_time_; } | 71 double start_time() const { return start_time_; } |
74 void set_start_time(double monotonic_time) { start_time_ = monotonic_time; } | 72 void set_start_time(double monotonic_time) { start_time_ = monotonic_time; } |
75 bool has_set_start_time() const { return !!start_time_; } | 73 bool has_set_start_time() const { return !!start_time_; } |
76 | 74 |
77 double time_offset() const { return time_offset_; } | 75 double time_offset() const { return time_offset_; } |
78 void set_time_offset(double monotonic_time) { time_offset_ = monotonic_time; } | 76 void set_time_offset(double monotonic_time) { time_offset_ = monotonic_time; } |
79 | 77 |
80 void Suspend(double monotonic_time); | 78 void Suspend(double monotonic_time); |
81 void Resume(double monotonic_time); | 79 void Resume(double monotonic_time); |
82 | 80 |
83 Direction direction() { return direction_; } | 81 // If alternates_direction is true, on odd numbered iterations we reverse the |
84 void set_direction(Direction direction) { direction_ = direction; } | 82 // curve. |
| 83 bool alternates_direction() const { return alternates_direction_; } |
| 84 void set_alternates_direction(bool alternates) { |
| 85 alternates_direction_ = alternates; |
| 86 } |
85 | 87 |
86 bool IsFinishedAt(double monotonic_time) const; | 88 bool IsFinishedAt(double monotonic_time) const; |
87 bool is_finished() const { | 89 bool is_finished() const { |
88 return run_state_ == Finished || | 90 return run_state_ == Finished || |
89 run_state_ == Aborted || | 91 run_state_ == Aborted || |
90 run_state_ == WaitingForDeletion; | 92 run_state_ == WaitingForDeletion; |
91 } | 93 } |
92 | 94 |
93 AnimationCurve* curve() { return curve_.get(); } | 95 AnimationCurve* curve() { return curve_.get(); } |
94 const AnimationCurve* curve() const { return curve_.get(); } | 96 const AnimationCurve* curve() const { return curve_.get(); } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // group id. Grouped animations are guaranteed to start at the same time and | 143 // group id. Grouped animations are guaranteed to start at the same time and |
142 // no other animations may animate any of the group's target properties until | 144 // no other animations may animate any of the group's target properties until |
143 // all animations in the group have finished animating. Note: an active | 145 // all animations in the group have finished animating. Note: an active |
144 // animation's group id and target property uniquely identify that animation. | 146 // animation's group id and target property uniquely identify that animation. |
145 int group_; | 147 int group_; |
146 | 148 |
147 TargetProperty target_property_; | 149 TargetProperty target_property_; |
148 RunState run_state_; | 150 RunState run_state_; |
149 int iterations_; | 151 int iterations_; |
150 double start_time_; | 152 double start_time_; |
151 Direction direction_; | 153 bool alternates_direction_; |
152 | 154 |
153 // The time offset effectively pushes the start of the animation back in time. | 155 // The time offset effectively pushes the start of the animation back in time. |
154 // This is used for resuming paused animations -- an animation is added with a | 156 // This is used for resuming paused animations -- an animation is added with a |
155 // non-zero time offset, causing the animation to skip ahead to the desired | 157 // non-zero time offset, causing the animation to skip ahead to the desired |
156 // point in time. | 158 // point in time. |
157 double time_offset_; | 159 double time_offset_; |
158 | 160 |
159 bool needs_synchronized_start_time_; | 161 bool needs_synchronized_start_time_; |
160 bool received_finished_event_; | 162 bool received_finished_event_; |
161 | 163 |
(...skipping 19 matching lines...) Expand all Loading... |
181 bool is_controlling_instance_; | 183 bool is_controlling_instance_; |
182 | 184 |
183 bool is_impl_only_; | 185 bool is_impl_only_; |
184 | 186 |
185 DISALLOW_COPY_AND_ASSIGN(Animation); | 187 DISALLOW_COPY_AND_ASSIGN(Animation); |
186 }; | 188 }; |
187 | 189 |
188 } // namespace cc | 190 } // namespace cc |
189 | 191 |
190 #endif // CC_ANIMATION_ANIMATION_H_ | 192 #endif // CC_ANIMATION_ANIMATION_H_ |
OLD | NEW |