| 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 #include "cc/animation/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 void ElementAnimations::SetElementId(ElementId element_id) { | 42 void ElementAnimations::SetElementId(ElementId element_id) { |
| 43 element_id_ = element_id; | 43 element_id_ = element_id; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void ElementAnimations::InitAffectedElementTypes() { | 46 void ElementAnimations::InitAffectedElementTypes() { |
| 47 DCHECK(element_id_); | 47 DCHECK(element_id_); |
| 48 DCHECK(animation_host_); | 48 DCHECK(animation_host_); |
| 49 | 49 |
| 50 UpdateActivation(ActivationType::FORCE); | 50 UpdatePlayersTickingState(UpdateTickingType::FORCE); |
| 51 | 51 |
| 52 DCHECK(animation_host_->mutator_host_client()); | 52 DCHECK(animation_host_->mutator_host_client()); |
| 53 if (animation_host_->mutator_host_client()->IsElementInList( | 53 if (animation_host_->mutator_host_client()->IsElementInList( |
| 54 element_id_, ElementListType::ACTIVE)) { | 54 element_id_, ElementListType::ACTIVE)) { |
| 55 set_has_element_in_active_list(true); | 55 set_has_element_in_active_list(true); |
| 56 } | 56 } |
| 57 if (animation_host_->mutator_host_client()->IsElementInList( | 57 if (animation_host_->mutator_host_client()->IsElementInList( |
| 58 element_id_, ElementListType::PENDING)) { | 58 element_id_, ElementListType::PENDING)) { |
| 59 set_has_element_in_pending_list(true); | 59 set_has_element_in_pending_list(true); |
| 60 } | 60 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 } | 83 } |
| 84 set_has_element_in_active_list(false); | 84 set_has_element_in_active_list(false); |
| 85 | 85 |
| 86 if (has_element_in_pending_list()) { | 86 if (has_element_in_pending_list()) { |
| 87 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( | 87 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 88 element_id(), ElementListType::PENDING, disabled_state_mask, | 88 element_id(), ElementListType::PENDING, disabled_state_mask, |
| 89 disabled_state); | 89 disabled_state); |
| 90 } | 90 } |
| 91 set_has_element_in_pending_list(false); | 91 set_has_element_in_pending_list(false); |
| 92 | 92 |
| 93 Deactivate(); | 93 RemovePlayersFromTicking(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ElementAnimations::ElementRegistered(ElementId element_id, | 96 void ElementAnimations::ElementRegistered(ElementId element_id, |
| 97 ElementListType list_type) { | 97 ElementListType list_type) { |
| 98 DCHECK_EQ(element_id_, element_id); | 98 DCHECK_EQ(element_id_, element_id); |
| 99 | 99 |
| 100 if (!has_element_in_any_list()) | 100 if (!has_element_in_any_list()) |
| 101 UpdateActivation(ActivationType::FORCE); | 101 UpdatePlayersTickingState(UpdateTickingType::FORCE); |
| 102 | 102 |
| 103 if (list_type == ElementListType::ACTIVE) | 103 if (list_type == ElementListType::ACTIVE) |
| 104 set_has_element_in_active_list(true); | 104 set_has_element_in_active_list(true); |
| 105 else | 105 else |
| 106 set_has_element_in_pending_list(true); | 106 set_has_element_in_pending_list(true); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ElementAnimations::ElementUnregistered(ElementId element_id, | 109 void ElementAnimations::ElementUnregistered(ElementId element_id, |
| 110 ElementListType list_type) { | 110 ElementListType list_type) { |
| 111 DCHECK_EQ(this->element_id(), element_id); | 111 DCHECK_EQ(this->element_id(), element_id); |
| 112 if (list_type == ElementListType::ACTIVE) | 112 if (list_type == ElementListType::ACTIVE) |
| 113 set_has_element_in_active_list(false); | 113 set_has_element_in_active_list(false); |
| 114 else | 114 else |
| 115 set_has_element_in_pending_list(false); | 115 set_has_element_in_pending_list(false); |
| 116 | 116 |
| 117 if (!has_element_in_any_list()) | 117 if (!has_element_in_any_list()) |
| 118 Deactivate(); | 118 RemovePlayersFromTicking(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ElementAnimations::AddPlayer(AnimationPlayer* player) { | 121 void ElementAnimations::AddPlayer(AnimationPlayer* player) { |
| 122 players_list_.AddObserver(player); | 122 players_list_.AddObserver(player); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ElementAnimations::RemovePlayer(AnimationPlayer* player) { | 125 void ElementAnimations::RemovePlayer(AnimationPlayer* player) { |
| 126 players_list_.RemoveObserver(player); | 126 players_list_.RemoveObserver(player); |
| 127 } | 127 } |
| 128 | 128 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 141 if (!needs_push_properties_) | 141 if (!needs_push_properties_) |
| 142 return; | 142 return; |
| 143 needs_push_properties_ = false; | 143 needs_push_properties_ = false; |
| 144 | 144 |
| 145 // Update impl client state. | 145 // Update impl client state. |
| 146 if (needs_update_impl_client_state_) | 146 if (needs_update_impl_client_state_) |
| 147 element_animations_impl->UpdateClientAnimationState(); | 147 element_animations_impl->UpdateClientAnimationState(); |
| 148 needs_update_impl_client_state_ = false; | 148 needs_update_impl_client_state_ = false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void ElementAnimations::UpdateActivation(ActivationType activation_type) const { | 151 void ElementAnimations::UpdatePlayersTickingState( |
| 152 UpdateTickingType update_ticking_type) const { |
| 152 for (auto& player : players_list_) | 153 for (auto& player : players_list_) |
| 153 player.UpdateActivation(activation_type); | 154 player.UpdateTickingState(update_ticking_type); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void ElementAnimations::Deactivate() const { | 157 void ElementAnimations::RemovePlayersFromTicking() const { |
| 157 for (auto& player : players_list_) | 158 for (auto& player : players_list_) |
| 158 player.Deactivate(); | 159 player.RemoveFromTicking(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { | 162 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { |
| 162 DCHECK(!event.is_impl_only); | 163 DCHECK(!event.is_impl_only); |
| 163 for (auto& player : players_list_) { | 164 for (auto& player : players_list_) { |
| 164 if (player.NotifyAnimationStarted(event)) | 165 if (player.NotifyAnimationStarted(event)) |
| 165 break; | 166 break; |
| 166 } | 167 } |
| 167 } | 168 } |
| 168 | 169 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( | 389 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 389 element_id(), ElementListType::ACTIVE, diff_active, active_state_); | 390 element_id(), ElementListType::ACTIVE, diff_active, active_state_); |
| 390 } | 391 } |
| 391 if (has_element_in_pending_list() && prev_pending != pending_state_) { | 392 if (has_element_in_pending_list() && prev_pending != pending_state_) { |
| 392 PropertyAnimationState diff_pending = prev_pending ^ pending_state_; | 393 PropertyAnimationState diff_pending = prev_pending ^ pending_state_; |
| 393 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( | 394 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 394 element_id(), ElementListType::PENDING, diff_pending, pending_state_); | 395 element_id(), ElementListType::PENDING, diff_pending, pending_state_); |
| 395 } | 396 } |
| 396 } | 397 } |
| 397 | 398 |
| 398 bool ElementAnimations::HasActiveAnimation() const { | 399 bool ElementAnimations::HasTickingAnimation() const { |
| 399 for (auto& player : players_list_) { | 400 for (auto& player : players_list_) { |
| 400 if (player.HasActiveAnimation()) | 401 if (player.HasTickingAnimation()) |
| 401 return true; | 402 return true; |
| 402 } | 403 } |
| 403 | 404 |
| 404 return false; | 405 return false; |
| 405 } | 406 } |
| 406 | 407 |
| 407 bool ElementAnimations::HasAnyAnimation() const { | 408 bool ElementAnimations::HasAnyAnimation() const { |
| 408 for (auto& player : players_list_) { | 409 for (auto& player : players_list_) { |
| 409 if (player.has_any_animation()) | 410 if (player.has_any_animation()) |
| 410 return true; | 411 return true; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 if (animation_host()) { | 486 if (animation_host()) { |
| 486 DCHECK(animation_host()->mutator_host_client()); | 487 DCHECK(animation_host()->mutator_host_client()); |
| 487 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 488 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
| 488 element_id()); | 489 element_id()); |
| 489 } | 490 } |
| 490 | 491 |
| 491 return gfx::ScrollOffset(); | 492 return gfx::ScrollOffset(); |
| 492 } | 493 } |
| 493 | 494 |
| 494 } // namespace cc | 495 } // namespace cc |
| OLD | NEW |