| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 OnScrollOffsetAnimated(ElementListType::ACTIVE, scroll_offset); | 531 OnScrollOffsetAnimated(ElementListType::ACTIVE, scroll_offset); |
| 532 if (notify_pending_elements && has_element_in_pending_list()) | 532 if (notify_pending_elements && has_element_in_pending_list()) |
| 533 OnScrollOffsetAnimated(ElementListType::PENDING, scroll_offset); | 533 OnScrollOffsetAnimated(ElementListType::PENDING, scroll_offset); |
| 534 } | 534 } |
| 535 | 535 |
| 536 void ElementAnimations::NotifyClientAnimationChanged( | 536 void ElementAnimations::NotifyClientAnimationChanged( |
| 537 TargetProperty::Type property, | 537 TargetProperty::Type property, |
| 538 ElementListType list_type, | 538 ElementListType list_type, |
| 539 bool notify_elements_about_potential_animation, | 539 bool notify_elements_about_potential_animation, |
| 540 bool notify_elements_about_running_animation) { | 540 bool notify_elements_about_running_animation) { |
| 541 struct PropertyAnimationState* animation_state = nullptr; | 541 PropertyAnimationState* animation_state = nullptr; |
| 542 switch (property) { | 542 switch (property) { |
| 543 case TargetProperty::OPACITY: | 543 case TargetProperty::OPACITY: |
| 544 animation_state = &opacity_animation_state_; | 544 animation_state = &opacity_animation_state_; |
| 545 break; | 545 break; |
| 546 case TargetProperty::TRANSFORM: | 546 case TargetProperty::TRANSFORM: |
| 547 animation_state = &transform_animation_state_; | 547 animation_state = &transform_animation_state_; |
| 548 break; | 548 break; |
| 549 case TargetProperty::FILTER: | 549 case TargetProperty::FILTER: |
| 550 animation_state = &filter_animation_state_; | 550 animation_state = &filter_animation_state_; |
| 551 break; | 551 break; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 578 bool currently_animating = | 578 bool currently_animating = |
| 579 active ? animation_state->currently_running_for_active_elements | 579 active ? animation_state->currently_running_for_active_elements |
| 580 : animation_state->currently_running_for_pending_elements; | 580 : animation_state->currently_running_for_pending_elements; |
| 581 IsAnimatingChanged(list_type, property, AnimationChangeType::RUNNING, | 581 IsAnimatingChanged(list_type, property, AnimationChangeType::RUNNING, |
| 582 currently_animating); | 582 currently_animating); |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 | 585 |
| 586 void ElementAnimations::UpdateClientAnimationStateInternal( | 586 void ElementAnimations::UpdateClientAnimationStateInternal( |
| 587 TargetProperty::Type property) { | 587 TargetProperty::Type property) { |
| 588 struct PropertyAnimationState* animation_state = nullptr; | 588 PropertyAnimationState* animation_state = nullptr; |
| 589 switch (property) { | 589 switch (property) { |
| 590 case TargetProperty::OPACITY: | 590 case TargetProperty::OPACITY: |
| 591 animation_state = &opacity_animation_state_; | 591 animation_state = &opacity_animation_state_; |
| 592 break; | 592 break; |
| 593 case TargetProperty::TRANSFORM: | 593 case TargetProperty::TRANSFORM: |
| 594 animation_state = &transform_animation_state_; | 594 animation_state = &transform_animation_state_; |
| 595 break; | 595 break; |
| 596 case TargetProperty::FILTER: | 596 case TargetProperty::FILTER: |
| 597 animation_state = &filter_animation_state_; | 597 animation_state = &filter_animation_state_; |
| 598 break; | 598 break; |
| 599 default: | 599 default: |
| 600 NOTREACHED(); | 600 NOTREACHED(); |
| 601 break; | 601 break; |
| 602 } | 602 } |
| 603 bool was_currently_running_animation_for_active_elements = | |
| 604 animation_state->currently_running_for_active_elements; | |
| 605 bool was_currently_running_animation_for_pending_elements = | |
| 606 animation_state->currently_running_for_pending_elements; | |
| 607 bool was_potentially_animating_for_active_elements = | |
| 608 animation_state->potentially_animating_for_active_elements; | |
| 609 bool was_potentially_animating_for_pending_elements = | |
| 610 animation_state->potentially_animating_for_pending_elements; | |
| 611 | 603 |
| 604 PropertyAnimationState previous_state = *animation_state; |
| 612 animation_state->Clear(); | 605 animation_state->Clear(); |
| 613 DCHECK(was_potentially_animating_for_active_elements || | 606 DCHECK(previous_state.IsValid()); |
| 614 !was_currently_running_animation_for_active_elements); | |
| 615 DCHECK(was_potentially_animating_for_pending_elements || | |
| 616 !was_currently_running_animation_for_pending_elements); | |
| 617 | 607 |
| 618 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 608 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
| 619 AnimationPlayer* player; | 609 AnimationPlayer* player; |
| 620 while ((player = it.GetNext()) != nullptr) { | 610 while ((player = it.GetNext()) != nullptr) { |
| 621 for (const auto& animation : player->animations()) { | 611 PropertyAnimationState player_state; |
| 622 if (!animation->is_finished() && | 612 player->GetPropertyAnimationStateFor(property, &player_state); |
| 623 animation->target_property() == property) { | 613 *animation_state |= player_state; |
| 624 animation_state->potentially_animating_for_active_elements |= | |
| 625 animation->affects_active_elements(); | |
| 626 animation_state->potentially_animating_for_pending_elements |= | |
| 627 animation->affects_pending_elements(); | |
| 628 animation_state->currently_running_for_active_elements |= | |
| 629 animation->affects_active_elements() && | |
| 630 animation->InEffect(last_tick_time_); | |
| 631 animation_state->currently_running_for_pending_elements |= | |
| 632 animation->affects_pending_elements() && | |
| 633 animation->InEffect(last_tick_time_); | |
| 634 } | |
| 635 } | |
| 636 } | 614 } |
| 637 | 615 |
| 638 bool potentially_animating_changed_for_active_elements = | 616 if (*animation_state == previous_state) |
| 639 was_potentially_animating_for_active_elements != | |
| 640 animation_state->potentially_animating_for_active_elements; | |
| 641 bool potentially_animating_changed_for_pending_elements = | |
| 642 was_potentially_animating_for_pending_elements != | |
| 643 animation_state->potentially_animating_for_pending_elements; | |
| 644 bool currently_running_animation_changed_for_active_elements = | |
| 645 was_currently_running_animation_for_active_elements != | |
| 646 animation_state->currently_running_for_active_elements; | |
| 647 bool currently_running_animation_changed_for_pending_elements = | |
| 648 was_currently_running_animation_for_pending_elements != | |
| 649 animation_state->currently_running_for_pending_elements; | |
| 650 if (!potentially_animating_changed_for_active_elements && | |
| 651 !potentially_animating_changed_for_pending_elements && | |
| 652 !currently_running_animation_changed_for_active_elements && | |
| 653 !currently_running_animation_changed_for_pending_elements) | |
| 654 return; | 617 return; |
| 618 |
| 619 PropertyAnimationState diff_state = previous_state ^ *animation_state; |
| 620 |
| 655 if (has_element_in_active_list()) | 621 if (has_element_in_active_list()) |
| 656 NotifyClientAnimationChanged( | 622 NotifyClientAnimationChanged( |
| 657 property, ElementListType::ACTIVE, | 623 property, ElementListType::ACTIVE, |
| 658 potentially_animating_changed_for_active_elements, | 624 diff_state.potentially_animating_for_active_elements, |
| 659 currently_running_animation_changed_for_active_elements); | 625 diff_state.currently_running_for_active_elements); |
| 660 if (has_element_in_pending_list()) | 626 if (has_element_in_pending_list()) |
| 661 NotifyClientAnimationChanged( | 627 NotifyClientAnimationChanged( |
| 662 property, ElementListType::PENDING, | 628 property, ElementListType::PENDING, |
| 663 potentially_animating_changed_for_pending_elements, | 629 diff_state.potentially_animating_for_pending_elements, |
| 664 currently_running_animation_changed_for_pending_elements); | 630 diff_state.currently_running_for_pending_elements); |
| 665 } | 631 } |
| 666 | 632 |
| 667 bool ElementAnimations::HasActiveAnimation() const { | 633 bool ElementAnimations::HasActiveAnimation() const { |
| 668 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 634 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
| 669 AnimationPlayer* player; | 635 AnimationPlayer* player; |
| 670 while ((player = it.GetNext()) != nullptr) { | 636 while ((player = it.GetNext()) != nullptr) { |
| 671 if (player->HasActiveAnimation()) | 637 if (player->HasActiveAnimation()) |
| 672 return true; | 638 return true; |
| 673 } | 639 } |
| 674 | 640 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 if (animation_host()) { | 819 if (animation_host()) { |
| 854 DCHECK(animation_host()->mutator_host_client()); | 820 DCHECK(animation_host()->mutator_host_client()); |
| 855 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 821 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
| 856 element_id()); | 822 element_id()); |
| 857 } | 823 } |
| 858 | 824 |
| 859 return gfx::ScrollOffset(); | 825 return gfx::ScrollOffset(); |
| 860 } | 826 } |
| 861 | 827 |
| 862 } // namespace cc | 828 } // namespace cc |
| OLD | NEW |