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_LAYER_ANIMATION_CONTROLLER_H_ | 5 #ifndef CC_LAYER_ANIMATION_CONTROLLER_H_ |
6 #define CC_LAYER_ANIMATION_CONTROLLER_H_ | 6 #define CC_LAYER_ANIMATION_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class Animation; | 26 class Animation; |
27 class AnimationRegistrar; | 27 class AnimationRegistrar; |
28 class KeyframeValueList; | 28 class KeyframeValueList; |
29 class LayerAnimationValueObserver; | 29 class LayerAnimationValueObserver; |
30 | 30 |
31 class CC_EXPORT LayerAnimationController | 31 class CC_EXPORT LayerAnimationController |
32 : public base::RefCounted<LayerAnimationController>, | 32 : public base::RefCounted<LayerAnimationController>, |
33 public LayerAnimationEventObserver { | 33 public LayerAnimationEventObserver { |
34 public: | 34 public: |
| 35 // Controllers belonging to orphan layers begin in the |
| 36 // NeverWaitedForLayout state. Once an animation is added to such |
| 37 // a controller, it moves into the WaitingForLayout state, and then moves |
| 38 // into the WaitedForLayout state after the next layout. |
| 39 enum OrphanWaitStatus { |
| 40 NeverWaitedForLayout = 0, |
| 41 WaitingForLayout, |
| 42 WaitedForLayout |
| 43 }; |
| 44 |
35 static scoped_refptr<LayerAnimationController> create(int id); | 45 static scoped_refptr<LayerAnimationController> create(int id); |
36 | 46 |
37 int id() const { return m_id; } | 47 int id() const { return m_id; } |
38 | 48 |
39 // These methods are virtual for testing. | 49 // These methods are virtual for testing. |
40 virtual void addAnimation(scoped_ptr<Animation>); | 50 virtual void addAnimation(scoped_ptr<Animation>); |
41 virtual void pauseAnimation(int animationId, double timeOffset); | 51 virtual void pauseAnimation(int animationId, double timeOffset); |
42 virtual void removeAnimation(int animationId); | 52 virtual void removeAnimation(int animationId); |
43 virtual void removeAnimation(int animationId, Animation::TargetProperty); | 53 virtual void removeAnimation(int animationId, Animation::TargetProperty); |
44 virtual void suspendAnimations(double monotonicTime); | 54 virtual void suspendAnimations(double monotonicTime); |
(...skipping 25 matching lines...) Expand all Loading... |
70 | 80 |
71 // This is called in response to an animation being started on the impl thre
ad. This | 81 // This is called in response to an animation being started on the impl thre
ad. This |
72 // function updates the corresponding main thread animation's start time. | 82 // function updates the corresponding main thread animation's start time. |
73 virtual void OnAnimationStarted(const AnimationEvent&) OVERRIDE; | 83 virtual void OnAnimationStarted(const AnimationEvent&) OVERRIDE; |
74 | 84 |
75 // If a sync is forced, then the next time animation updates are pushed to t
he impl | 85 // If a sync is forced, then the next time animation updates are pushed to t
he impl |
76 // thread, all animations will be transferred. | 86 // thread, all animations will be transferred. |
77 void setForceSync() { m_forceSync = true; } | 87 void setForceSync() { m_forceSync = true; } |
78 | 88 |
79 void setAnimationRegistrar(AnimationRegistrar*); | 89 void setAnimationRegistrar(AnimationRegistrar*); |
| 90 AnimationRegistrar* animationRegistrar() { return m_registrar; } |
80 | 91 |
81 void addObserver(LayerAnimationValueObserver*); | 92 void addObserver(LayerAnimationValueObserver*); |
82 void removeObserver(LayerAnimationValueObserver*); | 93 void removeObserver(LayerAnimationValueObserver*); |
83 | 94 |
| 95 bool hasNonOrphanedObserver(); |
| 96 |
| 97 void setOrphanWaitStatus(OrphanWaitStatus status) { m_orphanWaitStatus = sta
tus; } |
| 98 OrphanWaitStatus orphanWaitStatus() const { return m_orphanWaitStatus; } |
| 99 |
84 protected: | 100 protected: |
85 friend class base::RefCounted<LayerAnimationController>; | 101 friend class base::RefCounted<LayerAnimationController>; |
86 | 102 |
87 LayerAnimationController(int id); | 103 LayerAnimationController(int id); |
88 virtual ~LayerAnimationController(); | 104 virtual ~LayerAnimationController(); |
89 | 105 |
90 private: | 106 private: |
91 typedef base::hash_set<int> TargetProperties; | 107 typedef base::hash_set<int> TargetProperties; |
92 | 108 |
93 void pushNewAnimationsToImplThread(LayerAnimationController*) const; | 109 void pushNewAnimationsToImplThread(LayerAnimationController*) const; |
(...skipping 22 matching lines...) Expand all Loading... |
116 | 132 |
117 AnimationRegistrar* m_registrar; | 133 AnimationRegistrar* m_registrar; |
118 int m_id; | 134 int m_id; |
119 ScopedPtrVector<Animation> m_activeAnimations; | 135 ScopedPtrVector<Animation> m_activeAnimations; |
120 | 136 |
121 // This is used to ensure that we don't spam the registrar. | 137 // This is used to ensure that we don't spam the registrar. |
122 bool m_isActive; | 138 bool m_isActive; |
123 | 139 |
124 ObserverList<LayerAnimationValueObserver> m_observers; | 140 ObserverList<LayerAnimationValueObserver> m_observers; |
125 | 141 |
| 142 OrphanWaitStatus m_orphanWaitStatus; |
| 143 |
126 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); | 144 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); |
127 }; | 145 }; |
128 | 146 |
129 } // namespace cc | 147 } // namespace cc |
130 | 148 |
131 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_ | 149 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_ |
OLD | NEW |