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 "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 Opacity, | 44 Opacity, |
45 Filter, | 45 Filter, |
46 ScrollOffset, | 46 ScrollOffset, |
47 BackgroundColor, | 47 BackgroundColor, |
48 // This sentinel must be last. | 48 // This sentinel must be last. |
49 TargetPropertyEnumSize | 49 TargetPropertyEnumSize |
50 }; | 50 }; |
51 | 51 |
52 enum Direction { Normal, Reverse, Alternate, AlternateReverse }; | 52 enum Direction { Normal, Reverse, Alternate, AlternateReverse }; |
53 | 53 |
| 54 enum FillMode { |
| 55 FillModeNone, |
| 56 FillModeForwards, |
| 57 FillModeBackwards, |
| 58 FillModeBoth |
| 59 }; |
| 60 |
54 static scoped_ptr<Animation> Create(scoped_ptr<AnimationCurve> curve, | 61 static scoped_ptr<Animation> Create(scoped_ptr<AnimationCurve> curve, |
55 int animation_id, | 62 int animation_id, |
56 int group_id, | 63 int group_id, |
57 TargetProperty target_property); | 64 TargetProperty target_property); |
58 | 65 |
59 virtual ~Animation(); | 66 virtual ~Animation(); |
60 | 67 |
61 int id() const { return id_; } | 68 int id() const { return id_; } |
62 int group() const { return group_; } | 69 int group() const { return group_; } |
63 TargetProperty target_property() const { return target_property_; } | 70 TargetProperty target_property() const { return target_property_; } |
(...skipping 18 matching lines...) Expand all Loading... |
82 void set_time_offset(base::TimeDelta monotonic_time) { | 89 void set_time_offset(base::TimeDelta monotonic_time) { |
83 time_offset_ = monotonic_time; | 90 time_offset_ = monotonic_time; |
84 } | 91 } |
85 | 92 |
86 void Suspend(base::TimeTicks monotonic_time); | 93 void Suspend(base::TimeTicks monotonic_time); |
87 void Resume(base::TimeTicks monotonic_time); | 94 void Resume(base::TimeTicks monotonic_time); |
88 | 95 |
89 Direction direction() { return direction_; } | 96 Direction direction() { return direction_; } |
90 void set_direction(Direction direction) { direction_ = direction; } | 97 void set_direction(Direction direction) { direction_ = direction; } |
91 | 98 |
| 99 FillMode fill_mode() { return fill_mode_; } |
| 100 void set_fill_mode(FillMode fill_mode) { fill_mode_ = fill_mode; } |
| 101 |
92 double playback_rate() { return playback_rate_; } | 102 double playback_rate() { return playback_rate_; } |
93 void set_playback_rate(double playback_rate) { | 103 void set_playback_rate(double playback_rate) { |
94 playback_rate_ = playback_rate; | 104 playback_rate_ = playback_rate; |
95 } | 105 } |
96 | 106 |
97 bool IsFinishedAt(base::TimeTicks monotonic_time) const; | 107 bool IsFinishedAt(base::TimeTicks monotonic_time) const; |
98 bool is_finished() const { | 108 bool is_finished() const { |
99 return run_state_ == Finished || | 109 return run_state_ == Finished || |
100 run_state_ == Aborted || | 110 run_state_ == Aborted || |
101 run_state_ == WaitingForDeletion; | 111 run_state_ == WaitingForDeletion; |
102 } | 112 } |
103 | 113 |
| 114 bool NoEffectBeforeAnimation(base::TimeTicks monotonic_time) const; |
| 115 |
104 AnimationCurve* curve() { return curve_.get(); } | 116 AnimationCurve* curve() { return curve_.get(); } |
105 const AnimationCurve* curve() const { return curve_.get(); } | 117 const AnimationCurve* curve() const { return curve_.get(); } |
106 | 118 |
107 // If this is true, even if the animation is running, it will not be tickable | 119 // If this is true, even if the animation is running, it will not be tickable |
108 // until it is given a start time. This is true for animations running on the | 120 // until it is given a start time. This is true for animations running on the |
109 // main thread. | 121 // main thread. |
110 bool needs_synchronized_start_time() const { | 122 bool needs_synchronized_start_time() const { |
111 return needs_synchronized_start_time_; | 123 return needs_synchronized_start_time_; |
112 } | 124 } |
113 void set_needs_synchronized_start_time(bool needs_synchronized_start_time) { | 125 void set_needs_synchronized_start_time(bool needs_synchronized_start_time) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 affects_pending_observers_ = affects_pending_observers; | 157 affects_pending_observers_ = affects_pending_observers; |
146 } | 158 } |
147 bool affects_pending_observers() const { return affects_pending_observers_; } | 159 bool affects_pending_observers() const { return affects_pending_observers_; } |
148 | 160 |
149 private: | 161 private: |
150 Animation(scoped_ptr<AnimationCurve> curve, | 162 Animation(scoped_ptr<AnimationCurve> curve, |
151 int animation_id, | 163 int animation_id, |
152 int group_id, | 164 int group_id, |
153 TargetProperty target_property); | 165 TargetProperty target_property); |
154 | 166 |
| 167 double ConvertToActiveTime(base::TimeTicks monotonic_time) const; |
| 168 |
155 scoped_ptr<AnimationCurve> curve_; | 169 scoped_ptr<AnimationCurve> curve_; |
156 | 170 |
157 // IDs are not necessarily unique. | 171 // IDs are not necessarily unique. |
158 int id_; | 172 int id_; |
159 | 173 |
160 // Animations that must be run together are called 'grouped' and have the same | 174 // Animations that must be run together are called 'grouped' and have the same |
161 // group id. Grouped animations are guaranteed to start at the same time and | 175 // group id. Grouped animations are guaranteed to start at the same time and |
162 // no other animations may animate any of the group's target properties until | 176 // no other animations may animate any of the group's target properties until |
163 // all animations in the group have finished animating. Note: an active | 177 // all animations in the group have finished animating. Note: an active |
164 // animation's group id and target property uniquely identify that animation. | 178 // animation's group id and target property uniquely identify that animation. |
165 int group_; | 179 int group_; |
166 | 180 |
167 TargetProperty target_property_; | 181 TargetProperty target_property_; |
168 RunState run_state_; | 182 RunState run_state_; |
169 double iterations_; | 183 double iterations_; |
170 base::TimeTicks start_time_; | 184 base::TimeTicks start_time_; |
171 Direction direction_; | 185 Direction direction_; |
172 double playback_rate_; | 186 double playback_rate_; |
| 187 FillMode fill_mode_; |
173 | 188 |
174 // The time offset effectively pushes the start of the animation back in time. | 189 // The time offset effectively pushes the start of the animation back in time. |
175 // This is used for resuming paused animations -- an animation is added with a | 190 // This is used for resuming paused animations -- an animation is added with a |
176 // non-zero time offset, causing the animation to skip ahead to the desired | 191 // non-zero time offset, causing the animation to skip ahead to the desired |
177 // point in time. | 192 // point in time. |
178 base::TimeDelta time_offset_; | 193 base::TimeDelta time_offset_; |
179 | 194 |
180 bool needs_synchronized_start_time_; | 195 bool needs_synchronized_start_time_; |
181 bool received_finished_event_; | 196 bool received_finished_event_; |
182 | 197 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // longer affect any observers, and are deleted. | 231 // longer affect any observers, and are deleted. |
217 bool affects_active_observers_; | 232 bool affects_active_observers_; |
218 bool affects_pending_observers_; | 233 bool affects_pending_observers_; |
219 | 234 |
220 DISALLOW_COPY_AND_ASSIGN(Animation); | 235 DISALLOW_COPY_AND_ASSIGN(Animation); |
221 }; | 236 }; |
222 | 237 |
223 } // namespace cc | 238 } // namespace cc |
224 | 239 |
225 #endif // CC_ANIMATION_ANIMATION_H_ | 240 #endif // CC_ANIMATION_ANIMATION_H_ |
OLD | NEW |