Chromium Code Reviews| 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 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/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 class LayerAnimationValueProvider; | 33 class LayerAnimationValueProvider; |
| 34 | 34 |
| 35 class CC_EXPORT LayerAnimationController | 35 class CC_EXPORT LayerAnimationController |
| 36 : public base::RefCounted<LayerAnimationController> { | 36 : public base::RefCounted<LayerAnimationController> { |
| 37 public: | 37 public: |
| 38 static scoped_refptr<LayerAnimationController> Create(int id); | 38 static scoped_refptr<LayerAnimationController> Create(int id); |
| 39 | 39 |
| 40 int id() const { return id_; } | 40 int id() const { return id_; } |
| 41 | 41 |
| 42 void AddAnimation(scoped_ptr<Animation> animation); | 42 void AddAnimation(scoped_ptr<Animation> animation); |
| 43 void PauseAnimation(int animation_id, double time_offset); | 43 void PauseAnimation(int animation_id, base::TimeTicks time_offset); |
|
ajuma
2014/04/09 17:37:39
An offset seems more like a TimeDelta (a period of
Sikugu_
2014/04/10 14:04:57
Done.
| |
| 44 void RemoveAnimation(int animation_id); | 44 void RemoveAnimation(int animation_id); |
| 45 void RemoveAnimation(int animation_id, | 45 void RemoveAnimation(int animation_id, |
| 46 Animation::TargetProperty target_property); | 46 Animation::TargetProperty target_property); |
| 47 void AbortAnimations(Animation::TargetProperty target_property); | 47 void AbortAnimations(Animation::TargetProperty target_property); |
| 48 | 48 |
| 49 // 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 |
| 50 // 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 |
| 51 // thread controller. This method is virtual for testing. | 51 // thread controller. This method is virtual for testing. |
| 52 virtual void PushAnimationUpdatesTo( | 52 virtual void PushAnimationUpdatesTo( |
| 53 LayerAnimationController* controller_impl); | 53 LayerAnimationController* controller_impl); |
| 54 | 54 |
| 55 void Animate(double monotonic_time); | 55 void Animate(base::TimeTicks monotonic_time); |
| 56 void AccumulatePropertyUpdates(double monotonic_time, | 56 void AccumulatePropertyUpdates(base::TimeTicks monotonic_time, |
| 57 AnimationEventsVector* events); | 57 AnimationEventsVector* events); |
| 58 | 58 |
| 59 void UpdateState(bool start_ready_animations, | 59 void UpdateState(bool start_ready_animations, |
| 60 AnimationEventsVector* events); | 60 AnimationEventsVector* events); |
| 61 | 61 |
| 62 // Returns the active animation in the given group, animating the given | 62 // Returns the active animation in the given group, animating the given |
| 63 // property, if such an animation exists. | 63 // property, if such an animation exists. |
| 64 Animation* GetAnimation(int group_id, | 64 Animation* GetAnimation(int group_id, |
| 65 Animation::TargetProperty target_property) const; | 65 Animation::TargetProperty target_property) const; |
| 66 | 66 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // animations. Returns false if the maximum scale cannot be computed. | 127 // animations. Returns false if the maximum scale cannot be computed. |
| 128 bool MaximumScale(float* max_scale) const; | 128 bool MaximumScale(float* max_scale) const; |
| 129 | 129 |
| 130 protected: | 130 protected: |
| 131 friend class base::RefCounted<LayerAnimationController>; | 131 friend class base::RefCounted<LayerAnimationController>; |
| 132 | 132 |
| 133 explicit LayerAnimationController(int id); | 133 explicit LayerAnimationController(int id); |
| 134 virtual ~LayerAnimationController(); | 134 virtual ~LayerAnimationController(); |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 double GetTimeTicks(base::TimeTicks time) { | |
|
danakj
2014/04/09 16:33:03
make this a file-static method (or anon namespace)
Sikugu_
2014/04/10 14:04:57
Done.
| |
| 138 return (time - base::TimeTicks()).InSecondsF(); | |
| 139 } | |
| 137 typedef base::hash_set<int> TargetProperties; | 140 typedef base::hash_set<int> TargetProperties; |
| 138 | 141 |
| 139 void PushNewAnimationsToImplThread( | 142 void PushNewAnimationsToImplThread( |
| 140 LayerAnimationController* controller_impl) const; | 143 LayerAnimationController* controller_impl) const; |
| 141 void RemoveAnimationsCompletedOnMainThread( | 144 void RemoveAnimationsCompletedOnMainThread( |
| 142 LayerAnimationController* controller_impl) const; | 145 LayerAnimationController* controller_impl) const; |
| 143 void PushPropertiesToImplThread( | 146 void PushPropertiesToImplThread( |
| 144 LayerAnimationController* controller_impl) const; | 147 LayerAnimationController* controller_impl) const; |
| 145 | 148 |
| 146 void StartAnimations(double monotonic_time); | 149 void StartAnimations(base::TimeTicks monotonic_time); |
| 147 void PromoteStartedAnimations(double monotonic_time, | 150 void PromoteStartedAnimations(base::TimeTicks monotonic_time, |
| 148 AnimationEventsVector* events); | 151 AnimationEventsVector* events); |
| 149 void MarkFinishedAnimations(double monotonic_time); | 152 void MarkFinishedAnimations(base::TimeTicks monotonic_time); |
| 150 void MarkAnimationsForDeletion(double monotonic_time, | 153 void MarkAnimationsForDeletion(base::TimeTicks monotonic_time, |
| 151 AnimationEventsVector* events); | 154 AnimationEventsVector* events); |
| 152 void PurgeAnimationsMarkedForDeletion(); | 155 void PurgeAnimationsMarkedForDeletion(); |
| 153 | 156 |
| 154 void TickAnimations(double monotonic_time); | 157 void TickAnimations(base::TimeTicks monotonic_time); |
| 155 | 158 |
| 156 enum UpdateActivationType { | 159 enum UpdateActivationType { |
| 157 NormalActivation, | 160 NormalActivation, |
| 158 ForceActivation | 161 ForceActivation |
| 159 }; | 162 }; |
| 160 void UpdateActivation(UpdateActivationType type); | 163 void UpdateActivation(UpdateActivationType type); |
| 161 | 164 |
| 162 void NotifyObserversOpacityAnimated(float opacity); | 165 void NotifyObserversOpacityAnimated(float opacity); |
| 163 void NotifyObserversTransformAnimated(const gfx::Transform& transform); | 166 void NotifyObserversTransformAnimated(const gfx::Transform& transform); |
| 164 void NotifyObserversFilterAnimated(const FilterOperations& filter); | 167 void NotifyObserversFilterAnimated(const FilterOperations& filter); |
| 165 void NotifyObserversScrollOffsetAnimated(const gfx::Vector2dF& scroll_offset); | 168 void NotifyObserversScrollOffsetAnimated(const gfx::Vector2dF& scroll_offset); |
| 166 | 169 |
| 167 void NotifyObserversAnimationWaitingForDeletion(); | 170 void NotifyObserversAnimationWaitingForDeletion(); |
| 168 | 171 |
| 169 bool HasValueObserver(); | 172 bool HasValueObserver(); |
| 170 bool HasActiveValueObserver(); | 173 bool HasActiveValueObserver(); |
| 171 | 174 |
| 172 AnimationRegistrar* registrar_; | 175 AnimationRegistrar* registrar_; |
| 173 int id_; | 176 int id_; |
| 174 ScopedPtrVector<Animation> active_animations_; | 177 ScopedPtrVector<Animation> active_animations_; |
| 175 | 178 |
| 176 // This is used to ensure that we don't spam the registrar. | 179 // This is used to ensure that we don't spam the registrar. |
| 177 bool is_active_; | 180 bool is_active_; |
| 178 | 181 |
| 179 double last_tick_time_; | 182 base::TimeTicks last_tick_time_; |
| 180 | 183 |
| 181 ObserverList<LayerAnimationValueObserver> value_observers_; | 184 ObserverList<LayerAnimationValueObserver> value_observers_; |
| 182 ObserverList<LayerAnimationEventObserver> event_observers_; | 185 ObserverList<LayerAnimationEventObserver> event_observers_; |
| 183 | 186 |
| 184 LayerAnimationValueProvider* value_provider_; | 187 LayerAnimationValueProvider* value_provider_; |
| 185 | 188 |
| 186 AnimationDelegate* layer_animation_delegate_; | 189 AnimationDelegate* layer_animation_delegate_; |
| 187 | 190 |
| 188 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); | 191 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); |
| 189 }; | 192 }; |
| 190 | 193 |
| 191 } // namespace cc | 194 } // namespace cc |
| 192 | 195 |
| 193 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ | 196 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ |
| OLD | NEW |