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

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

Issue 2538973002: CC Animation: Make AnimationPlayer to be a unit of activation. (Closed)
Patch Set: Move ScrollOffsetAnimationWasInterrupted to AnimationPlayer Created 4 years 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/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "cc/animation/animation.h" 13 #include "cc/animation/animation.h"
14 #include "cc/animation/animation_curve.h" 14 #include "cc/animation/animation_curve.h"
15 #include "cc/animation/animation_export.h" 15 #include "cc/animation/animation_export.h"
16 #include "cc/animation/element_animations.h" 16 #include "cc/animation/element_animations.h"
17 #include "cc/trees/element_id.h" 17 #include "cc/trees/element_id.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 class AnimationDelegate; 21 class AnimationDelegate;
22 class AnimationEvents;
22 class AnimationHost; 23 class AnimationHost;
23 class AnimationTimeline; 24 class AnimationTimeline;
24 struct AnimationEvent; 25 struct AnimationEvent;
25 struct PropertyAnimationState; 26 struct PropertyAnimationState;
26 27
27 // An AnimationPlayer owns all animations to be run on particular CC Layer. 28 // An AnimationPlayer owns all animations to be run on particular CC Layer.
28 // Multiple AnimationPlayers can be attached to one layer. In this case, 29 // Multiple AnimationPlayers can be attached to one layer. In this case,
29 // they share common ElementAnimations so the 30 // they share common ElementAnimations so the
30 // ElementAnimations-to-Layer relationship is 1:1. 31 // ElementAnimations-to-Layer relationship is 1:1.
31 // For now, the blink logic is responsible for handling of conflicting 32 // For now, the blink logic is responsible for handling of conflicting
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 69
69 void AddAnimation(std::unique_ptr<Animation> animation); 70 void AddAnimation(std::unique_ptr<Animation> animation);
70 void PauseAnimation(int animation_id, double time_offset); 71 void PauseAnimation(int animation_id, double time_offset);
71 void RemoveAnimation(int animation_id); 72 void RemoveAnimation(int animation_id);
72 void AbortAnimation(int animation_id); 73 void AbortAnimation(int animation_id);
73 void AbortAnimations(TargetProperty::Type target_property, 74 void AbortAnimations(TargetProperty::Type target_property,
74 bool needs_completion); 75 bool needs_completion);
75 76
76 void PushPropertiesTo(AnimationPlayer* player_impl); 77 void PushPropertiesTo(AnimationPlayer* player_impl);
77 78
79 void Animate(base::TimeTicks monotonic_time);
80 void UpdateState(bool start_ready_animations, AnimationEvents* events);
81
82 void UpdateActivation(ActivationType type);
83 void Deactivate();
84
78 // AnimationDelegate routing. 85 // AnimationDelegate routing.
79 bool NotifyAnimationStarted(const AnimationEvent& event); 86 bool NotifyAnimationStarted(const AnimationEvent& event);
80 bool NotifyAnimationFinished(const AnimationEvent& event); 87 bool NotifyAnimationFinished(const AnimationEvent& event);
81 bool NotifyAnimationAborted(const AnimationEvent& event); 88 bool NotifyAnimationAborted(const AnimationEvent& event);
82 void NotifyAnimationTakeover(const AnimationEvent& event); 89 void NotifyAnimationTakeover(const AnimationEvent& event);
83 bool NotifyAnimationFinishedForTesting(TargetProperty::Type target_property, 90 bool NotifyAnimationFinishedForTesting(TargetProperty::Type target_property,
84 int group_id); 91 int group_id);
85 92
86 // Returns true if there are any animations that have neither finished nor 93 // Returns true if there are any animations that have neither finished nor
87 // aborted. 94 // aborted.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Returns the active animation animating the given property that is either 152 // Returns the active animation animating the given property that is either
146 // running, or is next to run, if such an animation exists. 153 // running, or is next to run, if such an animation exists.
147 Animation* GetAnimation(TargetProperty::Type target_property) const; 154 Animation* GetAnimation(TargetProperty::Type target_property) const;
148 155
149 // Returns the active animation for the given unique animation id. 156 // Returns the active animation for the given unique animation id.
150 Animation* GetAnimationById(int animation_id) const; 157 Animation* GetAnimationById(int animation_id) const;
151 158
152 void GetPropertyAnimationState(PropertyAnimationState* pending_state, 159 void GetPropertyAnimationState(PropertyAnimationState* pending_state,
153 PropertyAnimationState* active_state) const; 160 PropertyAnimationState* active_state) const;
154 161
162 // When a scroll animation is removed on the main thread, its compositor
163 // thread counterpart continues producing scroll deltas until activation.
164 // These scroll deltas need to be cleared at activation, so that the active
165 // element's scroll offset matches the offset provided by the main thread
166 // rather than a combination of this offset and scroll deltas produced by
167 // the removed animation. This is to provide the illusion of synchronicity to
168 // JS that simultaneously removes an animation and sets the scroll offset.
169 bool scroll_offset_animation_was_interrupted() const {
170 return scroll_offset_animation_was_interrupted_;
171 }
172
155 private: 173 private:
156 friend class base::RefCounted<AnimationPlayer>; 174 friend class base::RefCounted<AnimationPlayer>;
157 175
158 explicit AnimationPlayer(int id); 176 explicit AnimationPlayer(int id);
159 ~AnimationPlayer(); 177 ~AnimationPlayer();
160 178
161 void SetNeedsCommit(); 179 void SetNeedsCommit();
162 180
163 void RegisterPlayer(); 181 void RegisterPlayer();
164 void UnregisterPlayer(); 182 void UnregisterPlayer();
(...skipping 23 matching lines...) Expand all
188 206
189 int id_; 207 int id_;
190 ElementId element_id_; 208 ElementId element_id_;
191 bool needs_push_properties_; 209 bool needs_push_properties_;
192 base::TimeTicks last_tick_time_; 210 base::TimeTicks last_tick_time_;
193 211
194 // Only try to start animations when new animations are added or when the 212 // Only try to start animations when new animations are added or when the
195 // previous attempt at starting animations failed to start all animations. 213 // previous attempt at starting animations failed to start all animations.
196 bool needs_to_start_animations_; 214 bool needs_to_start_animations_;
197 215
216 // This is used to ensure that we don't spam the animation host.
217 bool is_active_;
218
219 bool scroll_offset_animation_was_interrupted_;
220
198 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); 221 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer);
199 }; 222 };
200 223
201 } // namespace cc 224 } // namespace cc
202 225
203 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_ 226 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698