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_ANIMATION_PLAYER_H_ | |
6 #define CC_ANIMATION_ANIMATION_PLAYER_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "cc/animation/layer_animation_controller.h" | |
10 #include "cc/animation/layer_animation_value_observer.h" | |
11 #include "cc/animation/layer_animation_value_provider.h" | |
12 #include "cc/base/cc_export.h" | |
13 | |
14 namespace cc { | |
15 | |
16 class AnimationPlayerPendingValueObserver; | |
17 class AnimationTimeline; | |
18 class Layer; | |
19 | |
20 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer>, | |
21 public LayerAnimationValueObserver, | |
22 public LayerAnimationValueProvider { | |
23 public: | |
24 static scoped_refptr<AnimationPlayer> Create(int id = 0); | |
25 scoped_refptr<AnimationPlayer> CreateImplInstance() const; | |
26 | |
27 int id() const { return id_; } | |
28 | |
29 AnimationTimeline* animation_timeline() { return animation_timeline_; } | |
30 const AnimationTimeline* animation_timeline() const { | |
31 return animation_timeline_; | |
32 } | |
33 void SetAnimationTimeline(AnimationTimeline* timeline); | |
34 | |
35 LayerAnimationController* layer_animation_controller() const { | |
36 return layer_animation_controller_.get(); | |
37 } | |
38 | |
39 void set_layer_animation_delegate(AnimationDelegate* delegate); | |
40 | |
41 void AttachLayer(int layer_id); | |
42 void DetachLayer(); | |
43 | |
44 void AddAnimation(scoped_ptr<Animation> animation); | |
45 void PauseAnimation(int animation_id, double time_offset); | |
46 void RemoveAnimation(int animation_id); | |
47 | |
48 void PushPropertiesTo(AnimationPlayer* player_impl); | |
49 | |
50 private: | |
51 friend class base::RefCounted<AnimationPlayer>; | |
52 friend class AnimationPlayerPendingValueObserver; | |
53 | |
54 explicit AnimationPlayer(int id); | |
55 ~AnimationPlayer() override; | |
56 | |
57 void SetNeedsCommit(); | |
58 | |
59 void SetFilterMutated(bool active_tree, const FilterOperations& filters); | |
60 void SetOpacityMutated(bool active_tree, float opacity); | |
61 void SetTransformMutated(bool active_tree, const gfx::Transform& transform); | |
62 | |
63 // LayerAnimationValueProvider implementation. | |
64 gfx::ScrollOffset ScrollOffsetForAnimation() const override; | |
65 | |
66 // LayerAnimationValueObserver implementation. | |
67 void OnFilterAnimated(const FilterOperations& filters) override; | |
68 void OnOpacityAnimated(float opacity) override; | |
69 void OnTransformAnimated(const gfx::Transform& transform) override; | |
70 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; | |
71 void OnAnimationWaitingForDeletion() override; | |
72 bool IsActive() const override; | |
73 | |
74 // non-null only for impl thread instance. | |
75 scoped_ptr<AnimationPlayerPendingValueObserver> pending_value_observer_; | |
76 | |
77 scoped_refptr<LayerAnimationController> layer_animation_controller_; | |
78 AnimationTimeline* animation_timeline_; | |
79 AnimationDelegate* layer_animation_delegate_; | |
80 | |
81 int id_; | |
82 int layer_id_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); | |
85 }; | |
86 | |
87 class AnimationPlayerPendingValueObserver : public LayerAnimationValueObserver { | |
ajuma
2015/02/23 16:36:44
Nit: This should go in a separate file.
loyso (OOO)
2015/02/25 04:37:03
We will eliminate LayerAnimationValueObserver and
ajuma
2015/02/25 14:57:25
If this is purely an implementation detail of Anim
| |
88 public: | |
89 // LayerAnimationValueObserver implementation. | |
90 void OnFilterAnimated(const FilterOperations& filters) override; | |
91 void OnOpacityAnimated(float opacity) override; | |
92 void OnTransformAnimated(const gfx::Transform& transform) override; | |
93 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; | |
94 void OnAnimationWaitingForDeletion() override; | |
95 bool IsActive() const override; | |
96 | |
97 private: | |
98 friend class AnimationPlayer; | |
ajuma
2015/02/25 14:57:25
I missed this the first time through, but rather t
loyso (OOO)
2015/02/26 03:04:44
Do you mean nested class? Ok. I'm going to make it
| |
99 | |
100 explicit AnimationPlayerPendingValueObserver(AnimationPlayer* player); | |
101 | |
102 AnimationPlayer* player_; | |
103 | |
104 DISALLOW_COPY_AND_ASSIGN(AnimationPlayerPendingValueObserver); | |
105 }; | |
106 | |
107 } // namespace cc | |
108 | |
109 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_ | |
OLD | NEW |