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

Side by Side Diff: cc/layer_animation_controller.h

Issue 11443004: Maintain global lists of 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/time.h"
11 #include "cc/animation_events.h" 13 #include "cc/animation_events.h"
14 #include "cc/animation_registrar.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;
22 class KeyframeValueList; 26 class KeyframeValueList;
23 27
24 class CC_EXPORT LayerAnimationControllerClient { 28 class CC_EXPORT LayerAnimationController
29 : public base::RefCounted<LayerAnimationController> {
25 public: 30 public:
26 virtual ~LayerAnimationControllerClient() { } 31 static scoped_refptr<LayerAnimationController> create(AnimationRegistrar::Th readName);
27
28 virtual int id() const = 0;
29 virtual void setOpacityFromAnimation(float) = 0;
30 virtual float opacity() const = 0;
31 virtual void setTransformFromAnimation(const gfx::Transform&) = 0;
32 virtual const gfx::Transform& transform() const = 0;
33 };
34
35 class CC_EXPORT LayerAnimationController {
36 public:
37 static scoped_ptr<LayerAnimationController> create(LayerAnimationControllerC lient*);
38
39 virtual ~LayerAnimationController();
40 32
41 // These methods are virtual for testing. 33 // These methods are virtual for testing.
42 virtual void addAnimation(scoped_ptr<ActiveAnimation>); 34 virtual void addAnimation(scoped_ptr<ActiveAnimation>);
43 virtual void pauseAnimation(int animationId, double timeOffset); 35 virtual void pauseAnimation(int animationId, double timeOffset);
44 virtual void removeAnimation(int animationId); 36 virtual void removeAnimation(int animationId);
45 virtual void removeAnimation(int animationId, ActiveAnimation::TargetPropert y); 37 virtual void removeAnimation(int animationId, ActiveAnimation::TargetPropert y);
46 virtual void suspendAnimations(double monotonicTime); 38 virtual void suspendAnimations(double monotonicTime);
47 virtual void resumeAnimations(double monotonicTime); 39 virtual void resumeAnimations(double monotonicTime);
48 40
49 // Ensures that the list of active animations on the main thread and the imp l thread 41 // 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; 60 bool isAnimatingProperty(ActiveAnimation::TargetProperty) const;
69 61
70 // This is called in response to an animation being started on the impl thre ad. This 62 // 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. 63 // function updates the corresponding main thread animation's start time.
72 void notifyAnimationStarted(const AnimationEvent&); 64 void notifyAnimationStarted(const AnimationEvent&);
73 65
74 // If a sync is forced, then the next time animation updates are pushed to t he impl 66 // If a sync is forced, then the next time animation updates are pushed to t he impl
75 // thread, all animations will be transferred. 67 // thread, all animations will be transferred.
76 void setForceSync() { m_forceSync = true; } 68 void setForceSync() { m_forceSync = true; }
77 69
78 void setClient(LayerAnimationControllerClient*); 70 void setId(int id);
71
72 // Gets the last animated opacity value.
73 float opacity() const { return m_opacity; }
74
75 // Sets the opacity. Returns true if this call actually updates the opacity.
76 // This can return false if either the new opacity matches the old, or if
77 // the property is currently animating.
78 bool setOpacity(float opacity);
79
80 // Gets the last animate transform value.
81 const gfx::Transform& transform() const { return m_transform; }
82
83 // Sets the transform. Returns true if this call actually updates the
84 // transform. This can return false if either the new transform matches the
85 // old or if the property is currently animating.
86 bool setTransform(const gfx::Transform& transform);
79 87
80 protected: 88 protected:
81 explicit LayerAnimationController(LayerAnimationControllerClient*); 89 friend class base::RefCounted<LayerAnimationController>;
90
91 LayerAnimationController(AnimationRegistrar::ThreadName);
92 virtual ~LayerAnimationController();
82 93
83 private: 94 private:
84 typedef base::hash_set<int> TargetProperties; 95 typedef base::hash_set<int> TargetProperties;
85 96
86 void pushNewAnimationsToImplThread(LayerAnimationController*) const; 97 void pushNewAnimationsToImplThread(LayerAnimationController*) const;
87 void removeAnimationsCompletedOnMainThread(LayerAnimationController*) const; 98 void removeAnimationsCompletedOnMainThread(LayerAnimationController*) const;
88 void pushPropertiesToImplThread(LayerAnimationController*) const; 99 void pushPropertiesToImplThread(LayerAnimationController*) const;
89 void replaceImplThreadAnimations(LayerAnimationController*) const; 100 void replaceImplThreadAnimations(LayerAnimationController*) const;
90 101
91 void startAnimationsWaitingForNextTick(double monotonicTime, AnimationEvents Vector*); 102 void startAnimationsWaitingForNextTick(double monotonicTime, AnimationEvents Vector*);
92 void startAnimationsWaitingForStartTime(double monotonicTime, AnimationEvent sVector*); 103 void startAnimationsWaitingForStartTime(double monotonicTime, AnimationEvent sVector*);
93 void startAnimationsWaitingForTargetAvailability(double monotonicTime, Anima tionEventsVector*); 104 void startAnimationsWaitingForTargetAvailability(double monotonicTime, Anima tionEventsVector*);
94 void resolveConflicts(double monotonicTime); 105 void resolveConflicts(double monotonicTime);
95 void markAnimationsForDeletion(double monotonicTime, AnimationEventsVector*) ; 106 void markAnimationsForDeletion(double monotonicTime, AnimationEventsVector*) ;
96 void purgeAnimationsMarkedForDeletion(); 107 void purgeAnimationsMarkedForDeletion();
97 108
98 void tickAnimations(double monotonicTime); 109 void tickAnimations(double monotonicTime);
99 110
111 void updateActivation();
112
100 // If this is true, we force a sync to the impl thread. 113 // If this is true, we force a sync to the impl thread.
101 bool m_forceSync; 114 bool m_forceSync;
102 115
103 LayerAnimationControllerClient* m_client; 116 float m_opacity;
117 gfx::Transform m_transform;
118
119 AnimationRegistrar::ThreadName m_threadName;
120 int m_id;
104 ScopedPtrVector<ActiveAnimation> m_activeAnimations; 121 ScopedPtrVector<ActiveAnimation> m_activeAnimations;
105 122
106 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); 123 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController);
107 }; 124 };
108 125
109 } // namespace cc 126 } // namespace cc
110 127
111 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_ 128 #endif // CC_LAYER_ANIMATION_CONTROLLER_H_
OLDNEW
« cc/animation_registrar.h ('K') | « cc/layer.cc ('k') | cc/layer_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698