OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
| 6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
| 7 |
| 8 #include "base/containers/linked_list.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "cc/animation/animation_delegate.h" |
| 11 #include "cc/animation/layer_animation_controller.h" |
| 12 #include "cc/animation/layer_animation_value_provider.h" |
| 13 #include "cc/base/cc_export.h" |
| 14 |
| 15 namespace gfx { |
| 16 class ScrollOffset; |
| 17 class Transform; |
| 18 } |
| 19 |
| 20 namespace cc { |
| 21 |
| 22 class AnimationHost; |
| 23 class AnimationPlayer; |
| 24 class FilterOperations; |
| 25 class LayerAnimationController; |
| 26 enum class LayerTreeType; |
| 27 |
| 28 // An ElementAnimations owns a list of all AnimationPlayers, attached to |
| 29 // the layer. Also, it owns LayerAnimationController instance (1:1 |
| 30 // relationship) |
| 31 // ElementAnimations object redirects all events from LAC to the list |
| 32 // of animation layers. |
| 33 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship). |
| 34 // No pointer to/from respective blink::ElementAnimations object for now. |
| 35 class CC_EXPORT ElementAnimations : public AnimationDelegate, |
| 36 public LayerAnimationValueProvider { |
| 37 public: |
| 38 static scoped_ptr<ElementAnimations> Create(AnimationHost* host); |
| 39 ~ElementAnimations() override; |
| 40 |
| 41 int layer_id() const { |
| 42 return layer_animation_controller_ ? layer_animation_controller_->id() : 0; |
| 43 } |
| 44 |
| 45 // Parent AnimationHost. |
| 46 AnimationHost* animation_host() { return animation_host_; } |
| 47 const AnimationHost* animation_host() const { return animation_host_; } |
| 48 |
| 49 LayerAnimationController* layer_animation_controller() const { |
| 50 return layer_animation_controller_.get(); |
| 51 } |
| 52 |
| 53 void CreateLayerAnimationController(int layer_id); |
| 54 void DestroyLayerAnimationController(); |
| 55 |
| 56 void LayerRegistered(int layer_id, LayerTreeType tree_type); |
| 57 void LayerUnregistered(int layer_id, LayerTreeType tree_type); |
| 58 |
| 59 bool has_active_value_observer_for_testing() const { |
| 60 return active_value_observer_; |
| 61 } |
| 62 bool has_pending_value_observer_for_testing() const { |
| 63 return pending_value_observer_; |
| 64 } |
| 65 |
| 66 void AddPlayer(AnimationPlayer* player); |
| 67 void RemovePlayer(AnimationPlayer* player); |
| 68 bool IsEmpty() const; |
| 69 |
| 70 typedef base::LinkedList<AnimationPlayer> PlayersList; |
| 71 typedef base::LinkNode<AnimationPlayer> PlayersListNode; |
| 72 const PlayersList& players_list() const { return *players_list_.get(); } |
| 73 |
| 74 void PushPropertiesTo(ElementAnimations* element_animations_impl); |
| 75 |
| 76 private: |
| 77 explicit ElementAnimations(AnimationHost* host); |
| 78 |
| 79 void SetFilterMutated(LayerTreeType tree_type, |
| 80 const FilterOperations& filters); |
| 81 void SetOpacityMutated(LayerTreeType tree_type, float opacity); |
| 82 void SetTransformMutated(LayerTreeType tree_type, |
| 83 const gfx::Transform& transform); |
| 84 void SetScrollOffsetMutated(LayerTreeType tree_type, |
| 85 const gfx::ScrollOffset& scroll_offset); |
| 86 |
| 87 void CreateActiveValueObserver(); |
| 88 void DestroyActiveValueObserver(); |
| 89 |
| 90 void CreatePendingValueObserver(); |
| 91 void DestroyPendingValueObserver(); |
| 92 |
| 93 // AnimationDelegate implementation |
| 94 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 95 Animation::TargetProperty target_property, |
| 96 int group) override; |
| 97 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 98 Animation::TargetProperty target_property, |
| 99 int group) override; |
| 100 |
| 101 // LayerAnimationValueProvider implementation. |
| 102 gfx::ScrollOffset ScrollOffsetForAnimation() const override; |
| 103 |
| 104 scoped_ptr<PlayersList> players_list_; |
| 105 |
| 106 class ValueObserver; |
| 107 scoped_ptr<ValueObserver> active_value_observer_; |
| 108 scoped_ptr<ValueObserver> pending_value_observer_; |
| 109 |
| 110 // LAC is owned by ElementAnimations (1:1 relationship). |
| 111 scoped_refptr<LayerAnimationController> layer_animation_controller_; |
| 112 AnimationHost* animation_host_; |
| 113 |
| 114 DISALLOW_COPY_AND_ASSIGN(ElementAnimations); |
| 115 }; |
| 116 |
| 117 } // namespace cc |
| 118 |
| 119 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
OLD | NEW |