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 <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
11 #include "cc/animation/target_property.h" | 12 #include "cc/animation/target_property.h" |
12 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 | 16 |
16 class AnimationCurve; | 17 class AnimationCurve; |
17 | 18 |
18 // An Animation contains all the state required to play an AnimationCurve. | 19 // An Animation contains all the state required to play an AnimationCurve. |
19 // Specifically, the affected property, the run state (paused, finished, etc.), | 20 // Specifically, the affected property, the run state (paused, finished, etc.), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 DIRECTION_ALTERNATE_REVERSE | 52 DIRECTION_ALTERNATE_REVERSE |
52 }; | 53 }; |
53 | 54 |
54 enum FillMode { | 55 enum FillMode { |
55 FILL_MODE_NONE, | 56 FILL_MODE_NONE, |
56 FILL_MODE_FORWARDS, | 57 FILL_MODE_FORWARDS, |
57 FILL_MODE_BACKWARDS, | 58 FILL_MODE_BACKWARDS, |
58 FILL_MODE_BOTH | 59 FILL_MODE_BOTH |
59 }; | 60 }; |
60 | 61 |
61 static scoped_ptr<Animation> Create(scoped_ptr<AnimationCurve> curve, | 62 static std::unique_ptr<Animation> Create( |
62 int animation_id, | 63 std::unique_ptr<AnimationCurve> curve, |
63 int group_id, | 64 int animation_id, |
64 TargetProperty::Type target_property); | 65 int group_id, |
| 66 TargetProperty::Type target_property); |
65 | 67 |
66 virtual ~Animation(); | 68 virtual ~Animation(); |
67 | 69 |
68 int id() const { return id_; } | 70 int id() const { return id_; } |
69 int group() const { return group_; } | 71 int group() const { return group_; } |
70 TargetProperty::Type target_property() const { return target_property_; } | 72 TargetProperty::Type target_property() const { return target_property_; } |
71 | 73 |
72 RunState run_state() const { return run_state_; } | 74 RunState run_state() const { return run_state_; } |
73 void SetRunState(RunState run_state, base::TimeTicks monotonic_time); | 75 void SetRunState(RunState run_state, base::TimeTicks monotonic_time); |
74 | 76 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 139 } |
138 void set_received_finished_event(bool received_finished_event) { | 140 void set_received_finished_event(bool received_finished_event) { |
139 received_finished_event_ = received_finished_event; | 141 received_finished_event_ = received_finished_event; |
140 } | 142 } |
141 | 143 |
142 // Takes the given absolute time, and using the start time and the number | 144 // Takes the given absolute time, and using the start time and the number |
143 // of iterations, returns the relative time in the current iteration. | 145 // of iterations, returns the relative time in the current iteration. |
144 base::TimeDelta TrimTimeToCurrentIteration( | 146 base::TimeDelta TrimTimeToCurrentIteration( |
145 base::TimeTicks monotonic_time) const; | 147 base::TimeTicks monotonic_time) const; |
146 | 148 |
147 scoped_ptr<Animation> CloneAndInitialize(RunState initial_run_state) const; | 149 std::unique_ptr<Animation> CloneAndInitialize( |
| 150 RunState initial_run_state) const; |
148 | 151 |
149 void set_is_controlling_instance_for_test(bool is_controlling_instance) { | 152 void set_is_controlling_instance_for_test(bool is_controlling_instance) { |
150 is_controlling_instance_ = is_controlling_instance; | 153 is_controlling_instance_ = is_controlling_instance; |
151 } | 154 } |
152 bool is_controlling_instance() const { return is_controlling_instance_; } | 155 bool is_controlling_instance() const { return is_controlling_instance_; } |
153 | 156 |
154 void PushPropertiesTo(Animation* other) const; | 157 void PushPropertiesTo(Animation* other) const; |
155 | 158 |
156 void set_is_impl_only(bool is_impl_only) { is_impl_only_ = is_impl_only; } | 159 void set_is_impl_only(bool is_impl_only) { is_impl_only_ = is_impl_only; } |
157 bool is_impl_only() const { return is_impl_only_; } | 160 bool is_impl_only() const { return is_impl_only_; } |
158 | 161 |
159 void set_affects_active_observers(bool affects_active_observers) { | 162 void set_affects_active_observers(bool affects_active_observers) { |
160 affects_active_observers_ = affects_active_observers; | 163 affects_active_observers_ = affects_active_observers; |
161 } | 164 } |
162 bool affects_active_observers() const { return affects_active_observers_; } | 165 bool affects_active_observers() const { return affects_active_observers_; } |
163 | 166 |
164 void set_affects_pending_observers(bool affects_pending_observers) { | 167 void set_affects_pending_observers(bool affects_pending_observers) { |
165 affects_pending_observers_ = affects_pending_observers; | 168 affects_pending_observers_ = affects_pending_observers; |
166 } | 169 } |
167 bool affects_pending_observers() const { return affects_pending_observers_; } | 170 bool affects_pending_observers() const { return affects_pending_observers_; } |
168 | 171 |
169 private: | 172 private: |
170 Animation(scoped_ptr<AnimationCurve> curve, | 173 Animation(std::unique_ptr<AnimationCurve> curve, |
171 int animation_id, | 174 int animation_id, |
172 int group_id, | 175 int group_id, |
173 TargetProperty::Type target_property); | 176 TargetProperty::Type target_property); |
174 | 177 |
175 base::TimeDelta ConvertToActiveTime(base::TimeTicks monotonic_time) const; | 178 base::TimeDelta ConvertToActiveTime(base::TimeTicks monotonic_time) const; |
176 | 179 |
177 scoped_ptr<AnimationCurve> curve_; | 180 std::unique_ptr<AnimationCurve> curve_; |
178 | 181 |
179 // IDs must be unique. | 182 // IDs must be unique. |
180 int id_; | 183 int id_; |
181 | 184 |
182 // Animations that must be run together are called 'grouped' and have the same | 185 // Animations that must be run together are called 'grouped' and have the same |
183 // group id. Grouped animations are guaranteed to start at the same time and | 186 // group id. Grouped animations are guaranteed to start at the same time and |
184 // no other animations may animate any of the group's target properties until | 187 // no other animations may animate any of the group's target properties until |
185 // all animations in the group have finished animating. | 188 // all animations in the group have finished animating. |
186 int group_; | 189 int group_; |
187 | 190 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // longer affect any observers, and are deleted. | 242 // longer affect any observers, and are deleted. |
240 bool affects_active_observers_; | 243 bool affects_active_observers_; |
241 bool affects_pending_observers_; | 244 bool affects_pending_observers_; |
242 | 245 |
243 DISALLOW_COPY_AND_ASSIGN(Animation); | 246 DISALLOW_COPY_AND_ASSIGN(Animation); |
244 }; | 247 }; |
245 | 248 |
246 } // namespace cc | 249 } // namespace cc |
247 | 250 |
248 #endif // CC_ANIMATION_ANIMATION_H_ | 251 #endif // CC_ANIMATION_ANIMATION_H_ |
OLD | NEW |