OLD | NEW |
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_ELEMENT_ANIMATIONS_H_ | 5 #ifndef CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_ | 6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "cc/animation/animation.h" | 15 #include "cc/animation/element_id.h" |
16 #include "cc/animation/animation_curve.h" | |
17 #include "cc/animation/animation_events.h" | |
18 #include "cc/animation/property_animation_state.h" | 16 #include "cc/animation/property_animation_state.h" |
19 #include "cc/animation/target_property.h" | 17 #include "cc/animation/target_property.h" |
20 #include "cc/base/cc_export.h" | 18 #include "cc/base/cc_export.h" |
21 #include "ui/gfx/geometry/scroll_offset.h" | 19 #include "ui/gfx/geometry/scroll_offset.h" |
22 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
23 | 21 |
24 namespace gfx { | 22 namespace gfx { |
25 class BoxF; | 23 class BoxF; |
26 } | 24 } |
27 | 25 |
28 namespace cc { | 26 namespace cc { |
29 | 27 |
30 class AnimationDelegate; | 28 class AnimationDelegate; |
31 class AnimationEvents; | 29 class AnimationEvents; |
32 class AnimationHost; | 30 class AnimationHost; |
33 class AnimationPlayer; | 31 class AnimationPlayer; |
34 class FilterOperations; | 32 class FilterOperations; |
35 class KeyframeValueList; | |
36 enum class ElementListType; | 33 enum class ElementListType; |
37 enum class AnimationChangeType; | 34 struct AnimationEvent; |
38 | 35 |
39 // An ElementAnimations owns a list of all AnimationPlayers, attached to | 36 // An ElementAnimations owns a list of all AnimationPlayers, attached to |
40 // the element. | 37 // the element. |
41 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship). | 38 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship). |
42 // No pointer to/from respective blink::ElementAnimations object for now. | 39 // No pointer to/from respective blink::ElementAnimations object for now. |
43 class CC_EXPORT ElementAnimations : public base::RefCounted<ElementAnimations> { | 40 class CC_EXPORT ElementAnimations : public base::RefCounted<ElementAnimations> { |
44 public: | 41 public: |
45 static scoped_refptr<ElementAnimations> Create(); | 42 static scoped_refptr<ElementAnimations> Create(); |
46 | 43 |
47 ElementId element_id() const { return element_id_; } | 44 ElementId element_id() const { return element_id_; } |
(...skipping 16 matching lines...) Expand all Loading... |
64 | 61 |
65 typedef base::ObserverList<AnimationPlayer> PlayersList; | 62 typedef base::ObserverList<AnimationPlayer> PlayersList; |
66 PlayersList& players_list() const { return *players_list_.get(); } | 63 PlayersList& players_list() const { return *players_list_.get(); } |
67 | 64 |
68 // Ensures that the list of active animations on the main thread and the impl | 65 // Ensures that the list of active animations on the main thread and the impl |
69 // thread are kept in sync. This function does not take ownership of the impl | 66 // thread are kept in sync. This function does not take ownership of the impl |
70 // thread ElementAnimations. | 67 // thread ElementAnimations. |
71 void PushPropertiesTo( | 68 void PushPropertiesTo( |
72 scoped_refptr<ElementAnimations> element_animations_impl); | 69 scoped_refptr<ElementAnimations> element_animations_impl); |
73 | 70 |
74 void AddAnimation(std::unique_ptr<Animation> animation); | |
75 void PauseAnimation(int animation_id, base::TimeDelta time_offset); | |
76 void RemoveAnimation(int animation_id); | |
77 void AbortAnimation(int animation_id); | |
78 void AbortAnimations(TargetProperty::Type target_property, | |
79 bool needs_completion = false); | |
80 | |
81 void Animate(base::TimeTicks monotonic_time); | 71 void Animate(base::TimeTicks monotonic_time); |
82 | 72 |
83 void UpdateState(bool start_ready_animations, AnimationEvents* events); | 73 void UpdateState(bool start_ready_animations, AnimationEvents* events); |
84 | 74 |
85 // Make animations affect active elements if and only if they affect | 75 // Make animations affect active elements if and only if they affect |
86 // pending elements. Any animations that no longer affect any elements | 76 // pending elements. Any animations that no longer affect any elements |
87 // are deleted. | 77 // are deleted. |
88 void ActivateAnimations(); | 78 void ActivateAnimations(); |
89 | 79 |
90 // Returns the active animation animating the given property that is either | |
91 // running, or is next to run, if such an animation exists. | |
92 Animation* GetAnimation(TargetProperty::Type target_property) const; | |
93 | |
94 // Returns the active animation for the given unique animation id. | |
95 Animation* GetAnimationById(int animation_id) const; | |
96 | |
97 // Returns true if there are any animations that have neither finished nor | 80 // Returns true if there are any animations that have neither finished nor |
98 // aborted. | 81 // aborted. |
99 bool HasActiveAnimation() const; | 82 bool HasActiveAnimation() const; |
100 | 83 |
101 // Returns true if there are any animations at all to process. | 84 // Returns true if there are any animations at all to process. |
102 bool HasAnyAnimation() const; | 85 bool HasAnyAnimation() const; |
103 | 86 |
| 87 bool HasAnyAnimationTargetingProperty(TargetProperty::Type property) const; |
| 88 |
104 // Returns true if there is an animation that is either currently animating | 89 // Returns true if there is an animation that is either currently animating |
105 // the given property or scheduled to animate this property in the future, and | 90 // the given property or scheduled to animate this property in the future, and |
106 // that affects the given tree type. | 91 // that affects the given tree type. |
107 bool IsPotentiallyAnimatingProperty(TargetProperty::Type target_property, | 92 bool IsPotentiallyAnimatingProperty(TargetProperty::Type target_property, |
108 ElementListType list_type) const; | 93 ElementListType list_type) const; |
109 | 94 |
110 // Returns true if there is an animation that is currently animating the given | 95 // Returns true if there is an animation that is currently animating the given |
111 // property and that affects the given tree type. | 96 // property and that affects the given tree type. |
112 bool IsCurrentlyAnimatingProperty(TargetProperty::Type target_property, | 97 bool IsCurrentlyAnimatingProperty(TargetProperty::Type target_property, |
113 ElementListType list_type) const; | 98 ElementListType list_type) const; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // These scroll deltas need to be cleared at activation, so that the active | 151 // These scroll deltas need to be cleared at activation, so that the active |
167 // element's scroll offset matches the offset provided by the main thread | 152 // element's scroll offset matches the offset provided by the main thread |
168 // rather than a combination of this offset and scroll deltas produced by | 153 // rather than a combination of this offset and scroll deltas produced by |
169 // the removed animation. This is to provide the illusion of synchronicity to | 154 // the removed animation. This is to provide the illusion of synchronicity to |
170 // JS that simultaneously removes an animation and sets the scroll offset. | 155 // JS that simultaneously removes an animation and sets the scroll offset. |
171 bool scroll_offset_animation_was_interrupted() const { | 156 bool scroll_offset_animation_was_interrupted() const { |
172 return scroll_offset_animation_was_interrupted_; | 157 return scroll_offset_animation_was_interrupted_; |
173 } | 158 } |
174 void SetScrollOffsetAnimationWasInterrupted(); | 159 void SetScrollOffsetAnimationWasInterrupted(); |
175 | 160 |
176 // TODO(loyso): Erase it, use AnimationPlayer's one. | |
177 bool needs_to_start_animations_for_testing() const; | |
178 | |
179 void SetNeedsPushProperties(); | 161 void SetNeedsPushProperties(); |
180 bool needs_push_properties() const { return needs_push_properties_; } | 162 bool needs_push_properties() const { return needs_push_properties_; } |
181 | 163 |
182 void UpdateClientAnimationState(); | 164 void UpdateClientAnimationState(); |
183 void SetNeedsUpdateImplClientState(); | 165 void SetNeedsUpdateImplClientState(); |
184 | 166 |
185 void UpdateActivationNormal(); | 167 void UpdateActivationNormal(); |
186 | 168 |
187 void NotifyClientOpacityAnimated(float opacity, | 169 void NotifyClientOpacityAnimated(float opacity, |
188 bool notify_active_elements, | 170 bool notify_active_elements, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 PropertyAnimationState pending_state_; | 219 PropertyAnimationState pending_state_; |
238 | 220 |
239 bool needs_update_impl_client_state_; | 221 bool needs_update_impl_client_state_; |
240 | 222 |
241 DISALLOW_COPY_AND_ASSIGN(ElementAnimations); | 223 DISALLOW_COPY_AND_ASSIGN(ElementAnimations); |
242 }; | 224 }; |
243 | 225 |
244 } // namespace cc | 226 } // namespace cc |
245 | 227 |
246 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_ | 228 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_ |
OLD | NEW |