| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ELEMENT_ANIMATIONS_H_ | 5 #ifndef CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
| 6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_ | 6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/containers/linked_list.h" | 10 #include "base/containers/linked_list.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "cc/animation/animation_curve.h" | 13 #include "cc/animation/animation_curve.h" |
| 14 #include "cc/animation/animation_delegate.h" | 14 #include "cc/animation/animation_delegate.h" |
| 15 #include "cc/animation/layer_animation_controller.h" | 15 #include "cc/animation/layer_animation_controller.h" |
| 16 #include "cc/animation/layer_animation_value_observer.h" |
| 16 #include "cc/animation/layer_animation_value_provider.h" | 17 #include "cc/animation/layer_animation_value_provider.h" |
| 17 #include "cc/base/cc_export.h" | 18 #include "cc/base/cc_export.h" |
| 18 | 19 |
| 19 namespace gfx { | 20 namespace gfx { |
| 20 class ScrollOffset; | 21 class ScrollOffset; |
| 21 class Transform; | 22 class Transform; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace cc { | 25 namespace cc { |
| 25 | 26 |
| 26 class AnimationHost; | 27 class AnimationHost; |
| 27 class AnimationPlayer; | 28 class AnimationPlayer; |
| 28 class FilterOperations; | 29 class FilterOperations; |
| 29 class LayerAnimationController; | 30 class LayerAnimationController; |
| 30 enum class LayerTreeType; | 31 enum class LayerTreeType; |
| 31 | 32 |
| 32 // An ElementAnimations owns a list of all AnimationPlayers, attached to | 33 // An ElementAnimations owns a list of all AnimationPlayers, attached to |
| 33 // the layer. Also, it owns LayerAnimationController instance (1:1 | 34 // the layer. Also, it owns LayerAnimationController instance (1:1 |
| 34 // relationship) | 35 // relationship) |
| 35 // ElementAnimations object redirects all events from LAC to the list | 36 // ElementAnimations object redirects all events from LAC to the list |
| 36 // of animation layers. | 37 // of animation layers. |
| 37 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship). | 38 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship). |
| 38 // No pointer to/from respective blink::ElementAnimations object for now. | 39 // No pointer to/from respective blink::ElementAnimations object for now. |
| 39 class CC_EXPORT ElementAnimations : public AnimationDelegate, | 40 class CC_EXPORT ElementAnimations : public AnimationDelegate, |
| 41 public LayerAnimationValueObserver, |
| 40 public LayerAnimationValueProvider { | 42 public LayerAnimationValueProvider { |
| 41 public: | 43 public: |
| 42 static std::unique_ptr<ElementAnimations> Create(AnimationHost* host); | 44 static std::unique_ptr<ElementAnimations> Create(AnimationHost* host); |
| 43 ~ElementAnimations() override; | 45 ~ElementAnimations() override; |
| 44 | 46 |
| 45 int layer_id() const { | 47 int layer_id() const { |
| 46 return layer_animation_controller_ ? layer_animation_controller_->id() : 0; | 48 return layer_animation_controller_ ? layer_animation_controller_->id() : 0; |
| 47 } | 49 } |
| 48 | 50 |
| 49 // Parent AnimationHost. | 51 // Parent AnimationHost. |
| 50 AnimationHost* animation_host() { return animation_host_; } | 52 AnimationHost* animation_host() { return animation_host_; } |
| 51 const AnimationHost* animation_host() const { return animation_host_; } | 53 const AnimationHost* animation_host() const { return animation_host_; } |
| 52 | 54 |
| 53 void CreateLayerAnimationController(int layer_id); | 55 void CreateLayerAnimationController(int layer_id); |
| 54 void DestroyLayerAnimationController(); | 56 void DestroyLayerAnimationController(); |
| 55 | 57 |
| 56 void LayerRegistered(int layer_id, LayerTreeType tree_type); | 58 void LayerRegistered(int layer_id, LayerTreeType tree_type); |
| 57 void LayerUnregistered(int layer_id, LayerTreeType tree_type); | 59 void LayerUnregistered(int layer_id, LayerTreeType tree_type); |
| 58 | 60 |
| 59 bool has_active_value_observer_for_testing() const { | 61 bool needs_active_value_observations() const { |
| 60 return !!active_value_observer_; | 62 return layer_animation_controller_->needs_active_value_observations(); |
| 61 } | 63 } |
| 62 bool has_pending_value_observer_for_testing() const { | 64 bool needs_pending_value_observations() const { |
| 63 return !!pending_value_observer_; | 65 return layer_animation_controller_->needs_pending_value_observations(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 void AddPlayer(AnimationPlayer* player); | 68 void AddPlayer(AnimationPlayer* player); |
| 67 void RemovePlayer(AnimationPlayer* player); | 69 void RemovePlayer(AnimationPlayer* player); |
| 68 bool IsEmpty() const; | 70 bool IsEmpty() const; |
| 69 | 71 |
| 70 typedef base::LinkedList<AnimationPlayer> PlayersList; | 72 typedef base::LinkedList<AnimationPlayer> PlayersList; |
| 71 typedef base::LinkNode<AnimationPlayer> PlayersListNode; | 73 typedef base::LinkNode<AnimationPlayer> PlayersListNode; |
| 72 const PlayersList& players_list() const { return *players_list_.get(); } | 74 const PlayersList& players_list() const { return *players_list_.get(); } |
| 73 | 75 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 89 | 91 |
| 90 void AddEventObserver(LayerAnimationEventObserver* observer); | 92 void AddEventObserver(LayerAnimationEventObserver* observer); |
| 91 void RemoveEventObserver(LayerAnimationEventObserver* observer); | 93 void RemoveEventObserver(LayerAnimationEventObserver* observer); |
| 92 | 94 |
| 93 private: | 95 private: |
| 94 // TODO(loyso): Erase this when LAC merged into ElementAnimations. | 96 // TODO(loyso): Erase this when LAC merged into ElementAnimations. |
| 95 friend class AnimationHost; | 97 friend class AnimationHost; |
| 96 | 98 |
| 97 explicit ElementAnimations(AnimationHost* host); | 99 explicit ElementAnimations(AnimationHost* host); |
| 98 | 100 |
| 99 void SetFilterMutated(LayerTreeType tree_type, | 101 // LayerAnimationValueObserver implementation. |
| 100 const FilterOperations& filters); | 102 void OnFilterAnimated(LayerTreeType tree_type, |
| 101 void SetOpacityMutated(LayerTreeType tree_type, float opacity); | 103 const FilterOperations& filters) override; |
| 102 void SetTransformMutated(LayerTreeType tree_type, | 104 void OnOpacityAnimated(LayerTreeType tree_type, float opacity) override; |
| 103 const gfx::Transform& transform); | 105 void OnTransformAnimated(LayerTreeType tree_type, |
| 104 void SetScrollOffsetMutated(LayerTreeType tree_type, | 106 const gfx::Transform& transform) override; |
| 105 const gfx::ScrollOffset& scroll_offset); | 107 void OnScrollOffsetAnimated(LayerTreeType tree_type, |
| 106 void SetTransformIsPotentiallyAnimatingChanged(LayerTreeType tree_type, | 108 const gfx::ScrollOffset& scroll_offset) override; |
| 107 bool is_animating); | 109 void OnAnimationWaitingForDeletion() override; |
| 110 void OnTransformIsPotentiallyAnimatingChanged(LayerTreeType tree_type, |
| 111 bool is_animating) override; |
| 108 | 112 |
| 109 void CreateActiveValueObserver(); | 113 void CreateActiveValueObserver(); |
| 110 void DestroyActiveValueObserver(); | 114 void DestroyActiveValueObserver(); |
| 111 | 115 |
| 112 void CreatePendingValueObserver(); | 116 void CreatePendingValueObserver(); |
| 113 void DestroyPendingValueObserver(); | 117 void DestroyPendingValueObserver(); |
| 114 | 118 |
| 115 // AnimationDelegate implementation | 119 // AnimationDelegate implementation |
| 116 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 120 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 117 TargetProperty::Type target_property, | 121 TargetProperty::Type target_property, |
| 118 int group) override; | 122 int group) override; |
| 119 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 123 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 120 TargetProperty::Type target_property, | 124 TargetProperty::Type target_property, |
| 121 int group) override; | 125 int group) override; |
| 122 void NotifyAnimationAborted(base::TimeTicks monotonic_time, | 126 void NotifyAnimationAborted(base::TimeTicks monotonic_time, |
| 123 TargetProperty::Type target_property, | 127 TargetProperty::Type target_property, |
| 124 int group) override; | 128 int group) override; |
| 125 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, | 129 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, |
| 126 TargetProperty::Type target_property, | 130 TargetProperty::Type target_property, |
| 127 double animation_start_time, | 131 double animation_start_time, |
| 128 std::unique_ptr<AnimationCurve> curve) override; | 132 std::unique_ptr<AnimationCurve> curve) override; |
| 129 | 133 |
| 130 // LayerAnimationValueProvider implementation. | 134 // LayerAnimationValueProvider implementation. |
| 131 gfx::ScrollOffset ScrollOffsetForAnimation() const override; | 135 gfx::ScrollOffset ScrollOffsetForAnimation() const override; |
| 132 | 136 |
| 133 std::unique_ptr<PlayersList> players_list_; | 137 std::unique_ptr<PlayersList> players_list_; |
| 134 | 138 |
| 135 class ValueObserver; | |
| 136 std::unique_ptr<ValueObserver> active_value_observer_; | |
| 137 std::unique_ptr<ValueObserver> pending_value_observer_; | |
| 138 | |
| 139 // LAC is owned by ElementAnimations (1:1 relationship). | 139 // LAC is owned by ElementAnimations (1:1 relationship). |
| 140 scoped_refptr<LayerAnimationController> layer_animation_controller_; | 140 scoped_refptr<LayerAnimationController> layer_animation_controller_; |
| 141 AnimationHost* animation_host_; | 141 AnimationHost* animation_host_; |
| 142 | 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(ElementAnimations); | 143 DISALLOW_COPY_AND_ASSIGN(ElementAnimations); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 } // namespace cc | 146 } // namespace cc |
| 147 | 147 |
| 148 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_ | 148 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
| OLD | NEW |