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

Side by Side Diff: cc/animation/layer_animation_controller.h

Issue 13465014: LayerTreeHost::SetAnimationEvents should use AnimationRegistrar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 8 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/animation/animation.cc ('k') | cc/animation/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_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 "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/animation_events.h" 14 #include "cc/animation/animation_events.h"
15 #include "cc/animation/layer_animation_event_observer.h" 15 #include "cc/animation/layer_animation_event_observer.h"
16 #include "cc/base/cc_export.h" 16 #include "cc/base/cc_export.h"
17 #include "cc/base/scoped_ptr_vector.h" 17 #include "cc/base/scoped_ptr_vector.h"
18 #include "ui/gfx/transform.h" 18 #include "ui/gfx/transform.h"
19 19
20 namespace WebKit {
21 class WebAnimationDelegate;
22 }
23
20 namespace gfx { class Transform; } 24 namespace gfx { class Transform; }
21 25
22 namespace cc { 26 namespace cc {
23 27
24 class Animation; 28 class Animation;
25 class AnimationRegistrar; 29 class AnimationRegistrar;
26 class KeyframeValueList; 30 class KeyframeValueList;
27 class LayerAnimationValueObserver; 31 class LayerAnimationValueObserver;
28 32
29 class CC_EXPORT LayerAnimationController 33 class CC_EXPORT LayerAnimationController
30 : public base::RefCounted<LayerAnimationController>, 34 : public base::RefCounted<LayerAnimationController> {
31 public LayerAnimationEventObserver {
32 public: 35 public:
33 static scoped_refptr<LayerAnimationController> Create(int id); 36 static scoped_refptr<LayerAnimationController> Create(int id);
34 37
35 int id() const { return id_; } 38 int id() const { return id_; }
36 39
37 // These methods are virtual for testing. 40 // These methods are virtual for testing.
38 virtual void AddAnimation(scoped_ptr<Animation> animation); 41 virtual void AddAnimation(scoped_ptr<Animation> animation);
39 virtual void PauseAnimation(int animation_id, double time_offset); 42 virtual void PauseAnimation(int animation_id, double time_offset);
40 virtual void RemoveAnimation(int animation_id); 43 virtual void RemoveAnimation(int animation_id);
41 virtual void RemoveAnimation(int animation_id, 44 virtual void RemoveAnimation(int animation_id,
42 Animation::TargetProperty target_property); 45 Animation::TargetProperty target_property);
43 virtual void SuspendAnimations(double monotonic_time); 46 virtual void SuspendAnimations(double monotonic_time);
44 virtual void ResumeAnimations(double monotonic_time); 47 virtual void ResumeAnimations(double monotonic_time);
45 48
46 // Ensures that the list of active animations on the main thread and the impl 49 // Ensures that the list of active animations on the main thread and the impl
47 // thread are kept in sync. This function does not take ownership of the impl 50 // thread are kept in sync. This function does not take ownership of the impl
48 // thread controller. 51 // thread controller.
49 virtual void PushAnimationUpdatesTo( 52 virtual void PushAnimationUpdatesTo(
50 LayerAnimationController* controller_impl); 53 LayerAnimationController* controller_impl);
51 54
55 // Transfers ownership of all animations to other_controller, replacing
56 // any animations currently owned by other_controller. This is intended
57 // to be used for transferring animations between main thread controllers,
58 // so the run state of each transferred animation is preserved (note that
59 // this differs from ReplaceImplThreadAnimations, which is used for copying
60 // animations from a main thread controller to an impl thread controller).
61 void TransferAnimationsTo(LayerAnimationController* other_controller);
62
52 void Animate(double monotonic_time); 63 void Animate(double monotonic_time);
53 void AccumulatePropertyUpdates(double monotonic_time, 64 void AccumulatePropertyUpdates(double monotonic_time,
54 AnimationEventsVector* events); 65 AnimationEventsVector* events);
55 66
56 void UpdateState(bool start_ready_animations, 67 void UpdateState(bool start_ready_animations,
57 AnimationEventsVector* events); 68 AnimationEventsVector* events);
58 69
59 // Returns the active animation in the given group, animating the given 70 // Returns the active animation in the given group, animating the given
60 // property, if such an animation exists. 71 // property, if such an animation exists.
61 Animation* GetAnimation(int group_id, 72 Animation* GetAnimation(int group_id,
62 Animation::TargetProperty target_property) const; 73 Animation::TargetProperty target_property) const;
63 74
64 // Returns the active animation animating the given property that is either 75 // Returns the active animation animating the given property that is either
65 // running, or is next to run, if such an animation exists. 76 // running, or is next to run, if such an animation exists.
66 Animation* GetAnimation(Animation::TargetProperty target_property) const; 77 Animation* GetAnimation(Animation::TargetProperty target_property) const;
67 78
68 // Returns true if there are any animations that have neither finished nor 79 // Returns true if there are any animations that have neither finished nor
69 // aborted. 80 // aborted.
70 bool HasActiveAnimation() const; 81 bool HasActiveAnimation() const;
71 82
72 // Returns true if there are any animations at all to process. 83 // Returns true if there are any animations at all to process.
73 bool has_any_animation() const { return !active_animations_.empty(); } 84 bool has_any_animation() const { return !active_animations_.empty(); }
74 85
75 // Returns true if there is an animation currently animating the given 86 // Returns true if there is an animation currently animating the given
76 // property, or if there is an animation scheduled to animate this property in 87 // property, or if there is an animation scheduled to animate this property in
77 // the future. 88 // the future.
78 bool IsAnimatingProperty(Animation::TargetProperty target_property) const; 89 bool IsAnimatingProperty(Animation::TargetProperty target_property) const;
79 90
80 // This is called in response to an animation being started on the impl
81 // thread. This function updates the corresponding main thread animation's
82 // start time.
83 virtual void OnAnimationStarted(const AnimationEvent& event) OVERRIDE;
84
85 // If a sync is forced, then the next time animation updates are pushed to the 91 // If a sync is forced, then the next time animation updates are pushed to the
86 // impl thread, all animations will be transferred. 92 // impl thread, all animations will be transferred.
87 void set_force_sync() { force_sync_ = true; } 93 void set_force_sync() { force_sync_ = true; }
88 94
89 void SetAnimationRegistrar(AnimationRegistrar* registrar); 95 void SetAnimationRegistrar(AnimationRegistrar* registrar);
90 AnimationRegistrar* animation_registrar() { return registrar_; } 96 AnimationRegistrar* animation_registrar() { return registrar_; }
91 97
92 void AddObserver(LayerAnimationValueObserver* observer); 98 void NotifyAnimationStarted(const AnimationEvent& event,
93 void RemoveObserver(LayerAnimationValueObserver* observer); 99 double wall_clock_time);
100 void NotifyAnimationFinished(const AnimationEvent& event,
101 double wall_clock_time);
102 void NotifyAnimationPropertyUpdate(const AnimationEvent& event);
103
104 void AddValueObserver(LayerAnimationValueObserver* observer);
105 void RemoveValueObserver(LayerAnimationValueObserver* observer);
106
107 void AddEventObserver(LayerAnimationEventObserver* observer);
108 void RemoveEventObserver(LayerAnimationEventObserver* observer);
109
110 void set_layer_animation_delegate(WebKit::WebAnimationDelegate* delegate) {
111 layer_animation_delegate_ = delegate;
112 }
94 113
95 protected: 114 protected:
96 friend class base::RefCounted<LayerAnimationController>; 115 friend class base::RefCounted<LayerAnimationController>;
97 116
98 explicit LayerAnimationController(int id); 117 explicit LayerAnimationController(int id);
99 virtual ~LayerAnimationController(); 118 virtual ~LayerAnimationController();
100 119
101 private: 120 private:
102 typedef base::hash_set<int> TargetProperties; 121 typedef base::hash_set<int> TargetProperties;
103 122
(...skipping 21 matching lines...) Expand all
125 144
126 enum UpdateActivationType { 145 enum UpdateActivationType {
127 NormalActivation, 146 NormalActivation,
128 ForceActivation 147 ForceActivation
129 }; 148 };
130 void UpdateActivation(UpdateActivationType type); 149 void UpdateActivation(UpdateActivationType type);
131 150
132 void NotifyObserversOpacityAnimated(float opacity); 151 void NotifyObserversOpacityAnimated(float opacity);
133 void NotifyObserversTransformAnimated(const gfx::Transform& transform); 152 void NotifyObserversTransformAnimated(const gfx::Transform& transform);
134 153
135 bool HasActiveObserver(); 154 bool HasActiveValueObserver();
136 155
137 // If this is true, we force a sync to the impl thread. 156 // If this is true, we force a sync to the impl thread.
138 bool force_sync_; 157 bool force_sync_;
139 158
140 AnimationRegistrar* registrar_; 159 AnimationRegistrar* registrar_;
141 int id_; 160 int id_;
142 ScopedPtrVector<Animation> active_animations_; 161 ScopedPtrVector<Animation> active_animations_;
143 162
144 // This is used to ensure that we don't spam the registrar. 163 // This is used to ensure that we don't spam the registrar.
145 bool is_active_; 164 bool is_active_;
146 165
147 double last_tick_time_; 166 double last_tick_time_;
148 167
149 ObserverList<LayerAnimationValueObserver> observers_; 168 ObserverList<LayerAnimationValueObserver> value_observers_;
169 ObserverList<LayerAnimationEventObserver> event_observers_;
170
171 WebKit::WebAnimationDelegate* layer_animation_delegate_;
150 172
151 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); 173 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController);
152 }; 174 };
153 175
154 } // namespace cc 176 } // namespace cc
155 177
156 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ 178 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « cc/animation/animation.cc ('k') | cc/animation/layer_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698