Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 } | 25 } |
| 26 | 26 |
| 27 ElementAnimations::ElementAnimations() | 27 ElementAnimations::ElementAnimations() |
| 28 : animation_host_(), | 28 : animation_host_(), |
| 29 element_id_(), | 29 element_id_(), |
| 30 is_active_(false), | 30 is_active_(false), |
| 31 has_element_in_active_list_(false), | 31 has_element_in_active_list_(false), |
| 32 has_element_in_pending_list_(false), | 32 has_element_in_pending_list_(false), |
| 33 scroll_offset_animation_was_interrupted_(false), | 33 scroll_offset_animation_was_interrupted_(false), |
| 34 needs_push_properties_(false) { | 34 needs_push_properties_(false) { |
| 35 ClearNeedsUpdateImplClientState(); | |
| 36 } | 35 } |
| 37 | 36 |
| 38 ElementAnimations::~ElementAnimations() {} | 37 ElementAnimations::~ElementAnimations() {} |
| 39 | 38 |
| 40 void ElementAnimations::SetAnimationHost(AnimationHost* host) { | 39 void ElementAnimations::SetAnimationHost(AnimationHost* host) { |
| 41 animation_host_ = host; | 40 animation_host_ = host; |
| 42 } | 41 } |
| 43 | 42 |
| 44 void ElementAnimations::SetElementId(ElementId element_id) { | 43 void ElementAnimations::SetElementId(ElementId element_id) { |
| 45 element_id_ = element_id; | 44 element_id_ = element_id; |
| 46 } | 45 } |
| 47 | 46 |
| 48 void ElementAnimations::InitAffectedElementTypes() { | 47 void ElementAnimations::InitAffectedElementTypes() { |
| 49 DCHECK(element_id_); | 48 DCHECK(element_id_); |
| 50 DCHECK(animation_host_); | 49 DCHECK(animation_host_); |
| 51 | 50 |
| 52 UpdateActivation(ActivationType::FORCE); | 51 UpdateActivation(ActivationType::FORCE); |
| 53 | 52 |
| 54 DCHECK(animation_host_->mutator_host_client()); | 53 DCHECK(animation_host_->mutator_host_client()); |
| 55 if (animation_host_->mutator_host_client()->IsElementInList( | 54 if (animation_host_->mutator_host_client()->IsElementInList( |
| 56 element_id_, ElementListType::ACTIVE)) { | 55 element_id_, ElementListType::ACTIVE)) { |
| 57 set_has_element_in_active_list(true); | 56 set_has_element_in_active_list(true); |
| 58 } | 57 } |
| 59 if (animation_host_->mutator_host_client()->IsElementInList( | 58 if (animation_host_->mutator_host_client()->IsElementInList( |
| 60 element_id_, ElementListType::PENDING)) { | 59 element_id_, ElementListType::PENDING)) { |
| 61 set_has_element_in_pending_list(true); | 60 set_has_element_in_pending_list(true); |
| 62 } | 61 } |
| 63 } | 62 } |
| 64 | 63 |
| 64 TargetProperties ElementAnimations::GetPropertiesMaskForAnimationState() { | |
| 65 TargetProperties properties; | |
| 66 properties[TargetProperty::TRANSFORM] = true; | |
| 67 properties[TargetProperty::OPACITY] = true; | |
| 68 properties[TargetProperty::FILTER] = true; | |
| 69 return properties; | |
| 70 } | |
| 71 | |
| 65 void ElementAnimations::ClearAffectedElementTypes() { | 72 void ElementAnimations::ClearAffectedElementTypes() { |
| 66 DCHECK(animation_host_); | 73 DCHECK(animation_host_); |
| 67 | 74 |
| 75 TargetProperties disable_properties = GetPropertiesMaskForAnimationState(); | |
| 76 PropertyAnimationState disabled_state_mask, disabled_state; | |
| 77 disabled_state_mask.currently_running = disable_properties; | |
| 78 disabled_state_mask.potentially_animating = disable_properties; | |
| 79 | |
| 68 if (has_element_in_active_list()) { | 80 if (has_element_in_active_list()) { |
| 69 IsAnimatingChanged(ElementListType::ACTIVE, TargetProperty::TRANSFORM, | 81 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 70 AnimationChangeType::BOTH, false); | 82 element_id(), ElementListType::ACTIVE, disabled_state_mask, |
| 71 IsAnimatingChanged(ElementListType::ACTIVE, TargetProperty::OPACITY, | 83 disabled_state); |
| 72 AnimationChangeType::BOTH, false); | |
| 73 } | 84 } |
| 74 set_has_element_in_active_list(false); | 85 set_has_element_in_active_list(false); |
| 75 | 86 |
| 76 if (has_element_in_pending_list()) { | 87 if (has_element_in_pending_list()) { |
| 77 IsAnimatingChanged(ElementListType::PENDING, TargetProperty::TRANSFORM, | 88 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 78 AnimationChangeType::BOTH, false); | 89 element_id(), ElementListType::PENDING, disabled_state_mask, |
| 79 IsAnimatingChanged(ElementListType::PENDING, TargetProperty::OPACITY, | 90 disabled_state); |
| 80 AnimationChangeType::BOTH, false); | |
| 81 } | 91 } |
| 82 set_has_element_in_pending_list(false); | 92 set_has_element_in_pending_list(false); |
| 83 | 93 |
| 84 animation_host_->DidDeactivateElementAnimations(this); | 94 animation_host_->DidDeactivateElementAnimations(this); |
| 85 UpdateActivation(ActivationType::FORCE); | 95 UpdateActivation(ActivationType::FORCE); |
| 86 } | 96 } |
| 87 | 97 |
| 88 void ElementAnimations::ElementRegistered(ElementId element_id, | 98 void ElementAnimations::ElementRegistered(ElementId element_id, |
| 89 ElementListType list_type) { | 99 ElementListType list_type) { |
| 90 DCHECK_EQ(element_id_, element_id); | 100 DCHECK_EQ(element_id_, element_id); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 if (!needs_push_properties_) | 143 if (!needs_push_properties_) |
| 134 return; | 144 return; |
| 135 needs_push_properties_ = false; | 145 needs_push_properties_ = false; |
| 136 | 146 |
| 137 element_animations_impl->scroll_offset_animation_was_interrupted_ = | 147 element_animations_impl->scroll_offset_animation_was_interrupted_ = |
| 138 scroll_offset_animation_was_interrupted_; | 148 scroll_offset_animation_was_interrupted_; |
| 139 scroll_offset_animation_was_interrupted_ = false; | 149 scroll_offset_animation_was_interrupted_ = false; |
| 140 | 150 |
| 141 // Update impl client state. | 151 // Update impl client state. |
| 142 element_animations_impl->UpdateClientAnimationState( | 152 element_animations_impl->UpdateClientAnimationState( |
| 143 needs_update_impl_client_state_transform_, | 153 needs_update_impl_client_state_properties_); |
| 144 needs_update_impl_client_state_opacity_, | 154 needs_update_impl_client_state_properties_.reset(); |
| 145 needs_update_impl_client_state_filter_); | |
| 146 ClearNeedsUpdateImplClientState(); | |
| 147 | 155 |
| 148 element_animations_impl->UpdateActivation(ActivationType::NORMAL); | 156 element_animations_impl->UpdateActivation(ActivationType::NORMAL); |
| 149 UpdateActivation(ActivationType::NORMAL); | 157 UpdateActivation(ActivationType::NORMAL); |
| 150 } | 158 } |
| 151 | 159 |
| 152 void ElementAnimations::UpdateClientAnimationState( | 160 void ElementAnimations::UpdateClientAnimationState( |
| 153 TargetProperty::Type target_property) { | 161 TargetProperty::Type target_property) { |
| 154 switch (target_property) { | 162 TargetProperties properties; |
| 155 case TargetProperty::TRANSFORM: | 163 properties[target_property] = true; |
| 156 case TargetProperty::OPACITY: | 164 UpdateClientAnimationState(properties); |
| 157 case TargetProperty::FILTER: | |
| 158 UpdateClientAnimationStateInternal(target_property); | |
| 159 break; | |
| 160 default: | |
| 161 // Do not update for other properties. | |
| 162 break; | |
| 163 } | |
| 164 } | 165 } |
| 165 | 166 |
| 166 void ElementAnimations::UpdateClientAnimationState(bool transform, | 167 void ElementAnimations::UpdateClientAnimationState( |
| 167 bool opacity, | 168 TargetProperties target_properties) { |
| 168 bool filter) { | 169 TargetProperties allowed_properties = GetPropertiesMaskForAnimationState(); |
| 169 if (transform) | 170 UpdateClientAnimationStateInternal(target_properties & allowed_properties); |
| 170 UpdateClientAnimationStateInternal(TargetProperty::TRANSFORM); | |
| 171 if (opacity) | |
| 172 UpdateClientAnimationStateInternal(TargetProperty::OPACITY); | |
| 173 if (filter) | |
| 174 UpdateClientAnimationStateInternal(TargetProperty::FILTER); | |
| 175 } | 171 } |
| 176 | 172 |
| 177 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) { | 173 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) { |
| 178 // TODO(loyso): Erase this. Rewrite element_animations_unittest to use | 174 // TODO(loyso): Erase this. Rewrite element_animations_unittest to use |
| 179 // AnimationPlayer::AddAnimation. | 175 // AnimationPlayer::AddAnimation. |
| 180 | 176 |
| 181 // Add animation to the first player. | 177 // Add animation to the first player. |
| 182 DCHECK(players_list_.might_have_observers()); | 178 DCHECK(players_list_.might_have_observers()); |
| 183 | 179 |
| 184 AnimationPlayer& player = *players_list_.begin(); | 180 AnimationPlayer& player = *players_list_.begin(); |
| 185 player.AddAnimation(std::move(animation)); | 181 player.AddAnimation(std::move(animation)); |
| 186 } | 182 } |
| 187 | 183 |
| 188 void ElementAnimations::Animate(base::TimeTicks monotonic_time) { | 184 void ElementAnimations::Animate(base::TimeTicks monotonic_time) { |
| 189 DCHECK(!monotonic_time.is_null()); | 185 DCHECK(!monotonic_time.is_null()); |
| 190 if (!has_element_in_active_list() && !has_element_in_pending_list()) | 186 if (!has_element_in_active_list() && !has_element_in_pending_list()) |
| 191 return; | 187 return; |
| 192 | 188 |
| 193 for (auto& player : players_list_) { | 189 for (auto& player : players_list_) { |
| 194 if (player.needs_to_start_animations()) | 190 if (player.needs_to_start_animations()) |
| 195 player.StartAnimations(monotonic_time); | 191 player.StartAnimations(monotonic_time); |
| 196 } | 192 } |
| 197 | 193 |
| 198 for (auto& player : players_list_) | 194 for (auto& player : players_list_) |
| 199 player.TickAnimations(monotonic_time); | 195 player.TickAnimations(monotonic_time); |
| 200 | 196 |
| 201 last_tick_time_ = monotonic_time; | 197 last_tick_time_ = monotonic_time; |
| 202 | 198 |
| 203 UpdateClientAnimationStateInternal(TargetProperty::OPACITY); | 199 TargetProperties update_properties = GetPropertiesMaskForAnimationState(); |
| 204 UpdateClientAnimationStateInternal(TargetProperty::TRANSFORM); | 200 UpdateClientAnimationStateInternal(update_properties); |
| 205 UpdateClientAnimationStateInternal(TargetProperty::FILTER); | |
| 206 } | 201 } |
| 207 | 202 |
| 208 void ElementAnimations::UpdateState(bool start_ready_animations, | 203 void ElementAnimations::UpdateState(bool start_ready_animations, |
| 209 AnimationEvents* events) { | 204 AnimationEvents* events) { |
| 210 if (!has_element_in_active_list()) | 205 if (!has_element_in_active_list()) |
| 211 return; | 206 return; |
| 212 | 207 |
| 213 // Animate hasn't been called, this happens if an element has been added | 208 // Animate hasn't been called, this happens if an element has been added |
| 214 // between the Commit and Draw phases. | 209 // between the Commit and Draw phases. |
| 215 if (last_tick_time_ == base::TimeTicks()) | 210 if (last_tick_time_ == base::TimeTicks()) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 232 player.StartAnimations(last_tick_time_); | 227 player.StartAnimations(last_tick_time_); |
| 233 player.PromoteStartedAnimations(last_tick_time_, events); | 228 player.PromoteStartedAnimations(last_tick_time_, events); |
| 234 } | 229 } |
| 235 } | 230 } |
| 236 } | 231 } |
| 237 | 232 |
| 238 UpdateActivation(ActivationType::NORMAL); | 233 UpdateActivation(ActivationType::NORMAL); |
| 239 } | 234 } |
| 240 | 235 |
| 241 void ElementAnimations::ActivateAnimations() { | 236 void ElementAnimations::ActivateAnimations() { |
| 242 bool changed_transform_animation = false; | 237 TargetProperties activated_properties; |
| 243 bool changed_opacity_animation = false; | |
| 244 bool changed_filter_animation = false; | |
| 245 | 238 |
| 246 for (auto& player : players_list_) { | 239 for (auto& player : players_list_) { |
| 247 player.ActivateAnimations(&changed_transform_animation, | 240 TargetProperties player_activated_properties = player.ActivateAnimations(); |
| 248 &changed_opacity_animation, | 241 activated_properties |= player_activated_properties; |
| 249 &changed_filter_animation); | |
| 250 } | 242 } |
| 251 | 243 |
| 252 scroll_offset_animation_was_interrupted_ = false; | 244 scroll_offset_animation_was_interrupted_ = false; |
| 253 UpdateActivation(ActivationType::NORMAL); | 245 UpdateActivation(ActivationType::NORMAL); |
| 254 UpdateClientAnimationState(changed_transform_animation, | 246 UpdateClientAnimationState(activated_properties); |
| 255 changed_opacity_animation, | |
| 256 changed_filter_animation); | |
| 257 } | 247 } |
| 258 | 248 |
| 259 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { | 249 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { |
| 260 DCHECK(!event.is_impl_only); | 250 DCHECK(!event.is_impl_only); |
| 261 for (auto& player : players_list_) { | 251 for (auto& player : players_list_) { |
| 262 if (player.NotifyAnimationStarted(event)) | 252 if (player.NotifyAnimationStarted(event)) |
| 263 break; | 253 break; |
| 264 } | 254 } |
| 265 } | 255 } |
| 266 | 256 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 bool success = player.MaximumTargetScale(list_type, &player_max_scale); | 387 bool success = player.MaximumTargetScale(list_type, &player_max_scale); |
| 398 if (!success) | 388 if (!success) |
| 399 return false; | 389 return false; |
| 400 // Union: a maximum. | 390 // Union: a maximum. |
| 401 *max_scale = std::max(*max_scale, player_max_scale); | 391 *max_scale = std::max(*max_scale, player_max_scale); |
| 402 } | 392 } |
| 403 | 393 |
| 404 return true; | 394 return true; |
| 405 } | 395 } |
| 406 | 396 |
| 407 void ElementAnimations::SetNeedsUpdateImplClientState(bool transform, | 397 void ElementAnimations::SetNeedsUpdateImplClientState( |
| 408 bool opacity, | 398 TargetProperties target_properties) { |
| 409 bool filter) { | 399 needs_update_impl_client_state_properties_ |= target_properties; |
| 410 if (transform) | |
| 411 needs_update_impl_client_state_transform_ = true; | |
| 412 if (opacity) | |
| 413 needs_update_impl_client_state_opacity_ = true; | |
| 414 if (filter) | |
| 415 needs_update_impl_client_state_filter_ = true; | |
| 416 | 400 |
| 417 if (needs_update_impl_client_state_transform_ || | 401 if (needs_update_impl_client_state_properties_.any()) |
| 418 needs_update_impl_client_state_opacity_ || | |
| 419 needs_update_impl_client_state_filter_) | |
| 420 SetNeedsPushProperties(); | 402 SetNeedsPushProperties(); |
| 421 } | 403 } |
| 422 | 404 |
| 423 void ElementAnimations::ClearNeedsUpdateImplClientState() { | |
| 424 needs_update_impl_client_state_transform_ = false; | |
| 425 needs_update_impl_client_state_opacity_ = false; | |
| 426 needs_update_impl_client_state_filter_ = false; | |
| 427 } | |
| 428 | |
| 429 void ElementAnimations::UpdateActivation(ActivationType type) { | 405 void ElementAnimations::UpdateActivation(ActivationType type) { |
| 430 bool force = type == ActivationType::FORCE; | 406 bool force = type == ActivationType::FORCE; |
| 431 if (animation_host_) { | 407 if (animation_host_) { |
| 432 bool was_active = is_active_; | 408 bool was_active = is_active_; |
| 433 is_active_ = false; | 409 is_active_ = false; |
| 434 | 410 |
| 435 for (auto& player : players_list_) { | 411 for (auto& player : players_list_) { |
| 436 if (player.HasNonDeletedAnimation()) { | 412 if (player.HasNonDeletedAnimation()) { |
| 437 is_active_ = true; | 413 is_active_ = true; |
| 438 break; | 414 break; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 void ElementAnimations::NotifyClientScrollOffsetAnimated( | 463 void ElementAnimations::NotifyClientScrollOffsetAnimated( |
| 488 const gfx::ScrollOffset& scroll_offset, | 464 const gfx::ScrollOffset& scroll_offset, |
| 489 bool notify_active_elements, | 465 bool notify_active_elements, |
| 490 bool notify_pending_elements) { | 466 bool notify_pending_elements) { |
| 491 if (notify_active_elements && has_element_in_active_list()) | 467 if (notify_active_elements && has_element_in_active_list()) |
| 492 OnScrollOffsetAnimated(ElementListType::ACTIVE, scroll_offset); | 468 OnScrollOffsetAnimated(ElementListType::ACTIVE, scroll_offset); |
| 493 if (notify_pending_elements && has_element_in_pending_list()) | 469 if (notify_pending_elements && has_element_in_pending_list()) |
| 494 OnScrollOffsetAnimated(ElementListType::PENDING, scroll_offset); | 470 OnScrollOffsetAnimated(ElementListType::PENDING, scroll_offset); |
| 495 } | 471 } |
| 496 | 472 |
| 497 void ElementAnimations::NotifyClientAnimationChanged( | 473 void ElementAnimations::UpdateClientAnimationStateInternal( |
| 498 TargetProperty::Type property, | 474 TargetProperties properties) { |
|
loyso (OOO)
2016/09/22 00:47:29
Just realized last night that |properties| paramet
| |
| 499 ElementListType list_type, | 475 if (!properties.any()) |
| 500 bool notify_elements_about_potential_animation, | 476 return; |
| 501 bool notify_elements_about_running_animation) { | 477 if (!element_id()) |
| 502 PropertyAnimationState* animation_state = nullptr; | 478 return; |
| 503 switch (property) { | 479 DCHECK(animation_host()); |
| 504 case TargetProperty::OPACITY: | 480 if (!animation_host()->mutator_host_client()) |
| 505 animation_state = &opacity_animation_state_; | 481 return; |
| 506 break; | 482 |
| 507 case TargetProperty::TRANSFORM: | 483 PropertyAnimationState prev_pending = pending_state_; |
| 508 animation_state = &transform_animation_state_; | 484 PropertyAnimationState prev_active = active_state_; |
| 509 break; | 485 |
| 510 case TargetProperty::FILTER: | 486 pending_state_.Clear(); |
| 511 animation_state = &filter_animation_state_; | 487 active_state_.Clear(); |
| 512 break; | 488 |
| 513 default: | 489 for (auto& player : players_list_) { |
| 514 NOTREACHED(); | 490 PropertyAnimationState player_pending_state, player_active_state; |
| 515 break; | 491 player.GetPropertyAnimationState(&player_pending_state, |
| 492 &player_active_state); | |
| 493 pending_state_ |= player_pending_state; | |
| 494 active_state_ |= player_active_state; | |
| 516 } | 495 } |
| 517 | 496 |
| 518 bool notify_elements_about_potential_and_running_animation = | 497 TargetProperties allowed_properties = GetPropertiesMaskForAnimationState(); |
| 519 notify_elements_about_potential_animation && | 498 PropertyAnimationState allowed_state; |
| 520 notify_elements_about_running_animation; | 499 allowed_state.currently_running = allowed_properties; |
| 521 bool active = list_type == ElementListType::ACTIVE; | 500 allowed_state.potentially_animating = allowed_properties; |
| 522 if (notify_elements_about_potential_and_running_animation) { | 501 |
| 523 bool potentially_animating = | 502 pending_state_ &= allowed_state; |
| 524 active ? animation_state->potentially_animating_for_active_elements | 503 active_state_ &= allowed_state; |
| 525 : animation_state->potentially_animating_for_pending_elements; | 504 |
| 526 bool currently_animating = | 505 DCHECK(pending_state_.IsValid()); |
| 527 active ? animation_state->currently_running_for_active_elements | 506 DCHECK(active_state_.IsValid()); |
| 528 : animation_state->currently_running_for_pending_elements; | 507 |
| 529 DCHECK_EQ(potentially_animating, currently_animating); | 508 if (has_element_in_active_list() && prev_active != active_state_) { |
| 530 IsAnimatingChanged(list_type, property, AnimationChangeType::BOTH, | 509 PropertyAnimationState diff_active = prev_active ^ active_state_; |
| 531 potentially_animating); | 510 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 532 } else if (notify_elements_about_potential_animation) { | 511 element_id(), ElementListType::ACTIVE, diff_active, active_state_); |
| 533 bool potentially_animating = | 512 } |
| 534 active ? animation_state->potentially_animating_for_active_elements | 513 if (has_element_in_pending_list() && prev_pending != pending_state_) { |
| 535 : animation_state->potentially_animating_for_pending_elements; | 514 PropertyAnimationState diff_pending = prev_pending ^ pending_state_; |
| 536 IsAnimatingChanged(list_type, property, AnimationChangeType::POTENTIAL, | 515 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 537 potentially_animating); | 516 element_id(), ElementListType::PENDING, diff_pending, pending_state_); |
| 538 } else if (notify_elements_about_running_animation) { | |
| 539 bool currently_animating = | |
| 540 active ? animation_state->currently_running_for_active_elements | |
| 541 : animation_state->currently_running_for_pending_elements; | |
| 542 IsAnimatingChanged(list_type, property, AnimationChangeType::RUNNING, | |
| 543 currently_animating); | |
| 544 } | 517 } |
| 545 } | 518 } |
| 546 | 519 |
| 547 void ElementAnimations::UpdateClientAnimationStateInternal( | |
| 548 TargetProperty::Type property) { | |
| 549 PropertyAnimationState* animation_state = nullptr; | |
| 550 switch (property) { | |
| 551 case TargetProperty::OPACITY: | |
| 552 animation_state = &opacity_animation_state_; | |
| 553 break; | |
| 554 case TargetProperty::TRANSFORM: | |
| 555 animation_state = &transform_animation_state_; | |
| 556 break; | |
| 557 case TargetProperty::FILTER: | |
| 558 animation_state = &filter_animation_state_; | |
| 559 break; | |
| 560 default: | |
| 561 NOTREACHED(); | |
| 562 break; | |
| 563 } | |
| 564 | |
| 565 PropertyAnimationState previous_state = *animation_state; | |
| 566 animation_state->Clear(); | |
| 567 DCHECK(previous_state.IsValid()); | |
| 568 | |
| 569 for (auto& player : players_list_) { | |
| 570 PropertyAnimationState player_state; | |
| 571 player.GetPropertyAnimationStateFor(property, &player_state); | |
| 572 *animation_state |= player_state; | |
| 573 } | |
| 574 | |
| 575 if (*animation_state == previous_state) | |
| 576 return; | |
| 577 | |
| 578 PropertyAnimationState diff_state = previous_state ^ *animation_state; | |
| 579 | |
| 580 if (has_element_in_active_list()) | |
| 581 NotifyClientAnimationChanged( | |
| 582 property, ElementListType::ACTIVE, | |
| 583 diff_state.potentially_animating_for_active_elements, | |
| 584 diff_state.currently_running_for_active_elements); | |
| 585 if (has_element_in_pending_list()) | |
| 586 NotifyClientAnimationChanged( | |
| 587 property, ElementListType::PENDING, | |
| 588 diff_state.potentially_animating_for_pending_elements, | |
| 589 diff_state.currently_running_for_pending_elements); | |
| 590 } | |
| 591 | |
| 592 bool ElementAnimations::HasActiveAnimation() const { | 520 bool ElementAnimations::HasActiveAnimation() const { |
| 593 for (auto& player : players_list_) { | 521 for (auto& player : players_list_) { |
| 594 if (player.HasActiveAnimation()) | 522 if (player.HasActiveAnimation()) |
| 595 return true; | 523 return true; |
| 596 } | 524 } |
| 597 | 525 |
| 598 return false; | 526 return false; |
| 599 } | 527 } |
| 600 | 528 |
| 601 bool ElementAnimations::HasAnyAnimation() const { | 529 bool ElementAnimations::HasAnyAnimation() const { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 void ElementAnimations::OnScrollOffsetAnimated( | 639 void ElementAnimations::OnScrollOffsetAnimated( |
| 712 ElementListType list_type, | 640 ElementListType list_type, |
| 713 const gfx::ScrollOffset& scroll_offset) { | 641 const gfx::ScrollOffset& scroll_offset) { |
| 714 DCHECK(element_id()); | 642 DCHECK(element_id()); |
| 715 DCHECK(animation_host()); | 643 DCHECK(animation_host()); |
| 716 DCHECK(animation_host()->mutator_host_client()); | 644 DCHECK(animation_host()->mutator_host_client()); |
| 717 animation_host()->mutator_host_client()->SetElementScrollOffsetMutated( | 645 animation_host()->mutator_host_client()->SetElementScrollOffsetMutated( |
| 718 element_id(), list_type, scroll_offset); | 646 element_id(), list_type, scroll_offset); |
| 719 } | 647 } |
| 720 | 648 |
| 721 void ElementAnimations::IsAnimatingChanged(ElementListType list_type, | |
| 722 TargetProperty::Type property, | |
| 723 AnimationChangeType change_type, | |
| 724 bool is_animating) { | |
| 725 if (!element_id()) | |
| 726 return; | |
| 727 DCHECK(animation_host()); | |
| 728 if (animation_host()->mutator_host_client()) { | |
| 729 switch (property) { | |
| 730 case TargetProperty::OPACITY: | |
| 731 animation_host() | |
| 732 ->mutator_host_client() | |
| 733 ->ElementOpacityIsAnimatingChanged(element_id(), list_type, | |
| 734 change_type, is_animating); | |
| 735 break; | |
| 736 case TargetProperty::TRANSFORM: | |
| 737 animation_host() | |
| 738 ->mutator_host_client() | |
| 739 ->ElementTransformIsAnimatingChanged(element_id(), list_type, | |
| 740 change_type, is_animating); | |
| 741 break; | |
| 742 case TargetProperty::FILTER: | |
| 743 animation_host() | |
| 744 ->mutator_host_client() | |
| 745 ->ElementFilterIsAnimatingChanged(element_id(), list_type, | |
| 746 change_type, is_animating); | |
| 747 break; | |
| 748 default: | |
| 749 NOTREACHED(); | |
| 750 break; | |
| 751 } | |
| 752 } | |
| 753 } | |
| 754 | |
| 755 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { | 649 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { |
| 756 if (animation_host()) { | 650 if (animation_host()) { |
| 757 DCHECK(animation_host()->mutator_host_client()); | 651 DCHECK(animation_host()->mutator_host_client()); |
| 758 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 652 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
| 759 element_id()); | 653 element_id()); |
| 760 } | 654 } |
| 761 | 655 |
| 762 return gfx::ScrollOffset(); | 656 return gfx::ScrollOffset(); |
| 763 } | 657 } |
| 764 | 658 |
| 765 } // namespace cc | 659 } // namespace cc |
| OLD | NEW |