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 <unordered_set> | 8 #include <unordered_set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... | |
40 enum class ObserverType { ACTIVE, PENDING }; | 40 enum class ObserverType { ACTIVE, PENDING }; |
41 | 41 |
42 static scoped_refptr<LayerAnimationController> Create(int id); | 42 static scoped_refptr<LayerAnimationController> Create(int id); |
43 | 43 |
44 int id() const { return id_; } | 44 int id() const { return id_; } |
45 | 45 |
46 void AddAnimation(scoped_ptr<Animation> animation); | 46 void AddAnimation(scoped_ptr<Animation> animation); |
47 void PauseAnimation(int animation_id, base::TimeDelta time_offset); | 47 void PauseAnimation(int animation_id, base::TimeDelta time_offset); |
48 void RemoveAnimation(int animation_id); | 48 void RemoveAnimation(int animation_id); |
49 void AbortAnimation(int animation_id); | 49 void AbortAnimation(int animation_id); |
50 void AbortAnimations(Animation::TargetProperty target_property); | 50 void AbortAnimations(AnimationTargetProperty target_property); |
51 | 51 |
52 // Ensures that the list of active animations on the main thread and the impl | 52 // Ensures that the list of active animations on the main thread and the impl |
53 // thread are kept in sync. This function does not take ownership of the impl | 53 // thread are kept in sync. This function does not take ownership of the impl |
54 // thread controller. This method is virtual for testing. | 54 // thread controller. This method is virtual for testing. |
55 virtual void PushAnimationUpdatesTo( | 55 virtual void PushAnimationUpdatesTo( |
56 LayerAnimationController* controller_impl); | 56 LayerAnimationController* controller_impl); |
57 | 57 |
58 void Animate(base::TimeTicks monotonic_time); | 58 void Animate(base::TimeTicks monotonic_time); |
59 void AccumulatePropertyUpdates(base::TimeTicks monotonic_time, | 59 void AccumulatePropertyUpdates(base::TimeTicks monotonic_time, |
60 AnimationEvents* events); | 60 AnimationEvents* events); |
61 | 61 |
62 void UpdateState(bool start_ready_animations, AnimationEvents* events); | 62 void UpdateState(bool start_ready_animations, AnimationEvents* events); |
63 | 63 |
64 // Make animations affect active observers if and only if they affect | 64 // Make animations affect active observers if and only if they affect |
65 // pending observers. Any animations that no longer affect any observers | 65 // pending observers. Any animations that no longer affect any observers |
66 // are deleted. | 66 // are deleted. |
67 void ActivateAnimations(); | 67 void ActivateAnimations(); |
68 | 68 |
69 // Returns the active animation animating the given property that is either | 69 // Returns the active animation animating the given property that is either |
70 // running, or is next to run, if such an animation exists. | 70 // running, or is next to run, if such an animation exists. |
71 Animation* GetAnimation(Animation::TargetProperty target_property) const; | 71 Animation* GetAnimation(AnimationTargetProperty target_property) const; |
72 | 72 |
73 // Returns the active animation for the given unique animation id. | 73 // Returns the active animation for the given unique animation id. |
74 Animation* GetAnimationById(int animation_id) const; | 74 Animation* GetAnimationById(int animation_id) const; |
75 | 75 |
76 // Returns true if there are any animations that have neither finished nor | 76 // Returns true if there are any animations that have neither finished nor |
77 // aborted. | 77 // aborted. |
78 bool HasActiveAnimation() const; | 78 bool HasActiveAnimation() const; |
79 | 79 |
80 // Returns true if there are any animations at all to process. | 80 // Returns true if there are any animations at all to process. |
81 bool has_any_animation() const { return !animations_.empty(); } | 81 bool has_any_animation() const { return !animations_.empty(); } |
82 | 82 |
83 // Returns true if there is an animation that is either currently animating | 83 // Returns true if there is an animation that is either currently animating |
84 // the given property or scheduled to animate this property in the future, and | 84 // the given property or scheduled to animate this property in the future, and |
85 // that affects the given observer type. | 85 // that affects the given observer type. |
86 bool IsPotentiallyAnimatingProperty(Animation::TargetProperty target_property, | 86 bool IsPotentiallyAnimatingProperty(AnimationTargetProperty target_property, |
87 ObserverType observer_type) const; | 87 ObserverType observer_type) const; |
88 | 88 |
89 // Returns true if there is an animation that is currently animating the given | 89 // Returns true if there is an animation that is currently animating the given |
90 // property and that affects the given observer type. | 90 // property and that affects the given observer type. |
91 bool IsCurrentlyAnimatingProperty(Animation::TargetProperty target_property, | 91 bool IsCurrentlyAnimatingProperty(AnimationTargetProperty target_property, |
92 ObserverType observer_type) const; | 92 ObserverType observer_type) const; |
93 | 93 |
94 void SetAnimationRegistrar(AnimationRegistrar* registrar); | 94 void SetAnimationRegistrar(AnimationRegistrar* registrar); |
95 AnimationRegistrar* animation_registrar() { return registrar_; } | 95 AnimationRegistrar* animation_registrar() { return registrar_; } |
96 | 96 |
97 void NotifyAnimationStarted(const AnimationEvent& event); | 97 void NotifyAnimationStarted(const AnimationEvent& event); |
98 void NotifyAnimationFinished(const AnimationEvent& event); | 98 void NotifyAnimationFinished(const AnimationEvent& event); |
99 void NotifyAnimationAborted(const AnimationEvent& event); | 99 void NotifyAnimationAborted(const AnimationEvent& event); |
100 void NotifyAnimationPropertyUpdate(const AnimationEvent& event); | 100 void NotifyAnimationPropertyUpdate(const AnimationEvent& event); |
101 | 101 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 return needs_to_start_animations_; | 168 return needs_to_start_animations_; |
169 } | 169 } |
170 | 170 |
171 protected: | 171 protected: |
172 friend class base::RefCounted<LayerAnimationController>; | 172 friend class base::RefCounted<LayerAnimationController>; |
173 | 173 |
174 explicit LayerAnimationController(int id); | 174 explicit LayerAnimationController(int id); |
175 virtual ~LayerAnimationController(); | 175 virtual ~LayerAnimationController(); |
176 | 176 |
177 private: | 177 private: |
178 using TargetProperties = std::unordered_set<int>; | 178 using TargetProperties = |
179 std::unordered_set<AnimationTargetProperty, EnumClassHash>; | |
esprehn
2016/02/17 00:40:11
This could just be a bitset right? there's like 5
| |
179 | 180 |
180 void PushNewAnimationsToImplThread( | 181 void PushNewAnimationsToImplThread( |
181 LayerAnimationController* controller_impl) const; | 182 LayerAnimationController* controller_impl) const; |
182 void MarkAbortedAnimationsForDeletion( | 183 void MarkAbortedAnimationsForDeletion( |
183 LayerAnimationController* controller_impl) const; | 184 LayerAnimationController* controller_impl) const; |
184 void RemoveAnimationsCompletedOnMainThread( | 185 void RemoveAnimationsCompletedOnMainThread( |
185 LayerAnimationController* controller_impl) const; | 186 LayerAnimationController* controller_impl) const; |
186 void PushPropertiesToImplThread(LayerAnimationController* controller_impl); | 187 void PushPropertiesToImplThread(LayerAnimationController* controller_impl); |
187 | 188 |
188 void StartAnimations(base::TimeTicks monotonic_time); | 189 void StartAnimations(base::TimeTicks monotonic_time); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 248 |
248 bool potentially_animating_transform_for_active_observers_; | 249 bool potentially_animating_transform_for_active_observers_; |
249 bool potentially_animating_transform_for_pending_observers_; | 250 bool potentially_animating_transform_for_pending_observers_; |
250 | 251 |
251 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); | 252 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); |
252 }; | 253 }; |
253 | 254 |
254 } // namespace cc | 255 } // namespace cc |
255 | 256 |
256 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ | 257 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ |
OLD | NEW |