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

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: Fix codereview issues. Created 5 years, 5 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/containers/linked_list.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h"
11 #include "cc/animation/animation.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/base/scoped_ptr_vector.h"
14
15 namespace cc {
16
17 class AnimationDelegate;
18 class AnimationHost;
19 class AnimationTimeline;
20 class ElementAnimations;
21 class LayerAnimationController;
22 enum class LayerTreeType;
23
24 // An AnimationPlayer owns all animations to be run on particular CC Layer.
25 // Multiple AnimationPlayers can be attached to one layer. In this case,
26 // they share common LayerAnimationController (temp solution) so the
27 // LayerAnimationController-to-Layer relationship stays the same (1:1, LACs
28 // have same IDs as their respective Layers).
29 // For now, the blink logic is responsible for handling of conflicting
30 // same-property animations.
31 // Each AnimationPlayer has its copy on the impl thread.
32 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship).
33 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer>,
34 public base::LinkNode<AnimationPlayer> {
35 public:
36 static scoped_refptr<AnimationPlayer> Create(int id);
37 scoped_refptr<AnimationPlayer> CreateImplInstance() const;
38
39 int id() const { return id_; }
40 int layer_id() const { return layer_id_; }
41
42 // Parent AnimationHost. AnimationPlayer can be detached from
43 // AnimationTimeline.
44 AnimationHost* animation_host() { return animation_host_; }
45 const AnimationHost* animation_host() const { return animation_host_; }
46 void SetAnimationHost(AnimationHost* animation_host);
47
48 // Parent AnimationTimeline.
49 AnimationTimeline* animation_timeline() { return animation_timeline_; }
50 const AnimationTimeline* animation_timeline() const {
51 return animation_timeline_;
52 }
53 void SetAnimationTimeline(AnimationTimeline* timeline);
54
55 // ElementAnimations object where this player is listed.
56 // ElementAnimations has a reference to shared LayerAnimationController.
57 ElementAnimations* element_animations() const { return element_animations_; }
58
59 void set_layer_animation_delegate(AnimationDelegate* delegate) {
60 layer_animation_delegate_ = delegate;
61 }
62
63 void AttachLayer(int layer_id);
64 void DetachLayer();
65
66 void AddAnimation(scoped_ptr<Animation> animation);
67 void PauseAnimation(int animation_id, double time_offset);
68 void RemoveAnimation(int animation_id);
69
70 void PushPropertiesTo(AnimationPlayer* player_impl);
71
72 // AnimationDelegate routing.
73 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
74 Animation::TargetProperty target_property,
75 int group);
76 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
77 Animation::TargetProperty target_property,
78 int group);
79
80 private:
81 friend class base::RefCounted<AnimationPlayer>;
82
83 explicit AnimationPlayer(int id);
84 ~AnimationPlayer();
85
86 void SetNeedsCommit();
87
88 void RegisterPlayer();
89 void UnregisterPlayer();
90
91 void BindElementAnimations();
92 void UnbindElementAnimations();
93
94 typedef ScopedPtrVector<Animation> AnimationList;
95 AnimationList animations_;
Ian Vollick 2015/07/01 03:03:29 If I'm understanding correctly, animations_ here i
loyso (OOO) 2015/07/01 06:59:06 We create ElementAnimations+LAC objects later on a
96
97 AnimationHost* animation_host_;
98 AnimationTimeline* animation_timeline_;
99 ElementAnimations* element_animations_;
100 AnimationDelegate* layer_animation_delegate_;
101
102 int id_;
103 int layer_id_;
104
105 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer);
106 };
107
108 } // namespace cc
109
110 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698