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.
5 #ifndef CC_ANIMATION_ELEMENT_ANIMATIONS_H_
6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_
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"
23 class AnimationPlayer
;
24 class FilterOperations
;
25 class LayerAnimationController
;
26 enum class LayerTreeType
;
28 // An ElementAnimations owns a list of all AnimationPlayers, attached to
29 // the layer. Also, it owns LayerAnimationController instance (1:1
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
{
38 static scoped_ptr
<ElementAnimations
> Create(AnimationHost
* host
);
39 ~ElementAnimations() override
;
41 int layer_id() const {
42 return layer_animation_controller_
? layer_animation_controller_
->id() : 0;
45 // Parent AnimationHost.
46 AnimationHost
* animation_host() { return animation_host_
; }
47 const AnimationHost
* animation_host() const { return animation_host_
; }
49 LayerAnimationController
* layer_animation_controller() const {
50 return layer_animation_controller_
.get();
53 void CreateLayerAnimationController(int layer_id
);
54 void DestroyLayerAnimationController();
56 void LayerRegistered(int layer_id
, LayerTreeType tree_type
);
57 void LayerUnregistered(int layer_id
, LayerTreeType tree_type
);
59 bool has_active_value_observer_for_testing() const {
60 return active_value_observer_
;
62 bool has_pending_value_observer_for_testing() const {
63 return pending_value_observer_
;
66 void AddPlayer(AnimationPlayer
* player
);
67 void RemovePlayer(AnimationPlayer
* player
);
70 typedef base::LinkedList
<AnimationPlayer
> PlayersList
;
71 typedef base::LinkNode
<AnimationPlayer
> PlayersListNode
;
72 const PlayersList
& players_list() const { return *players_list_
.get(); }
74 void PushPropertiesTo(ElementAnimations
* element_animations_impl
);
77 explicit ElementAnimations(AnimationHost
* host
);
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 void SetTransformIsPotentiallyAnimatingChanged(LayerTreeType tree_type
,
89 void CreateActiveValueObserver();
90 void DestroyActiveValueObserver();
92 void CreatePendingValueObserver();
93 void DestroyPendingValueObserver();
95 // AnimationDelegate implementation
96 void NotifyAnimationStarted(base::TimeTicks monotonic_time
,
97 Animation::TargetProperty target_property
,
99 void NotifyAnimationFinished(base::TimeTicks monotonic_time
,
100 Animation::TargetProperty target_property
,
103 // LayerAnimationValueProvider implementation.
104 gfx::ScrollOffset
ScrollOffsetForAnimation() const override
;
106 scoped_ptr
<PlayersList
> players_list_
;
109 scoped_ptr
<ValueObserver
> active_value_observer_
;
110 scoped_ptr
<ValueObserver
> pending_value_observer_
;
112 // LAC is owned by ElementAnimations (1:1 relationship).
113 scoped_refptr
<LayerAnimationController
> layer_animation_controller_
;
114 AnimationHost
* animation_host_
;
116 DISALLOW_COPY_AND_ASSIGN(ElementAnimations
);
121 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_