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 19 matching lines...) Expand all Loading... |
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 static scoped_refptr<LayerAnimationController> create(int id); | 35 static scoped_refptr<LayerAnimationController> create(int id); |
36 | 36 |
37 int id() const { return m_id; } | 37 int id() const { return m_id; } |
38 | 38 |
39 // These methods are virtual for testing. | 39 // These methods are virtual for testing. |
40 virtual void addAnimation(scoped_ptr<ActiveAnimation>); | 40 virtual void addAnimation(scoped_ptr<Animation>); |
41 virtual void pauseAnimation(int animationId, double timeOffset); | 41 virtual void pauseAnimation(int animationId, double timeOffset); |
42 virtual void removeAnimation(int animationId); | 42 virtual void removeAnimation(int animationId); |
43 virtual void removeAnimation(int animationId, ActiveAnimation::TargetPropert
y); | 43 virtual void removeAnimation(int animationId, Animation::TargetProperty); |
44 virtual void suspendAnimations(double monotonicTime); | 44 virtual void suspendAnimations(double monotonicTime); |
45 virtual void resumeAnimations(double monotonicTime); | 45 virtual void resumeAnimations(double monotonicTime); |
46 | 46 |
47 // Ensures that the list of active animations on the main thread and the imp
l thread | 47 // Ensures that the list of active animations on the main thread and the imp
l thread |
48 // are kept in sync. This function does not take ownership of the impl threa
d controller. | 48 // are kept in sync. This function does not take ownership of the impl threa
d controller. |
49 virtual void pushAnimationUpdatesTo(LayerAnimationController*); | 49 virtual void pushAnimationUpdatesTo(LayerAnimationController*); |
50 | 50 |
51 void animate(double monotonicTime, AnimationEventsVector*); | 51 void animate(double monotonicTime, AnimationEventsVector*); |
52 | 52 |
53 // Returns the active animation in the given group, animating the given prop
erty, if such an | 53 // Returns the active animation in the given group, animating the given prop
erty, if such an |
54 // animation exists. | 54 // animation exists. |
55 ActiveAnimation* getActiveAnimation(int groupId, ActiveAnimation::TargetProp
erty) const; | 55 Animation* getAnimation(int groupId, Animation::TargetProperty) const; |
56 | 56 |
57 // Returns the active animation animating the given property that is either
running, or is | 57 // Returns the active animation animating the given property that is either
running, or is |
58 // next to run, if such an animation exists. | 58 // next to run, if such an animation exists. |
59 ActiveAnimation* getActiveAnimation(ActiveAnimation::TargetProperty) const; | 59 Animation* getAnimation(Animation::TargetProperty) const; |
60 | 60 |
61 // Returns true if there are any animations that have neither finished nor a
borted. | 61 // Returns true if there are any animations that have neither finished nor a
borted. |
62 bool hasActiveAnimation() const; | 62 bool hasActiveAnimation() const; |
63 | 63 |
64 // Returns true if there are any animations at all to process. | 64 // Returns true if there are any animations at all to process. |
65 bool hasAnyAnimation() const { return !m_activeAnimations.isEmpty(); } | 65 bool hasAnyAnimation() const { return !m_activeAnimations.isEmpty(); } |
66 | 66 |
67 // Returns true if there is an animation currently animating the given prope
rty, or | 67 // Returns true if there is an animation currently animating the given prope
rty, or |
68 // if there is an animation scheduled to animate this property in the future
. | 68 // if there is an animation scheduled to animate this property in the future
. |
69 bool isAnimatingProperty(ActiveAnimation::TargetProperty) const; | 69 bool isAnimatingProperty(Animation::TargetProperty) const; |
70 | 70 |
71 // This is called in response to an animation being started on the impl thre
ad. This | 71 // 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. | 72 // function updates the corresponding main thread animation's start time. |
73 virtual void OnAnimationStarted(const AnimationEvent&) OVERRIDE; | 73 virtual void OnAnimationStarted(const AnimationEvent&) OVERRIDE; |
74 | 74 |
75 // If a sync is forced, then the next time animation updates are pushed to t
he impl | 75 // If a sync is forced, then the next time animation updates are pushed to t
he impl |
76 // thread, all animations will be transferred. | 76 // thread, all animations will be transferred. |
77 void setForceSync() { m_forceSync = true; } | 77 void setForceSync() { m_forceSync = true; } |
78 | 78 |
79 void setAnimationRegistrar(AnimationRegistrar*); | 79 void setAnimationRegistrar(AnimationRegistrar*); |
(...skipping 27 matching lines...) Expand all Loading... |
107 void updateActivation(bool force = false); | 107 void updateActivation(bool force = false); |
108 | 108 |
109 void notifyObserversOpacityAnimated(float opacity); | 109 void notifyObserversOpacityAnimated(float opacity); |
110 void notifyObserversTransformAnimated(const gfx::Transform& transform); | 110 void notifyObserversTransformAnimated(const gfx::Transform& transform); |
111 | 111 |
112 // If this is true, we force a sync to the impl thread. | 112 // If this is true, we force a sync to the impl thread. |
113 bool m_forceSync; | 113 bool m_forceSync; |
114 | 114 |
115 AnimationRegistrar* m_registrar; | 115 AnimationRegistrar* m_registrar; |
116 int m_id; | 116 int m_id; |
117 ScopedPtrVector<ActiveAnimation> m_activeAnimations; | 117 ScopedPtrVector<Animation> m_activeAnimations; |
118 | 118 |
119 // This is used to ensure that we don't spam the registrar. | 119 // This is used to ensure that we don't spam the registrar. |
120 bool m_isActive; | 120 bool m_isActive; |
121 | 121 |
122 ObserverList<LayerAnimationValueObserver> m_observers; | 122 ObserverList<LayerAnimationValueObserver> m_observers; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); | 124 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); |
125 }; | 125 }; |
126 | 126 |
127 } // namespace cc | 127 } // namespace cc |
128 | 128 |
129 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_ | 129 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_ |
OLD | NEW |