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 23 matching lines...) Expand all Loading... |
87 void set_time_offset(base::TimeDelta monotonic_time) { | 94 void set_time_offset(base::TimeDelta monotonic_time) { |
88 time_offset_ = monotonic_time; | 95 time_offset_ = monotonic_time; |
89 } | 96 } |
90 | 97 |
91 void Suspend(base::TimeTicks monotonic_time); | 98 void Suspend(base::TimeTicks monotonic_time); |
92 void Resume(base::TimeTicks monotonic_time); | 99 void Resume(base::TimeTicks monotonic_time); |
93 | 100 |
94 Direction direction() { return direction_; } | 101 Direction direction() { return direction_; } |
95 void set_direction(Direction direction) { direction_ = direction; } | 102 void set_direction(Direction direction) { direction_ = direction; } |
96 | 103 |
| 104 FillMode fill_mode() { return fill_mode_; } |
| 105 void set_fill_mode(FillMode fill_mode) { fill_mode_ = fill_mode; } |
| 106 |
97 double playback_rate() { return playback_rate_; } | 107 double playback_rate() { return playback_rate_; } |
98 void set_playback_rate(double playback_rate) { | 108 void set_playback_rate(double playback_rate) { |
99 playback_rate_ = playback_rate; | 109 playback_rate_ = playback_rate; |
100 } | 110 } |
101 | 111 |
102 bool IsFinishedAt(base::TimeTicks monotonic_time) const; | 112 bool IsFinishedAt(base::TimeTicks monotonic_time) const; |
103 bool is_finished() const { | 113 bool is_finished() const { |
104 return run_state_ == Finished || | 114 return run_state_ == Finished || |
105 run_state_ == Aborted || | 115 run_state_ == Aborted || |
106 run_state_ == WaitingForDeletion; | 116 run_state_ == WaitingForDeletion; |
107 } | 117 } |
108 | 118 |
| 119 bool InEffect(base::TimeTicks monotonic_time) const; |
| 120 |
109 AnimationCurve* curve() { return curve_.get(); } | 121 AnimationCurve* curve() { return curve_.get(); } |
110 const AnimationCurve* curve() const { return curve_.get(); } | 122 const AnimationCurve* curve() const { return curve_.get(); } |
111 | 123 |
112 // If this is true, even if the animation is running, it will not be tickable | 124 // If this is true, even if the animation is running, it will not be tickable |
113 // until it is given a start time. This is true for animations running on the | 125 // until it is given a start time. This is true for animations running on the |
114 // main thread. | 126 // main thread. |
115 bool needs_synchronized_start_time() const { | 127 bool needs_synchronized_start_time() const { |
116 return needs_synchronized_start_time_; | 128 return needs_synchronized_start_time_; |
117 } | 129 } |
118 void set_needs_synchronized_start_time(bool needs_synchronized_start_time) { | 130 void set_needs_synchronized_start_time(bool needs_synchronized_start_time) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 affects_pending_observers_ = affects_pending_observers; | 162 affects_pending_observers_ = affects_pending_observers; |
151 } | 163 } |
152 bool affects_pending_observers() const { return affects_pending_observers_; } | 164 bool affects_pending_observers() const { return affects_pending_observers_; } |
153 | 165 |
154 private: | 166 private: |
155 Animation(scoped_ptr<AnimationCurve> curve, | 167 Animation(scoped_ptr<AnimationCurve> curve, |
156 int animation_id, | 168 int animation_id, |
157 int group_id, | 169 int group_id, |
158 TargetProperty target_property); | 170 TargetProperty target_property); |
159 | 171 |
| 172 double ConvertToActiveTime(base::TimeTicks monotonic_time) const; |
| 173 |
160 scoped_ptr<AnimationCurve> curve_; | 174 scoped_ptr<AnimationCurve> curve_; |
161 | 175 |
162 // IDs are not necessarily unique. | 176 // IDs are not necessarily unique. |
163 int id_; | 177 int id_; |
164 | 178 |
165 // Animations that must be run together are called 'grouped' and have the same | 179 // Animations that must be run together are called 'grouped' and have the same |
166 // group id. Grouped animations are guaranteed to start at the same time and | 180 // group id. Grouped animations are guaranteed to start at the same time and |
167 // no other animations may animate any of the group's target properties until | 181 // no other animations may animate any of the group's target properties until |
168 // all animations in the group have finished animating. Note: an active | 182 // all animations in the group have finished animating. Note: an active |
169 // animation's group id and target property uniquely identify that animation. | 183 // animation's group id and target property uniquely identify that animation. |
170 int group_; | 184 int group_; |
171 | 185 |
172 TargetProperty target_property_; | 186 TargetProperty target_property_; |
173 RunState run_state_; | 187 RunState run_state_; |
174 double iterations_; | 188 double iterations_; |
175 double iteration_start_; | 189 double iteration_start_; |
176 base::TimeTicks start_time_; | 190 base::TimeTicks start_time_; |
177 Direction direction_; | 191 Direction direction_; |
178 double playback_rate_; | 192 double playback_rate_; |
| 193 FillMode fill_mode_; |
179 | 194 |
180 // The time offset effectively pushes the start of the animation back in time. | 195 // The time offset effectively pushes the start of the animation back in time. |
181 // This is used for resuming paused animations -- an animation is added with a | 196 // This is used for resuming paused animations -- an animation is added with a |
182 // non-zero time offset, causing the animation to skip ahead to the desired | 197 // non-zero time offset, causing the animation to skip ahead to the desired |
183 // point in time. | 198 // point in time. |
184 base::TimeDelta time_offset_; | 199 base::TimeDelta time_offset_; |
185 | 200 |
186 bool needs_synchronized_start_time_; | 201 bool needs_synchronized_start_time_; |
187 bool received_finished_event_; | 202 bool received_finished_event_; |
188 | 203 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // longer affect any observers, and are deleted. | 237 // longer affect any observers, and are deleted. |
223 bool affects_active_observers_; | 238 bool affects_active_observers_; |
224 bool affects_pending_observers_; | 239 bool affects_pending_observers_; |
225 | 240 |
226 DISALLOW_COPY_AND_ASSIGN(Animation); | 241 DISALLOW_COPY_AND_ASSIGN(Animation); |
227 }; | 242 }; |
228 | 243 |
229 } // namespace cc | 244 } // namespace cc |
230 | 245 |
231 #endif // CC_ANIMATION_ANIMATION_H_ | 246 #endif // CC_ANIMATION_ANIMATION_H_ |
OLD | NEW |