Index: cc/animation/animation_player.h |
diff --git a/cc/animation/animation_player.h b/cc/animation/animation_player.h |
index b20e0be217688723727f202a70a0ad64af268135..6e75399c9ad2f2abf67f77af268feca5a9283218 100644 |
--- a/cc/animation/animation_player.h |
+++ b/cc/animation/animation_player.h |
@@ -5,6 +5,7 @@ |
#ifndef CC_ANIMATION_ANIMATION_PLAYER_H_ |
#define CC_ANIMATION_ANIMATION_PLAYER_H_ |
+#include <bitset> |
#include <vector> |
#include "base/macros.h" |
@@ -13,14 +14,15 @@ |
#include "cc/animation/animation.h" |
#include "cc/animation/animation_curve.h" |
#include "cc/animation/element_animations.h" |
+#include "cc/animation/element_id.h" |
#include "cc/base/cc_export.h" |
namespace cc { |
class AnimationDelegate; |
+class AnimationEvents; |
class AnimationHost; |
class AnimationTimeline; |
-class ElementAnimations; |
// An AnimationPlayer owns all animations to be run on particular CC Layer. |
// Multiple AnimationPlayers can be attached to one layer. In this case, |
@@ -73,20 +75,16 @@ class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> { |
void PushPropertiesTo(AnimationPlayer* player_impl); |
// AnimationDelegate routing. |
- void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
- TargetProperty::Type target_property, |
- int group); |
- void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
- TargetProperty::Type target_property, |
- int group); |
- void NotifyAnimationAborted(base::TimeTicks monotonic_time, |
- TargetProperty::Type target_property, |
- int group); |
- void NotifyAnimationWaitingForDeletion(); |
- void NotifyAnimationTakeover(base::TimeTicks monotonic_time, |
- TargetProperty::Type target_property, |
- double animation_start_time, |
- std::unique_ptr<AnimationCurve> curve); |
+ bool NotifyAnimationStarted(const AnimationEvent& event); |
+ bool NotifyAnimationFinished(const AnimationEvent& event); |
+ bool NotifyAnimationAborted(const AnimationEvent& event); |
+ void NotifyAnimationTakeover(const AnimationEvent& event); |
+ bool NotifyAnimationFinishedForTesting(TargetProperty::Type target_property, |
+ int group_id); |
+ |
+ // Returns true if there are any animations that have neither finished nor |
+ // aborted. |
+ bool HasActiveAnimation() const; |
// Returns true if there are any animations at all to process. |
bool has_any_animation() const { return !animations_.empty(); } |
@@ -94,12 +92,78 @@ class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> { |
bool needs_push_properties() const { return needs_push_properties_; } |
void SetNeedsPushProperties(); |
+ bool HasNonDeletedAnimation() const; |
+ |
+ using Animations = std::vector<std::unique_ptr<Animation>>; |
+ const Animations& animations() const { return animations_; } |
+ |
+ bool needs_to_start_animations() const { return needs_to_start_animations_; } |
+ |
+ void StartAnimations(base::TimeTicks monotonic_time); |
+ void PromoteStartedAnimations(base::TimeTicks monotonic_time, |
+ AnimationEvents* events); |
+ void MarkAnimationsForDeletion(base::TimeTicks monotonic_time, |
+ AnimationEvents* events); |
+ void TickAnimations(base::TimeTicks monotonic_time); |
+ void MarkFinishedAnimations(base::TimeTicks monotonic_time); |
+ |
+ // Make animations affect active elements if and only if they affect |
+ // pending elements. Any animations that no longer affect any elements |
+ // are deleted. |
+ void ActivateAnimations(bool* changed_transform_animation, |
+ bool* changed_opacity_animation, |
+ bool* changed_filter_animation); |
+ |
+ bool HasFilterAnimationThatInflatesBounds() const; |
+ bool HasTransformAnimationThatInflatesBounds() const; |
+ |
+ bool TransformAnimationBoundsForBox(const gfx::BoxF& box, |
+ gfx::BoxF* bounds) const; |
+ bool HasAnimationThatAffectsScale() const; |
+ bool HasOnlyTranslationTransforms(ElementListType list_type) const; |
+ bool AnimationsPreserveAxisAlignment() const; |
+ |
+ // Sets |start_scale| to the maximum of starting animation scale along any |
+ // dimension at any destination in active animations. Returns false if the |
+ // starting scale cannot be computed. |
+ bool AnimationStartScale(ElementListType list_type, float* start_scale) const; |
+ |
+ // Sets |max_scale| to the maximum scale along any dimension at any |
+ // destination in active animations. Returns false if the maximum scale cannot |
+ // be computed. |
+ bool MaximumTargetScale(ElementListType list_type, float* max_scale) const; |
+ |
+ // Returns true if there is an animation that is either currently animating |
+ // the given property or scheduled to animate this property in the future, and |
+ // that affects the given tree type. |
+ bool IsPotentiallyAnimatingProperty(TargetProperty::Type target_property, |
+ ElementListType list_type) const; |
+ |
+ // Returns true if there is an animation that is currently animating the given |
+ // property and that affects the given tree type. |
+ bool IsCurrentlyAnimatingProperty(TargetProperty::Type target_property, |
+ ElementListType list_type) const; |
+ |
+ bool HasElementInActiveList() const; |
+ gfx::ScrollOffset ScrollOffsetForAnimation() const; |
+ |
+ // Returns the active animation animating the given property that is either |
+ // running, or is next to run, if such an animation exists. |
+ Animation* GetAnimation(TargetProperty::Type target_property) const; |
+ |
+ // Returns the active animation for the given unique animation id. |
+ Animation* GetAnimationById(int animation_id) const; |
+ |
private: |
friend class base::RefCounted<AnimationPlayer>; |
explicit AnimationPlayer(int id); |
~AnimationPlayer(); |
+ // A set of target properties. TargetProperty must be 0-based enum. |
+ using TargetProperties = |
+ std::bitset<TargetProperty::LAST_TARGET_PROPERTY + 1>; |
+ |
void SetNeedsCommit(); |
void RegisterPlayer(); |
@@ -108,10 +172,18 @@ class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> { |
void BindElementAnimations(); |
void UnbindElementAnimations(); |
- // We accumulate added animations in animations_ container |
- // if element_animations_ is a nullptr. It allows us to add/remove animations |
- // to non-attached AnimationPlayers. |
- std::vector<std::unique_ptr<Animation>> animations_; |
+ void AnimationAddedForProperty(TargetProperty::Type target_property); |
+ |
+ void MarkAbortedAnimationsForDeletion( |
+ AnimationPlayer* animation_player_impl) const; |
+ void PurgeAnimationsMarkedForDeletion(); |
+ void PushNewAnimationsToImplThread( |
+ AnimationPlayer* animation_player_impl) const; |
+ void RemoveAnimationsCompletedOnMainThread( |
+ AnimationPlayer* animation_player_impl) const; |
+ void PushPropertiesToImplThread(AnimationPlayer* animation_player_impl); |
+ |
+ Animations animations_; |
AnimationHost* animation_host_; |
AnimationTimeline* animation_timeline_; |
@@ -122,6 +194,11 @@ class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> { |
int id_; |
ElementId element_id_; |
bool needs_push_properties_; |
+ base::TimeTicks last_tick_time_; |
+ |
+ // Only try to start animations when new animations are added or when the |
+ // previous attempt at starting animations failed to start all animations. |
+ bool needs_to_start_animations_; |
DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); |
}; |