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_LAYER_ANIMATION_CONTROLLER_H_ | 5 #ifndef CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ |
6 #define CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ | 6 #define CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 class LayerAnimationValueProvider; | 33 class LayerAnimationValueProvider; |
34 | 34 |
35 class CC_EXPORT LayerAnimationController | 35 class CC_EXPORT LayerAnimationController |
36 : public base::RefCounted<LayerAnimationController> { | 36 : public base::RefCounted<LayerAnimationController> { |
37 public: | 37 public: |
38 static scoped_refptr<LayerAnimationController> Create(int id); | 38 static scoped_refptr<LayerAnimationController> Create(int id); |
39 | 39 |
40 int id() const { return id_; } | 40 int id() const { return id_; } |
41 | 41 |
42 void AddAnimation(scoped_ptr<Animation> animation); | 42 void AddAnimation(scoped_ptr<Animation> animation); |
43 void PauseAnimation(int animation_id, double time_offset); | 43 void PauseAnimation(int animation_id, base::TimeDelta time_offset); |
44 void RemoveAnimation(int animation_id); | 44 void RemoveAnimation(int animation_id); |
45 void RemoveAnimation(int animation_id, | 45 void RemoveAnimation(int animation_id, |
46 Animation::TargetProperty target_property); | 46 Animation::TargetProperty target_property); |
47 void AbortAnimations(Animation::TargetProperty target_property); | 47 void AbortAnimations(Animation::TargetProperty target_property); |
48 | 48 |
49 // Ensures that the list of active animations on the main thread and the impl | 49 // Ensures that the list of active animations on the main thread and the impl |
50 // thread are kept in sync. This function does not take ownership of the impl | 50 // thread are kept in sync. This function does not take ownership of the impl |
51 // thread controller. This method is virtual for testing. | 51 // thread controller. This method is virtual for testing. |
52 virtual void PushAnimationUpdatesTo( | 52 virtual void PushAnimationUpdatesTo( |
53 LayerAnimationController* controller_impl); | 53 LayerAnimationController* controller_impl); |
54 | 54 |
55 void Animate(double monotonic_time); | 55 void Animate(base::TimeTicks monotonic_time); |
56 void AccumulatePropertyUpdates(double monotonic_time, | 56 void AccumulatePropertyUpdates(base::TimeTicks monotonic_time, |
57 AnimationEventsVector* events); | 57 AnimationEventsVector* events); |
58 | 58 |
59 void UpdateState(bool start_ready_animations, | 59 void UpdateState(bool start_ready_animations, |
60 AnimationEventsVector* events); | 60 AnimationEventsVector* events); |
61 | 61 |
62 // Make animations affect active observers if and only if they affect | 62 // Make animations affect active observers if and only if they affect |
63 // pending observers. Any animations that no longer affect any observers | 63 // pending observers. Any animations that no longer affect any observers |
64 // are deleted. | 64 // are deleted. |
65 void ActivateAnimations(); | 65 void ActivateAnimations(); |
66 | 66 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 private: | 145 private: |
146 typedef base::hash_set<int> TargetProperties; | 146 typedef base::hash_set<int> TargetProperties; |
147 | 147 |
148 void PushNewAnimationsToImplThread( | 148 void PushNewAnimationsToImplThread( |
149 LayerAnimationController* controller_impl) const; | 149 LayerAnimationController* controller_impl) const; |
150 void RemoveAnimationsCompletedOnMainThread( | 150 void RemoveAnimationsCompletedOnMainThread( |
151 LayerAnimationController* controller_impl) const; | 151 LayerAnimationController* controller_impl) const; |
152 void PushPropertiesToImplThread( | 152 void PushPropertiesToImplThread( |
153 LayerAnimationController* controller_impl) const; | 153 LayerAnimationController* controller_impl) const; |
154 | 154 |
155 void StartAnimations(double monotonic_time); | 155 void StartAnimations(base::TimeTicks monotonic_time); |
156 void PromoteStartedAnimations(double monotonic_time, | 156 void PromoteStartedAnimations(base::TimeTicks monotonic_time, |
157 AnimationEventsVector* events); | 157 AnimationEventsVector* events); |
158 void MarkFinishedAnimations(double monotonic_time); | 158 void MarkFinishedAnimations(base::TimeTicks monotonic_time); |
159 void MarkAnimationsForDeletion(double monotonic_time, | 159 void MarkAnimationsForDeletion(base::TimeTicks monotonic_time, |
160 AnimationEventsVector* events); | 160 AnimationEventsVector* events); |
161 void PurgeAnimationsMarkedForDeletion(); | 161 void PurgeAnimationsMarkedForDeletion(); |
162 | 162 |
163 void TickAnimations(double monotonic_time); | 163 void TickAnimations(base::TimeTicks monotonic_time); |
164 | 164 |
165 enum UpdateActivationType { | 165 enum UpdateActivationType { |
166 NormalActivation, | 166 NormalActivation, |
167 ForceActivation | 167 ForceActivation |
168 }; | 168 }; |
169 void UpdateActivation(UpdateActivationType type); | 169 void UpdateActivation(UpdateActivationType type); |
170 | 170 |
171 void NotifyObserversOpacityAnimated(float opacity, | 171 void NotifyObserversOpacityAnimated(float opacity, |
172 bool notify_active_observers, | 172 bool notify_active_observers, |
173 bool notify_pending_observers); | 173 bool notify_pending_observers); |
(...skipping 12 matching lines...) Expand all Loading... |
186 bool HasValueObserver(); | 186 bool HasValueObserver(); |
187 bool HasActiveValueObserver(); | 187 bool HasActiveValueObserver(); |
188 | 188 |
189 AnimationRegistrar* registrar_; | 189 AnimationRegistrar* registrar_; |
190 int id_; | 190 int id_; |
191 ScopedPtrVector<Animation> animations_; | 191 ScopedPtrVector<Animation> animations_; |
192 | 192 |
193 // This is used to ensure that we don't spam the registrar. | 193 // This is used to ensure that we don't spam the registrar. |
194 bool is_active_; | 194 bool is_active_; |
195 | 195 |
196 double last_tick_time_; | 196 base::TimeTicks last_tick_time_; |
197 | 197 |
198 ObserverList<LayerAnimationValueObserver> value_observers_; | 198 ObserverList<LayerAnimationValueObserver> value_observers_; |
199 ObserverList<LayerAnimationEventObserver> event_observers_; | 199 ObserverList<LayerAnimationEventObserver> event_observers_; |
200 | 200 |
201 LayerAnimationValueProvider* value_provider_; | 201 LayerAnimationValueProvider* value_provider_; |
202 | 202 |
203 AnimationDelegate* layer_animation_delegate_; | 203 AnimationDelegate* layer_animation_delegate_; |
204 | 204 |
205 // Only try to start animations when new animations are added or when the | 205 // Only try to start animations when new animations are added or when the |
206 // previous attempt at starting animations failed to start all animations. | 206 // previous attempt at starting animations failed to start all animations. |
207 bool needs_to_start_animations_; | 207 bool needs_to_start_animations_; |
208 | 208 |
209 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); | 209 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); |
210 }; | 210 }; |
211 | 211 |
212 } // namespace cc | 212 } // namespace cc |
213 | 213 |
214 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ | 214 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ |
OLD | NEW |