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 CCLayerAnimationController_h | 5 #ifndef CCLayerAnimationController_h |
6 #define CCLayerAnimationController_h | 6 #define CCLayerAnimationController_h |
7 | 7 |
8 #include "CCAnimationEvents.h" | 8 #include "CCAnimationEvents.h" |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "cc/scoped_ptr_vector.h" | 13 #include "cc/scoped_ptr_vector.h" |
14 | 14 |
15 namespace WebKit { | 15 namespace WebKit { |
16 class WebTransformationMatrix; | 16 class WebTransformationMatrix; |
17 } | 17 } |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class Animation; | 21 class Animation; |
22 class IntSize; | 22 class IntSize; |
23 class KeyframeValueList; | 23 class KeyframeValueList; |
24 | 24 |
25 class CCLayerAnimationControllerClient { | 25 class LayerAnimationControllerClient { |
26 public: | 26 public: |
27 virtual ~CCLayerAnimationControllerClient() { } | 27 virtual ~LayerAnimationControllerClient() { } |
28 | 28 |
29 virtual int id() const = 0; | 29 virtual int id() const = 0; |
30 virtual void setOpacityFromAnimation(float) = 0; | 30 virtual void setOpacityFromAnimation(float) = 0; |
31 virtual float opacity() const = 0; | 31 virtual float opacity() const = 0; |
32 virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix
&) = 0; | 32 virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix
&) = 0; |
33 virtual const WebKit::WebTransformationMatrix& transform() const = 0; | 33 virtual const WebKit::WebTransformationMatrix& transform() const = 0; |
34 }; | 34 }; |
35 | 35 |
36 class CCLayerAnimationController { | 36 class LayerAnimationController { |
37 public: | 37 public: |
38 static scoped_ptr<CCLayerAnimationController> create(CCLayerAnimationControl
lerClient*); | 38 static scoped_ptr<LayerAnimationController> create(LayerAnimationControllerC
lient*); |
39 | 39 |
40 virtual ~CCLayerAnimationController(); | 40 virtual ~LayerAnimationController(); |
41 | 41 |
42 // These methods are virtual for testing. | 42 // These methods are virtual for testing. |
43 virtual void addAnimation(scoped_ptr<CCActiveAnimation>); | 43 virtual void addAnimation(scoped_ptr<ActiveAnimation>); |
44 virtual void pauseAnimation(int animationId, double timeOffset); | 44 virtual void pauseAnimation(int animationId, double timeOffset); |
45 virtual void removeAnimation(int animationId); | 45 virtual void removeAnimation(int animationId); |
46 virtual void removeAnimation(int animationId, CCActiveAnimation::TargetPrope
rty); | 46 virtual void removeAnimation(int animationId, ActiveAnimation::TargetPropert
y); |
47 virtual void suspendAnimations(double monotonicTime); | 47 virtual void suspendAnimations(double monotonicTime); |
48 virtual void resumeAnimations(double monotonicTime); | 48 virtual void resumeAnimations(double monotonicTime); |
49 | 49 |
50 // Ensures that the list of active animations on the main thread and the imp
l thread | 50 // Ensures that the list of active animations on the main thread and the imp
l thread |
51 // are kept in sync. This function does not take ownership of the impl threa
d controller. | 51 // are kept in sync. This function does not take ownership of the impl threa
d controller. |
52 virtual void pushAnimationUpdatesTo(CCLayerAnimationController*); | 52 virtual void pushAnimationUpdatesTo(LayerAnimationController*); |
53 | 53 |
54 void animate(double monotonicTime, CCAnimationEventsVector*); | 54 void animate(double monotonicTime, AnimationEventsVector*); |
55 | 55 |
56 // Returns the active animation in the given group, animating the given prop
erty, if such an | 56 // Returns the active animation in the given group, animating the given prop
erty, if such an |
57 // animation exists. | 57 // animation exists. |
58 CCActiveAnimation* getActiveAnimation(int groupId, CCActiveAnimation::Target
Property) const; | 58 ActiveAnimation* getActiveAnimation(int groupId, ActiveAnimation::TargetProp
erty) const; |
59 | 59 |
60 // Returns the active animation animating the given property that is either
running, or is | 60 // Returns the active animation animating the given property that is either
running, or is |
61 // next to run, if such an animation exists. | 61 // next to run, if such an animation exists. |
62 CCActiveAnimation* getActiveAnimation(CCActiveAnimation::TargetProperty) con
st; | 62 ActiveAnimation* getActiveAnimation(ActiveAnimation::TargetProperty) const; |
63 | 63 |
64 // Returns true if there are any animations that have neither finished nor a
borted. | 64 // Returns true if there are any animations that have neither finished nor a
borted. |
65 bool hasActiveAnimation() const; | 65 bool hasActiveAnimation() const; |
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(CCActiveAnimation::TargetProperty) const; | 69 bool isAnimatingProperty(ActiveAnimation::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 void notifyAnimationStarted(const CCAnimationEvent&); | 73 void notifyAnimationStarted(const AnimationEvent&); |
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 setClient(CCLayerAnimationControllerClient*); | 79 void setClient(LayerAnimationControllerClient*); |
80 | 80 |
81 protected: | 81 protected: |
82 explicit CCLayerAnimationController(CCLayerAnimationControllerClient*); | 82 explicit LayerAnimationController(LayerAnimationControllerClient*); |
83 | 83 |
84 private: | 84 private: |
85 typedef base::hash_set<int> TargetProperties; | 85 typedef base::hash_set<int> TargetProperties; |
86 | 86 |
87 void pushNewAnimationsToImplThread(CCLayerAnimationController*) const; | 87 void pushNewAnimationsToImplThread(LayerAnimationController*) const; |
88 void removeAnimationsCompletedOnMainThread(CCLayerAnimationController*) cons
t; | 88 void removeAnimationsCompletedOnMainThread(LayerAnimationController*) const; |
89 void pushPropertiesToImplThread(CCLayerAnimationController*) const; | 89 void pushPropertiesToImplThread(LayerAnimationController*) const; |
90 void replaceImplThreadAnimations(CCLayerAnimationController*) const; | 90 void replaceImplThreadAnimations(LayerAnimationController*) const; |
91 | 91 |
92 void startAnimationsWaitingForNextTick(double monotonicTime, CCAnimationEven
tsVector*); | 92 void startAnimationsWaitingForNextTick(double monotonicTime, AnimationEvents
Vector*); |
93 void startAnimationsWaitingForStartTime(double monotonicTime, CCAnimationEve
ntsVector*); | 93 void startAnimationsWaitingForStartTime(double monotonicTime, AnimationEvent
sVector*); |
94 void startAnimationsWaitingForTargetAvailability(double monotonicTime, CCAni
mationEventsVector*); | 94 void startAnimationsWaitingForTargetAvailability(double monotonicTime, Anima
tionEventsVector*); |
95 void resolveConflicts(double monotonicTime); | 95 void resolveConflicts(double monotonicTime); |
96 void markAnimationsForDeletion(double monotonicTime, CCAnimationEventsVector
*); | 96 void markAnimationsForDeletion(double monotonicTime, AnimationEventsVector*)
; |
97 void purgeAnimationsMarkedForDeletion(); | 97 void purgeAnimationsMarkedForDeletion(); |
98 | 98 |
99 void tickAnimations(double monotonicTime); | 99 void tickAnimations(double monotonicTime); |
100 | 100 |
101 // If this is true, we force a sync to the impl thread. | 101 // If this is true, we force a sync to the impl thread. |
102 bool m_forceSync; | 102 bool m_forceSync; |
103 | 103 |
104 CCLayerAnimationControllerClient* m_client; | 104 LayerAnimationControllerClient* m_client; |
105 ScopedPtrVector<CCActiveAnimation> m_activeAnimations; | 105 ScopedPtrVector<ActiveAnimation> m_activeAnimations; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(CCLayerAnimationController); | 107 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); |
108 }; | 108 }; |
109 | 109 |
110 } // namespace cc | 110 } // namespace cc |
111 | 111 |
112 #endif // CCLayerAnimationController_h | 112 #endif // CCLayerAnimationController_h |
OLD | NEW |