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

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

Issue 2189813002: ElementAnimations should hold an ObservableList of AnimationPlayers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + fix blink_platform_unittests compile error Created 4 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_ANIMATION_ANIMATION_PLAYER_H_ 5 #ifndef CC_ANIMATION_ANIMATION_PLAYER_H_
6 #define CC_ANIMATION_ANIMATION_PLAYER_H_ 6 #define CC_ANIMATION_ANIMATION_PLAYER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/linked_list.h" 10 #include "base/containers/linked_list.h"
(...skipping 13 matching lines...) Expand all
24 class ElementAnimations; 24 class ElementAnimations;
25 25
26 // An AnimationPlayer owns all animations to be run on particular CC Layer. 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, 27 // Multiple AnimationPlayers can be attached to one layer. In this case,
28 // they share common ElementAnimations so the 28 // they share common ElementAnimations so the
29 // ElementAnimations-to-Layer relationship is 1:1. 29 // ElementAnimations-to-Layer relationship is 1:1.
30 // For now, the blink logic is responsible for handling of conflicting 30 // For now, the blink logic is responsible for handling of conflicting
31 // same-property animations. 31 // same-property animations.
32 // Each AnimationPlayer has its copy on the impl thread. 32 // Each AnimationPlayer has its copy on the impl thread.
33 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship). 33 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship).
34 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer>, 34 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> {
35 public base::LinkNode<AnimationPlayer> {
36 public: 35 public:
37 static scoped_refptr<AnimationPlayer> Create(int id); 36 static scoped_refptr<AnimationPlayer> Create(int id);
38 scoped_refptr<AnimationPlayer> CreateImplInstance() const; 37 scoped_refptr<AnimationPlayer> CreateImplInstance() const;
39 38
40 int id() const { return id_; } 39 int id() const { return id_; }
41 ElementId element_id() const { return element_id_; } 40 ElementId element_id() const { return element_id_; }
42 41
43 // Parent AnimationHost. AnimationPlayer can be detached from 42 // Parent AnimationHost. AnimationPlayer can be detached from
44 // AnimationTimeline. 43 // AnimationTimeline.
45 AnimationHost* animation_host() { return animation_host_; } 44 AnimationHost* animation_host() { return animation_host_; }
(...skipping 22 matching lines...) Expand all
68 void AddAnimation(std::unique_ptr<Animation> animation); 67 void AddAnimation(std::unique_ptr<Animation> animation);
69 void PauseAnimation(int animation_id, double time_offset); 68 void PauseAnimation(int animation_id, double time_offset);
70 void RemoveAnimation(int animation_id); 69 void RemoveAnimation(int animation_id);
71 void AbortAnimation(int animation_id); 70 void AbortAnimation(int animation_id);
72 void AbortAnimations(TargetProperty::Type target_property, 71 void AbortAnimations(TargetProperty::Type target_property,
73 bool needs_completion); 72 bool needs_completion);
74 73
75 void PushPropertiesTo(AnimationPlayer* player_impl); 74 void PushPropertiesTo(AnimationPlayer* player_impl);
76 75
77 // AnimationDelegate routing. 76 // AnimationDelegate routing.
78 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 77 virtual void OnAnimationStarted(base::TimeTicks monotonic_time,
loyso (OOO) 2016/08/04 06:32:10 It's very sad to make it polymorphic only for the
loyso (OOO) 2016/08/04 06:50:37 I'm severely jet lagged but... Can we use Animatio
ymalik 2016/08/04 15:31:47 Yes, I am detaching the player from the timeline f
79 TargetProperty::Type target_property, 78 TargetProperty::Type target_property,
80 int group); 79 int group);
81 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 80 virtual void OnAnimationFinished(base::TimeTicks monotonic_time,
82 TargetProperty::Type target_property, 81 TargetProperty::Type target_property,
83 int group); 82 int group);
84 void NotifyAnimationAborted(base::TimeTicks monotonic_time, 83 virtual void OnAnimationAborted(base::TimeTicks monotonic_time,
85 TargetProperty::Type target_property, 84 TargetProperty::Type target_property,
86 int group); 85 int group);
87 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, 86 virtual void OnAnimationTakeover(base::TimeTicks monotonic_time,
88 TargetProperty::Type target_property, 87 TargetProperty::Type target_property,
89 double animation_start_time, 88 double animation_start_time,
90 std::unique_ptr<AnimationCurve> curve); 89 std::unique_ptr<AnimationCurve> curve);
91 90
92 // Whether this player has animations waiting to get sent to ElementAnimations 91 // Whether this player has animations waiting to get sent to ElementAnimations
93 bool has_pending_animations_for_testing() const { 92 bool has_pending_animations_for_testing() const {
94 return !animations_.empty(); 93 return !animations_.empty();
95 } 94 }
96 95
96 protected:
97 explicit AnimationPlayer(int id);
98 virtual ~AnimationPlayer();
99
97 private: 100 private:
98 friend class base::RefCounted<AnimationPlayer>; 101 friend class base::RefCounted<AnimationPlayer>;
99 102
100 explicit AnimationPlayer(int id);
101 ~AnimationPlayer();
102
103 void SetNeedsCommit(); 103 void SetNeedsCommit();
104 104
105 void RegisterPlayer(); 105 void RegisterPlayer();
106 void UnregisterPlayer(); 106 void UnregisterPlayer();
107 107
108 void BindElementAnimations(); 108 void BindElementAnimations();
109 void UnbindElementAnimations(); 109 void UnbindElementAnimations();
110 110
111 // We accumulate added animations in animations_ container 111 // We accumulate added animations in animations_ container
112 // if element_animations_ is a nullptr. It allows us to add/remove animations 112 // if element_animations_ is a nullptr. It allows us to add/remove animations
113 // to non-attached AnimationPlayers. 113 // to non-attached AnimationPlayers.
114 std::vector<std::unique_ptr<Animation>> animations_; 114 std::vector<std::unique_ptr<Animation>> animations_;
115 115
116 AnimationHost* animation_host_; 116 AnimationHost* animation_host_;
117 AnimationTimeline* animation_timeline_; 117 AnimationTimeline* animation_timeline_;
118 // element_animations isn't null if player attached to an element (layer). 118 // element_animations isn't null if player attached to an element (layer).
119 scoped_refptr<ElementAnimations> element_animations_; 119 scoped_refptr<ElementAnimations> element_animations_;
120 AnimationDelegate* animation_delegate_; 120 AnimationDelegate* animation_delegate_;
121 121
122 int id_; 122 int id_;
123 ElementId element_id_; 123 ElementId element_id_;
124 124
125 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); 125 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer);
126 }; 126 };
127 127
128 } // namespace cc 128 } // namespace cc
129 129
130 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_ 130 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/animation/animation_player.cc » ('j') | cc/animation/element_animations_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698