Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: cc/animation/animation_player.h

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Add comments. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 gfx {
15 class ScrollOffset;
16 class Transform;
17 }
18
19 namespace cc {
20
21 class AnimationHost;
22 class AnimationTimeline;
23 class FilterOperations;
24 class Layer;
25
26 // An AnimationPlayer owns all animations to be run on particular CC Layer.
27 // Multiple AnimationPlayers can be attached to one layer. In this case,
28 // they share common LayerAnimationController (temp solution) so the
29 // LayerAnimationController-to-Layer relationship stays the same (1:1, LACs
30 // have same IDs as their correspondent Layers).
31 // For now, the blink logic is responsible for handling conflicting
32 // same-property animations.
33 // Each AnimationPlayer has it's copy on the impl thread.
34 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship).
35 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer>,
Ian Vollick 2015/05/05 03:52:06 Why RefCounted?
loyso (OOO) 2015/05/05 06:51:18 It's in shared ownership between blink::AnimationP
Ian Vollick 2015/05/07 13:58:42 This is probably a dumb question, but can players
loyso (OOO) 2015/05/08 01:04:35 Yes, sure. Typically you create them in blink in a
loyso (OOO) 2015/06/22 07:48:51 Class diagrams added to the design doc.
Ian Vollick 2015/06/22 13:58:39 These diagrams are amazing. Thank you!
36 public LayerAnimationValueProvider {
37 public:
38 static scoped_refptr<AnimationPlayer> Create(int id);
39 scoped_refptr<AnimationPlayer> CreateImplInstance() const;
40
41 int id() const { return id_; }
42 int layer_id() const { return layer_id_; }
43
44 // Parent AnimationHost. AnimationPlayer can be detached from
45 // AnimationTimeline.
46 AnimationHost* animation_host() { return animation_host_; }
47 const AnimationHost* animation_host() const { return animation_host_; }
48 void SetAnimationHost(AnimationHost* animation_host);
49
50 // Parent AnimationTimeline.
51 AnimationTimeline* animation_timeline() { return animation_timeline_; }
52 const AnimationTimeline* animation_timeline() const {
53 return animation_timeline_;
54 }
55 void SetAnimationTimeline(AnimationTimeline* timeline);
56
57 LayerAnimationController* layer_animation_controller() const {
58 return layer_animation_controller_.get();
59 }
60
61 void set_layer_animation_delegate(AnimationDelegate* delegate);
62
63 void AttachLayer(int layer_id);
64 void DetachLayer();
65
66 void LayerRegistered(int layer_id, bool is_active_tree);
67 void LayerUnregistered(int layer_id, bool is_active_tree);
68
69 void AddAnimation(scoped_ptr<Animation> animation);
70 void PauseAnimation(int animation_id, double time_offset);
71 void RemoveAnimation(int animation_id);
72
73 void PushPropertiesTo(AnimationPlayer* player_impl);
74
75 bool has_active_value_observer_for_testing() const {
76 return active_value_observer_;
77 }
78 bool has_pending_value_observer_for_testing() const {
79 return pending_value_observer_;
80 }
81
82 private:
83 friend class base::RefCounted<AnimationPlayer>;
84
85 explicit AnimationPlayer(int id);
86 ~AnimationPlayer() override;
87
88 void SetNeedsCommit();
89
90 void SetFilterMutated(bool active_tree, const FilterOperations& filters);
91 void SetOpacityMutated(bool active_tree, float opacity);
92 void SetTransformMutated(bool active_tree, const gfx::Transform& transform);
93 void SetScrollOffsetMutated(bool active_tree,
94 const gfx::ScrollOffset& scroll_offset);
95
96 void AddControllerToTimeline();
97 void RemoveControllerFromTimeline();
98
99 void CreateActiveValueObserver();
100 void DestroyActiveValueObserver();
101
102 void CreatePendingValueObserver();
103 void DestroyPendingValueObserver();
104
105 // LayerAnimationValueProvider implementation.
106 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
107
108 class ValueObserver;
109 scoped_ptr<ValueObserver> active_value_observer_;
110 scoped_ptr<ValueObserver> pending_value_observer_;
111
112 scoped_refptr<LayerAnimationController> layer_animation_controller_;
113 AnimationHost* animation_host_;
114 AnimationTimeline* animation_timeline_;
115 AnimationDelegate* layer_animation_delegate_;
116
117 int id_;
118 int layer_id_;
119
120 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer);
121 };
122
123 } // namespace cc
124
125 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698