Index: cc/animation/animation_player.cc |
diff --git a/cc/animation/animation_player.cc b/cc/animation/animation_player.cc |
index 01ba0125121d7c0dd4d38eb654514ebf9cb89755..35302143e779a7b2e6463e83d9d8356899c4de89 100644 |
--- a/cc/animation/animation_player.cc |
+++ b/cc/animation/animation_player.cc |
@@ -160,9 +160,8 @@ void AnimationPlayer::PauseAnimation(int animation_id, double time_offset) { |
} |
void AnimationPlayer::RemoveAnimation(int animation_id) { |
- bool removed_transform_animation = false; |
- bool removed_opacity_animation = false; |
- bool removed_filter_animation = false; |
+ TargetProperties properties_animation_removed; |
+ |
// Since we want to use the animations that we're going to remove, we need to |
// use a stable_parition here instead of remove_if. Remove_if leaves the |
// removed items in an unspecified state. |
@@ -175,15 +174,8 @@ void AnimationPlayer::RemoveAnimation(int animation_id) { |
if ((*it)->target_property() == TargetProperty::SCROLL_OFFSET) { |
if (element_animations_) |
element_animations_->SetScrollOffsetAnimationWasInterrupted(); |
- } else if ((*it)->target_property() == TargetProperty::TRANSFORM && |
- !(*it)->is_finished()) { |
- removed_transform_animation = true; |
- } else if ((*it)->target_property() == TargetProperty::OPACITY && |
- !(*it)->is_finished()) { |
- removed_opacity_animation = true; |
- } else if ((*it)->target_property() == TargetProperty::FILTER && |
- !(*it)->is_finished()) { |
- removed_filter_animation = true; |
+ } else if (!(*it)->is_finished()) { |
+ properties_animation_removed[(*it)->target_property()] = true; |
} |
} |
@@ -191,9 +183,8 @@ void AnimationPlayer::RemoveAnimation(int animation_id) { |
if (element_animations_) { |
element_animations_->UpdateActivationNormal(); |
- element_animations_->UpdateClientAnimationState(removed_transform_animation, |
- removed_opacity_animation, |
- removed_filter_animation); |
+ element_animations_->UpdateClientAnimationState( |
+ properties_animation_removed); |
SetNeedsCommit(); |
SetNeedsPushProperties(); |
} |
@@ -447,8 +438,6 @@ void AnimationPlayer::StartAnimations(base::TimeTicks monotonic_time) { |
// case, the group's target properties need to be added to the lists of |
// blocked properties. |
bool null_intersection = true; |
- static_assert(TargetProperty::FIRST_TARGET_PROPERTY == 0, |
- "TargetProperty must be 0-based enum"); |
for (int property = TargetProperty::FIRST_TARGET_PROPERTY; |
property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { |
if (enqueued_properties[property]) { |
@@ -726,40 +715,28 @@ void AnimationPlayer::TickAnimations(base::TimeTicks monotonic_time) { |
} |
void AnimationPlayer::MarkFinishedAnimations(base::TimeTicks monotonic_time) { |
- bool finished_transform_animation = false; |
- bool finished_opacity_animation = false; |
- bool finished_filter_animation = false; |
+ TargetProperties properties_animation_finished; |
+ |
for (size_t i = 0; i < animations_.size(); ++i) { |
if (!animations_[i]->is_finished() && |
animations_[i]->IsFinishedAt(monotonic_time)) { |
animations_[i]->SetRunState(Animation::FINISHED, monotonic_time); |
- if (animations_[i]->target_property() == TargetProperty::TRANSFORM) |
- finished_transform_animation = true; |
- else if (animations_[i]->target_property() == TargetProperty::OPACITY) |
- finished_opacity_animation = true; |
- else if (animations_[i]->target_property() == TargetProperty::FILTER) |
- finished_filter_animation = true; |
+ properties_animation_finished[animations_[i]->target_property()] = true; |
} |
} |
DCHECK(element_animations_); |
- element_animations_->UpdateClientAnimationState(finished_transform_animation, |
- finished_opacity_animation, |
- finished_filter_animation); |
+ element_animations_->UpdateClientAnimationState( |
+ properties_animation_finished); |
} |
-void AnimationPlayer::ActivateAnimations(bool* changed_transform_animation, |
- bool* changed_opacity_animation, |
- bool* changed_filter_animation) { |
+TargetProperties AnimationPlayer::ActivateAnimations() { |
+ TargetProperties activated_properties; |
+ |
for (size_t i = 0; i < animations_.size(); ++i) { |
if (animations_[i]->affects_active_elements() != |
animations_[i]->affects_pending_elements()) { |
- if (animations_[i]->target_property() == TargetProperty::TRANSFORM) |
- *changed_transform_animation = true; |
- else if (animations_[i]->target_property() == TargetProperty::OPACITY) |
- *changed_opacity_animation = true; |
- else if (animations_[i]->target_property() == TargetProperty::FILTER) |
- *changed_filter_animation = true; |
+ activated_properties[animations_[i]->target_property()] = true; |
} |
animations_[i]->set_affects_active_elements( |
animations_[i]->affects_pending_elements()); |
@@ -771,6 +748,8 @@ void AnimationPlayer::ActivateAnimations(bool* changed_transform_animation, |
animations_.erase(std::remove_if(animations_.begin(), animations_.end(), |
affects_no_elements), |
animations_.end()); |
+ |
+ return activated_properties; |
} |
bool AnimationPlayer::HasFilterAnimationThatInflatesBounds() const { |
@@ -1011,31 +990,36 @@ Animation* AnimationPlayer::GetAnimationById(int animation_id) const { |
return nullptr; |
} |
-void AnimationPlayer::GetPropertyAnimationStateFor( |
- TargetProperty::Type property, |
- PropertyAnimationState* state) const { |
- state->Clear(); |
+void AnimationPlayer::GetPropertyAnimationState( |
+ PropertyAnimationState* pending_state, |
+ PropertyAnimationState* active_state) const { |
+ pending_state->Clear(); |
+ active_state->Clear(); |
+ |
for (const auto& animation : animations_) { |
- if (!animation->is_finished() && animation->target_property() == property) { |
- state->potentially_animating_for_active_elements |= |
- animation->affects_active_elements(); |
- state->potentially_animating_for_pending_elements |= |
- animation->affects_pending_elements(); |
- state->currently_running_for_active_elements |= |
- animation->affects_active_elements() && |
- animation->InEffect(last_tick_time_); |
- state->currently_running_for_pending_elements |= |
- animation->affects_pending_elements() && |
- animation->InEffect(last_tick_time_); |
+ if (!animation->is_finished()) { |
+ bool in_effect = animation->InEffect(last_tick_time_); |
+ bool active = animation->affects_active_elements(); |
+ bool pending = animation->affects_pending_elements(); |
+ TargetProperty::Type property = animation->target_property(); |
+ |
+ if (pending) |
+ pending_state->potentially_animating[property] = true; |
+ if (pending && in_effect) |
+ pending_state->currently_running[property] = true; |
+ |
+ if (active) |
+ active_state->potentially_animating[property] = true; |
+ if (active && in_effect) |
+ active_state->currently_running[property] = true; |
} |
} |
} |
void AnimationPlayer::MarkAbortedAnimationsForDeletion( |
AnimationPlayer* animation_player_impl) const { |
- bool aborted_transform_animation = false; |
- bool aborted_opacity_animation = false; |
- bool aborted_filter_animation = false; |
+ TargetProperties properties_animation_aborted; |
+ |
auto& animations_impl = animation_player_impl->animations_; |
for (const auto& animation_impl : animations_impl) { |
// If the animation has been aborted on the main thread, mark it for |
@@ -1046,20 +1030,14 @@ void AnimationPlayer::MarkAbortedAnimationsForDeletion( |
animation_player_impl->last_tick_time_); |
animation->SetRunState(Animation::WAITING_FOR_DELETION, |
last_tick_time_); |
- if (animation_impl->target_property() == TargetProperty::TRANSFORM) |
- aborted_transform_animation = true; |
- else if (animation_impl->target_property() == TargetProperty::OPACITY) |
- aborted_opacity_animation = true; |
- else if (animation_impl->target_property() == TargetProperty::FILTER) |
- aborted_filter_animation = true; |
+ properties_animation_aborted[animation_impl->target_property()] = true; |
} |
} |
} |
if (element_animations_) |
element_animations_->SetNeedsUpdateImplClientState( |
- aborted_transform_animation, aborted_opacity_animation, |
- aborted_filter_animation); |
+ properties_animation_aborted); |
} |
void AnimationPlayer::PurgeAnimationsMarkedForDeletion() { |
@@ -1122,9 +1100,8 @@ static bool IsCompleted(Animation* animation, |
void AnimationPlayer::RemoveAnimationsCompletedOnMainThread( |
AnimationPlayer* animation_player_impl) const { |
- bool removed_transform_animation = false; |
- bool removed_opacity_animation = false; |
- bool removed_filter_animation = false; |
+ TargetProperties properties_animation_completed; |
+ |
// Animations removed on the main thread should no longer affect pending |
// elements, and should stop affecting active elements after the next call |
// to ActivateAnimations. If already WAITING_FOR_DELETION, they can be removed |
@@ -1133,12 +1110,7 @@ void AnimationPlayer::RemoveAnimationsCompletedOnMainThread( |
for (const auto& animation : animations) { |
if (IsCompleted(animation.get(), this)) { |
animation->set_affects_pending_elements(false); |
- if (animation->target_property() == TargetProperty::TRANSFORM) |
- removed_transform_animation = true; |
- else if (animation->target_property() == TargetProperty::OPACITY) |
- removed_opacity_animation = true; |
- else if (animation->target_property() == TargetProperty::FILTER) |
- removed_filter_animation = true; |
+ properties_animation_completed[animation->target_property()] = true; |
} |
} |
auto affects_active_only_and_is_waiting_for_deletion = |
@@ -1153,8 +1125,7 @@ void AnimationPlayer::RemoveAnimationsCompletedOnMainThread( |
if (element_animations_) |
element_animations_->SetNeedsUpdateImplClientState( |
- removed_transform_animation, removed_opacity_animation, |
- removed_filter_animation); |
+ properties_animation_completed); |
} |
void AnimationPlayer::PushPropertiesToImplThread( |