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

Unified Diff: cc/animation/element_animations.cc

Issue 2349643003: CC Animation: Extract PropertyAnimationState as a non-nested struct. (Closed)
Patch Set: Reparent to master to make it independent. Created 4 years, 2 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
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/property_animation_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/element_animations.cc
diff --git a/cc/animation/element_animations.cc b/cc/animation/element_animations.cc
index b9bdc0b80f87afd609fd1b4b06eb21c1c6e41945..abcf3113a5685b2acdcba82c90ccdee252c1fc12 100644
--- a/cc/animation/element_animations.cc
+++ b/cc/animation/element_animations.cc
@@ -538,7 +538,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_;
@@ -585,7 +585,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_;
@@ -600,68 +600,34 @@ 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());
ElementAnimations::PlayersList::Iterator it(players_list_.get());
AnimationPlayer* player;
while ((player = it.GetNext()) != nullptr) {
- 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 {
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/property_animation_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698