Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: cc/layer_animation_controller.h

Issue 12517003: cc: Chromify the Animation and LayerAnimationController classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer.cc ('k') | cc/layer_animation_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "cc/animation_events.h" 14 #include "cc/animation_events.h"
15 #include "cc/cc_export.h" 15 #include "cc/cc_export.h"
16 #include "cc/layer_animation_event_observer.h" 16 #include "cc/layer_animation_event_observer.h"
17 #include "cc/scoped_ptr_vector.h" 17 #include "cc/scoped_ptr_vector.h"
18 #include "ui/gfx/transform.h" 18 #include "ui/gfx/transform.h"
19 19
20 namespace gfx { 20 namespace gfx { class Transform; }
21 class Transform;
22 }
23 21
24 namespace cc { 22 namespace cc {
25 23
26 class Animation; 24 class Animation;
27 class AnimationRegistrar; 25 class AnimationRegistrar;
28 class KeyframeValueList; 26 class KeyframeValueList;
29 class LayerAnimationValueObserver; 27 class LayerAnimationValueObserver;
30 28
31 class CC_EXPORT LayerAnimationController 29 class CC_EXPORT LayerAnimationController
32 : public base::RefCounted<LayerAnimationController>, 30 : public base::RefCounted<LayerAnimationController>,
33 public LayerAnimationEventObserver { 31 public LayerAnimationEventObserver {
34 public: 32 public:
35 static scoped_refptr<LayerAnimationController> create(int id); 33 static scoped_refptr<LayerAnimationController> Create(int id);
36 34
37 int id() const { return m_id; } 35 int id() const { return id_; }
38 36
39 // These methods are virtual for testing. 37 // These methods are virtual for testing.
40 virtual void addAnimation(scoped_ptr<Animation>); 38 virtual void AddAnimation(scoped_ptr<Animation> animation);
41 virtual void pauseAnimation(int animationId, double timeOffset); 39 virtual void PauseAnimation(int animation_id, double time_offset);
42 virtual void removeAnimation(int animationId); 40 virtual void RemoveAnimation(int animation_id);
43 virtual void removeAnimation(int animationId, Animation::TargetProperty); 41 virtual void RemoveAnimation(int animation_id,
44 virtual void suspendAnimations(double monotonicTime); 42 Animation::TargetProperty target_property);
45 virtual void resumeAnimations(double monotonicTime); 43 virtual void SuspendAnimations(double monotonic_time);
44 virtual void ResumeAnimations(double monotonic_time);
46 45
47 // Ensures that the list of active animations on the main thread and the imp l thread 46 // Ensures that the list of active animations on the main thread and the impl
48 // are kept in sync. This function does not take ownership of the impl threa d controller. 47 // thread are kept in sync. This function does not take ownership of the impl
49 virtual void pushAnimationUpdatesTo(LayerAnimationController*); 48 // thread controller.
49 virtual void PushAnimationUpdatesTo(
50 LayerAnimationController* controller_impl);
50 51
51 void animate(double monotonicTime); 52 void Animate(double monotonic_time);
52 void accumulatePropertyUpdates(double monotonicTime, AnimationEventsVector*) ; 53 void AccumulatePropertyUpdates(double monotonic_time,
53 void updateState(AnimationEventsVector*); 54 AnimationEventsVector* events);
55 void UpdateState(AnimationEventsVector* events);
54 56
55 // Returns the active animation in the given group, animating the given prop erty, if such an 57 // Returns the active animation in the given group, animating the given
56 // animation exists. 58 // property, if such an animation exists.
57 Animation* getAnimation(int groupId, Animation::TargetProperty) const; 59 Animation* GetAnimation(int group_id,
60 Animation::TargetProperty target_property) const;
58 61
59 // Returns the active animation animating the given property that is either running, or is 62 // Returns the active animation animating the given property that is either
60 // next to run, if such an animation exists. 63 // running, or is next to run, if such an animation exists.
61 Animation* getAnimation(Animation::TargetProperty) const; 64 Animation* GetAnimation(Animation::TargetProperty target_property) const;
62 65
63 // Returns true if there are any animations that have neither finished nor a borted. 66 // Returns true if there are any animations that have neither finished nor
64 bool hasActiveAnimation() const; 67 // aborted.
68 bool HasActiveAnimation() const;
65 69
66 // Returns true if there are any animations at all to process. 70 // Returns true if there are any animations at all to process.
67 bool hasAnyAnimation() const { return !m_activeAnimations.empty(); } 71 bool has_any_animation() const { return !active_animations_.empty(); }
68 72
69 // Returns true if there is an animation currently animating the given prope rty, or 73 // Returns true if there is an animation currently animating the given
70 // if there is an animation scheduled to animate this property in the future . 74 // property, or if there is an animation scheduled to animate this property in
71 bool isAnimatingProperty(Animation::TargetProperty) const; 75 // the future.
76 bool IsAnimatingProperty(Animation::TargetProperty target_property) const;
72 77
73 // This is called in response to an animation being started on the impl thre ad. This 78 // This is called in response to an animation being started on the impl
74 // function updates the corresponding main thread animation's start time. 79 // thread. This function updates the corresponding main thread animation's
75 virtual void OnAnimationStarted(const AnimationEvent&) OVERRIDE; 80 // start time.
81 virtual void OnAnimationStarted(const AnimationEvent& event) OVERRIDE;
76 82
77 // If a sync is forced, then the next time animation updates are pushed to t he impl 83 // If a sync is forced, then the next time animation updates are pushed to the
78 // thread, all animations will be transferred. 84 // impl thread, all animations will be transferred.
79 void setForceSync() { m_forceSync = true; } 85 void set_force_sync() { force_sync_ = true; }
80 86
81 void setAnimationRegistrar(AnimationRegistrar*); 87 void SetAnimationRegistrar(AnimationRegistrar* registrar);
82 AnimationRegistrar* animationRegistrar() { return m_registrar; } 88 AnimationRegistrar* animation_registrar() { return registrar_; }
83 89
84 void addObserver(LayerAnimationValueObserver*); 90 void AddObserver(LayerAnimationValueObserver* observer);
85 void removeObserver(LayerAnimationValueObserver*); 91 void RemoveObserver(LayerAnimationValueObserver* observer);
86 92
87 protected: 93 protected:
88 friend class base::RefCounted<LayerAnimationController>; 94 friend class base::RefCounted<LayerAnimationController>;
89 95
90 LayerAnimationController(int id); 96 LayerAnimationController(int id);
91 virtual ~LayerAnimationController(); 97 virtual ~LayerAnimationController();
92 98
93 private: 99 private:
94 typedef base::hash_set<int> TargetProperties; 100 typedef base::hash_set<int> TargetProperties;
95 101
96 void pushNewAnimationsToImplThread(LayerAnimationController*) const; 102 void PushNewAnimationsToImplThread(
97 void removeAnimationsCompletedOnMainThread(LayerAnimationController*) const; 103 LayerAnimationController* controller_impl) const;
98 void pushPropertiesToImplThread(LayerAnimationController*) const; 104 void RemoveAnimationsCompletedOnMainThread(
99 void replaceImplThreadAnimations(LayerAnimationController*) const; 105 LayerAnimationController* controller_impl) const;
106 void PushPropertiesToImplThread(
107 LayerAnimationController* controller_impl) const;
108 void ReplaceImplThreadAnimations(
109 LayerAnimationController* controller_impl) const;
100 110
101 void startAnimationsWaitingForNextTick(double monotonicTime); 111 void StartAnimationsWaitingForNextTick(double monotonic_time);
102 void startAnimationsWaitingForStartTime(double monotonicTime); 112 void StartAnimationsWaitingForStartTime(double monotonic_time);
103 void startAnimationsWaitingForTargetAvailability(double monotonicTime); 113 void StartAnimationsWaitingForTargetAvailability(double monotonic_time);
104 void resolveConflicts(double monotonicTime); 114 void ResolveConflicts(double monotonic_time);
105 void promoteStartedAnimations(double monotonicTime, AnimationEventsVector*); 115 void PromoteStartedAnimations(double monotonic_time,
106 void markFinishedAnimations(double monotonicTime); 116 AnimationEventsVector* events);
107 void markAnimationsForDeletion(double monotonicTime, AnimationEventsVector*) ; 117 void MarkFinishedAnimations(double monotonic_time);
108 void purgeAnimationsMarkedForDeletion(); 118 void MarkAnimationsForDeletion(double monotonic_time,
119 AnimationEventsVector* events);
120 void PurgeAnimationsMarkedForDeletion();
109 121
110 void tickAnimations(double monotonicTime); 122 void TickAnimations(double monotonic_time);
111 123
112 void updateActivation(bool force = false); 124 enum UpdateActivationType {
125 NormalActivation,
126 ForceActivation
127 };
128 void UpdateActivation(UpdateActivationType type);
113 129
114 void notifyObserversOpacityAnimated(float opacity); 130 void NotifyObserversOpacityAnimated(float opacity);
115 void notifyObserversTransformAnimated(const gfx::Transform& transform); 131 void NotifyObserversTransformAnimated(const gfx::Transform& transform);
116 132
117 bool hasActiveObserver(); 133 bool HasActiveObserver();
118 134
119 // If this is true, we force a sync to the impl thread. 135 // If this is true, we force a sync to the impl thread.
120 bool m_forceSync; 136 bool force_sync_;
121 137
122 AnimationRegistrar* m_registrar; 138 AnimationRegistrar* registrar_;
123 int m_id; 139 int id_;
124 ScopedPtrVector<Animation> m_activeAnimations; 140 ScopedPtrVector<Animation> active_animations_;
125 141
126 // This is used to ensure that we don't spam the registrar. 142 // This is used to ensure that we don't spam the registrar.
127 bool m_isActive; 143 bool is_active_;
128 144
129 double m_lastTickTime; 145 double last_tick_time_;
130 146
131 ObserverList<LayerAnimationValueObserver> m_observers; 147 ObserverList<LayerAnimationValueObserver> observers_;
132 148
133 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); 149 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController);
134 }; 150 };
135 151
136 } // namespace cc 152 } // namespace cc
137 153
138 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_ 154 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « cc/layer.cc ('k') | cc/layer_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698