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

Side by Side Diff: cc/layer_animation_controller.h

Issue 11598005: Ref count layer animation controllers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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
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/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
13 #include "base/time.h"
11 #include "cc/animation_events.h" 14 #include "cc/animation_events.h"
12 #include "cc/cc_export.h" 15 #include "cc/cc_export.h"
13 #include "cc/scoped_ptr_vector.h" 16 #include "cc/scoped_ptr_vector.h"
17 #include "ui/gfx/transform.h"
14 18
15 namespace gfx { 19 namespace gfx {
16 class Transform; 20 class Transform;
17 } 21 }
18 22
19 namespace cc { 23 namespace cc {
20 24
21 class Animation; 25 class Animation;
26 class AnimationRegistrar;
22 class KeyframeValueList; 27 class KeyframeValueList;
23 28
24 class CC_EXPORT LayerAnimationControllerClient { 29 class CC_EXPORT LayerAnimationControllerObserver {
25 public: 30 public:
26 virtual ~LayerAnimationControllerClient() { } 31 virtual ~LayerAnimationControllerObserver() { }
27 32
28 virtual int id() const = 0; 33 virtual void OnOpacityAnimated(float) = 0;
29 virtual void setOpacityFromAnimation(float) = 0; 34 virtual void OnTransformAnimated(const gfx::Transform&) = 0;
30 virtual float opacity() const = 0;
31 virtual void setTransformFromAnimation(const gfx::Transform&) = 0;
32 virtual const gfx::Transform& transform() const = 0;
33 }; 35 };
34 36
35 class CC_EXPORT LayerAnimationController { 37 class CC_EXPORT LayerAnimationController
38 : public base::RefCounted<LayerAnimationController> {
36 public: 39 public:
37 static scoped_ptr<LayerAnimationController> create(LayerAnimationControllerC lient*); 40 static scoped_refptr<LayerAnimationController> create(int id);
38 41
39 virtual ~LayerAnimationController(); 42 int id() const { return m_id; }
40 43
41 // These methods are virtual for testing. 44 // These methods are virtual for testing.
42 virtual void addAnimation(scoped_ptr<ActiveAnimation>); 45 virtual void addAnimation(scoped_ptr<ActiveAnimation>);
43 virtual void pauseAnimation(int animationId, double timeOffset); 46 virtual void pauseAnimation(int animationId, double timeOffset);
44 virtual void removeAnimation(int animationId); 47 virtual void removeAnimation(int animationId);
45 virtual void removeAnimation(int animationId, ActiveAnimation::TargetPropert y); 48 virtual void removeAnimation(int animationId, ActiveAnimation::TargetPropert y);
46 virtual void suspendAnimations(double monotonicTime); 49 virtual void suspendAnimations(double monotonicTime);
47 virtual void resumeAnimations(double monotonicTime); 50 virtual void resumeAnimations(double monotonicTime);
48 51
49 // Ensures that the list of active animations on the main thread and the imp l thread 52 // Ensures that the list of active animations on the main thread and the imp l thread
(...skipping 18 matching lines...) Expand all
68 bool isAnimatingProperty(ActiveAnimation::TargetProperty) const; 71 bool isAnimatingProperty(ActiveAnimation::TargetProperty) const;
69 72
70 // This is called in response to an animation being started on the impl thre ad. This 73 // This is called in response to an animation being started on the impl thre ad. This
71 // function updates the corresponding main thread animation's start time. 74 // function updates the corresponding main thread animation's start time.
72 void notifyAnimationStarted(const AnimationEvent&); 75 void notifyAnimationStarted(const AnimationEvent&);
73 76
74 // If a sync is forced, then the next time animation updates are pushed to t he impl 77 // If a sync is forced, then the next time animation updates are pushed to t he impl
75 // thread, all animations will be transferred. 78 // thread, all animations will be transferred.
76 void setForceSync() { m_forceSync = true; } 79 void setForceSync() { m_forceSync = true; }
77 80
78 void setClient(LayerAnimationControllerClient*); 81 void setAnimationRegistrar(AnimationRegistrar*);
82
83 void addObserver(LayerAnimationControllerObserver*);
84 void removeObserver(LayerAnimationControllerObserver*);
79 85
80 protected: 86 protected:
81 explicit LayerAnimationController(LayerAnimationControllerClient*); 87 friend class base::RefCounted<LayerAnimationController>;
88
89 LayerAnimationController(int id);
90 virtual ~LayerAnimationController();
82 91
83 private: 92 private:
84 typedef base::hash_set<int> TargetProperties; 93 typedef base::hash_set<int> TargetProperties;
85 94
86 void pushNewAnimationsToImplThread(LayerAnimationController*) const; 95 void pushNewAnimationsToImplThread(LayerAnimationController*) const;
87 void removeAnimationsCompletedOnMainThread(LayerAnimationController*) const; 96 void removeAnimationsCompletedOnMainThread(LayerAnimationController*) const;
88 void pushPropertiesToImplThread(LayerAnimationController*) const; 97 void pushPropertiesToImplThread(LayerAnimationController*) const;
89 void replaceImplThreadAnimations(LayerAnimationController*) const; 98 void replaceImplThreadAnimations(LayerAnimationController*) const;
90 99
91 void startAnimationsWaitingForNextTick(double monotonicTime, AnimationEvents Vector*); 100 void startAnimationsWaitingForNextTick(double monotonicTime, AnimationEvents Vector*);
92 void startAnimationsWaitingForStartTime(double monotonicTime, AnimationEvent sVector*); 101 void startAnimationsWaitingForStartTime(double monotonicTime, AnimationEvent sVector*);
93 void startAnimationsWaitingForTargetAvailability(double monotonicTime, Anima tionEventsVector*); 102 void startAnimationsWaitingForTargetAvailability(double monotonicTime, Anima tionEventsVector*);
94 void resolveConflicts(double monotonicTime); 103 void resolveConflicts(double monotonicTime);
95 void markAnimationsForDeletion(double monotonicTime, AnimationEventsVector*) ; 104 void markAnimationsForDeletion(double monotonicTime, AnimationEventsVector*) ;
96 void purgeAnimationsMarkedForDeletion(); 105 void purgeAnimationsMarkedForDeletion();
97 106
98 void tickAnimations(double monotonicTime); 107 void tickAnimations(double monotonicTime);
99 108
109 void updateActivation(bool force = false);
110
111 void notifyObserversOpacityAnimated(float opacity);
112 void notifyObserversTransformAnimated(const gfx::Transform& transform);
113
100 // If this is true, we force a sync to the impl thread. 114 // If this is true, we force a sync to the impl thread.
101 bool m_forceSync; 115 bool m_forceSync;
102 116
103 LayerAnimationControllerClient* m_client; 117 AnimationRegistrar* m_registrar;
118 int m_id;
104 ScopedPtrVector<ActiveAnimation> m_activeAnimations; 119 ScopedPtrVector<ActiveAnimation> m_activeAnimations;
105 120
121 // This is used to ensure that we don't spam the registrar.
122 bool m_isActive;
123
124 ObserverList<LayerAnimationControllerObserver> m_observers;
125
106 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); 126 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController);
107 }; 127 };
108 128
109 } // namespace cc 129 } // namespace cc
110 130
111 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_ 131 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698