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

Unified Diff: cc/animation/element_animations.cc

Issue 2349643003: CC Animation: Extract PropertyAnimationState as a non-nested struct. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: cc/animation/element_animations.cc
diff --git a/cc/animation/element_animations.cc b/cc/animation/element_animations.cc
index bf645075be24ea6256e0e76cb662591db234d17e..1654bdaa85e9f5adc5e245a0577d472d179b9ec4 100644
--- a/cc/animation/element_animations.cc
+++ b/cc/animation/element_animations.cc
@@ -500,7 +500,7 @@ void ElementAnimations::NotifyClientAnimationChanged(
ElementListType list_type,
bool notify_elements_about_potential_animation,
bool notify_elements_about_running_animation) {
- struct PropertyAnimationState* animation_state = nullptr;
+ PropertyAnimationState* animation_state = nullptr;
switch (property) {
case TargetProperty::OPACITY:
animation_state = &opacity_animation_state_;
@@ -547,7 +547,7 @@ void ElementAnimations::NotifyClientAnimationChanged(
void ElementAnimations::UpdateClientAnimationStateInternal(
TargetProperty::Type property) {
- struct PropertyAnimationState* animation_state = nullptr;
+ PropertyAnimationState* animation_state = nullptr;
switch (property) {
case TargetProperty::OPACITY:
animation_state = &opacity_animation_state_;
@@ -562,66 +562,32 @@ void ElementAnimations::UpdateClientAnimationStateInternal(
NOTREACHED();
break;
}
- bool was_currently_running_animation_for_active_elements =
- animation_state->currently_running_for_active_elements;
- bool was_currently_running_animation_for_pending_elements =
- animation_state->currently_running_for_pending_elements;
- bool was_potentially_animating_for_active_elements =
- animation_state->potentially_animating_for_active_elements;
- bool was_potentially_animating_for_pending_elements =
- animation_state->potentially_animating_for_pending_elements;
+ PropertyAnimationState previous_state = *animation_state;
animation_state->Clear();
- DCHECK(was_potentially_animating_for_active_elements ||
- !was_currently_running_animation_for_active_elements);
- DCHECK(was_potentially_animating_for_pending_elements ||
- !was_currently_running_animation_for_pending_elements);
+ DCHECK(previous_state.IsValid());
for (auto& player : players_list_) {
- for (const auto& animation : player.animations()) {
- if (!animation->is_finished() &&
- animation->target_property() == property) {
- animation_state->potentially_animating_for_active_elements |=
- animation->affects_active_elements();
- animation_state->potentially_animating_for_pending_elements |=
- animation->affects_pending_elements();
- animation_state->currently_running_for_active_elements |=
- animation->affects_active_elements() &&
- animation->InEffect(last_tick_time_);
- animation_state->currently_running_for_pending_elements |=
- animation->affects_pending_elements() &&
- animation->InEffect(last_tick_time_);
- }
- }
+ PropertyAnimationState player_state;
+ player.GetPropertyAnimationStateFor(property, &player_state);
+ *animation_state |= player_state;
}
- bool potentially_animating_changed_for_active_elements =
- was_potentially_animating_for_active_elements !=
- animation_state->potentially_animating_for_active_elements;
- bool potentially_animating_changed_for_pending_elements =
- was_potentially_animating_for_pending_elements !=
- animation_state->potentially_animating_for_pending_elements;
- bool currently_running_animation_changed_for_active_elements =
- was_currently_running_animation_for_active_elements !=
- animation_state->currently_running_for_active_elements;
- bool currently_running_animation_changed_for_pending_elements =
- was_currently_running_animation_for_pending_elements !=
- animation_state->currently_running_for_pending_elements;
- if (!potentially_animating_changed_for_active_elements &&
- !potentially_animating_changed_for_pending_elements &&
- !currently_running_animation_changed_for_active_elements &&
- !currently_running_animation_changed_for_pending_elements)
+ if (*animation_state == previous_state)
return;
+
+ PropertyAnimationState diff_state = previous_state ^ *animation_state;
+
if (has_element_in_active_list())
NotifyClientAnimationChanged(
property, ElementListType::ACTIVE,
- potentially_animating_changed_for_active_elements,
- currently_running_animation_changed_for_active_elements);
+ diff_state.potentially_animating_for_active_elements,
+ diff_state.currently_running_for_active_elements);
if (has_element_in_pending_list())
NotifyClientAnimationChanged(
property, ElementListType::PENDING,
- potentially_animating_changed_for_pending_elements,
- currently_running_animation_changed_for_pending_elements);
+ diff_state.potentially_animating_for_pending_elements,
+ diff_state.currently_running_for_pending_elements);
}
bool ElementAnimations::HasActiveAnimation() const {

Powered by Google App Engine
This is Rietveld 408576698