| 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/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "base/trace_event/trace_event_argument.h" | 12 #include "base/trace_event/trace_event_argument.h" |
| 13 #include "cc/animation/animation_delegate.h" | 13 #include "cc/animation/animation_delegate.h" |
| 14 #include "cc/animation/animation_events.h" | 14 #include "cc/animation/animation_events.h" |
| 15 #include "cc/animation/animation_id_provider.h" | 15 #include "cc/animation/animation_id_provider.h" |
| 16 #include "cc/animation/animation_player.h" | 16 #include "cc/animation/animation_player.h" |
| 17 #include "cc/animation/animation_timeline.h" | 17 #include "cc/animation/animation_timeline.h" |
| 18 #include "cc/animation/element_animations.h" | 18 #include "cc/animation/element_animations.h" |
| 19 #include "cc/animation/scroll_offset_animation_curve.h" | 19 #include "cc/animation/scroll_offset_animation_curve.h" |
| 20 #include "cc/animation/timing_function.h" | 20 #include "cc/animation/timing_function.h" |
| 21 #include "cc/trees/mutator_host_client.h" |
| 21 #include "ui/gfx/geometry/box_f.h" | 22 #include "ui/gfx/geometry/box_f.h" |
| 22 #include "ui/gfx/geometry/scroll_offset.h" | 23 #include "ui/gfx/geometry/scroll_offset.h" |
| 23 | 24 |
| 24 namespace cc { | 25 namespace cc { |
| 25 | 26 |
| 26 class AnimationHost::ScrollOffsetAnimations : public AnimationDelegate { | 27 class AnimationHost::ScrollOffsetAnimations : public AnimationDelegate { |
| 27 public: | 28 public: |
| 28 explicit ScrollOffsetAnimations(AnimationHost* animation_host) | 29 explicit ScrollOffsetAnimations(AnimationHost* animation_host) |
| 29 : animation_host_(animation_host), | 30 : animation_host_(animation_host), |
| 30 scroll_offset_timeline_( | 31 scroll_offset_timeline_( |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 430 } |
| 430 } | 431 } |
| 431 | 432 |
| 432 bool AnimationHost::ScrollOffsetAnimationWasInterrupted(int layer_id) const { | 433 bool AnimationHost::ScrollOffsetAnimationWasInterrupted(int layer_id) const { |
| 433 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 434 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 434 return element_animations | 435 return element_animations |
| 435 ? element_animations->scroll_offset_animation_was_interrupted() | 436 ? element_animations->scroll_offset_animation_was_interrupted() |
| 436 : false; | 437 : false; |
| 437 } | 438 } |
| 438 | 439 |
| 439 static ElementAnimations::ObserverType ObserverTypeFromTreeType( | |
| 440 LayerTreeType tree_type) { | |
| 441 return tree_type == LayerTreeType::ACTIVE | |
| 442 ? ElementAnimations::ObserverType::ACTIVE | |
| 443 : ElementAnimations::ObserverType::PENDING; | |
| 444 } | |
| 445 | |
| 446 bool AnimationHost::IsAnimatingFilterProperty(int layer_id, | 440 bool AnimationHost::IsAnimatingFilterProperty(int layer_id, |
| 447 LayerTreeType tree_type) const { | 441 LayerTreeType tree_type) const { |
| 448 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 442 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 449 return element_animations | 443 return element_animations |
| 450 ? element_animations->IsCurrentlyAnimatingProperty( | 444 ? element_animations->IsCurrentlyAnimatingProperty( |
| 451 TargetProperty::FILTER, ObserverTypeFromTreeType(tree_type)) | 445 TargetProperty::FILTER, tree_type) |
| 452 : false; | 446 : false; |
| 453 } | 447 } |
| 454 | 448 |
| 455 bool AnimationHost::IsAnimatingOpacityProperty(int layer_id, | 449 bool AnimationHost::IsAnimatingOpacityProperty(int layer_id, |
| 456 LayerTreeType tree_type) const { | 450 LayerTreeType tree_type) const { |
| 457 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 451 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 458 return element_animations | 452 return element_animations |
| 459 ? element_animations->IsCurrentlyAnimatingProperty( | 453 ? element_animations->IsCurrentlyAnimatingProperty( |
| 460 TargetProperty::OPACITY, ObserverTypeFromTreeType(tree_type)) | 454 TargetProperty::OPACITY, tree_type) |
| 461 : false; | 455 : false; |
| 462 } | 456 } |
| 463 | 457 |
| 464 bool AnimationHost::IsAnimatingTransformProperty( | 458 bool AnimationHost::IsAnimatingTransformProperty( |
| 465 int layer_id, | 459 int layer_id, |
| 466 LayerTreeType tree_type) const { | 460 LayerTreeType tree_type) const { |
| 467 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 461 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 468 return element_animations | 462 return element_animations |
| 469 ? element_animations->IsCurrentlyAnimatingProperty( | 463 ? element_animations->IsCurrentlyAnimatingProperty( |
| 470 TargetProperty::TRANSFORM, | 464 TargetProperty::TRANSFORM, tree_type) |
| 471 ObserverTypeFromTreeType(tree_type)) | |
| 472 : false; | 465 : false; |
| 473 } | 466 } |
| 474 | 467 |
| 475 bool AnimationHost::HasPotentiallyRunningFilterAnimation( | 468 bool AnimationHost::HasPotentiallyRunningFilterAnimation( |
| 476 int layer_id, | 469 int layer_id, |
| 477 LayerTreeType tree_type) const { | 470 LayerTreeType tree_type) const { |
| 478 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 471 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 479 return element_animations | 472 return element_animations |
| 480 ? element_animations->IsPotentiallyAnimatingProperty( | 473 ? element_animations->IsPotentiallyAnimatingProperty( |
| 481 TargetProperty::FILTER, ObserverTypeFromTreeType(tree_type)) | 474 TargetProperty::FILTER, tree_type) |
| 482 : false; | 475 : false; |
| 483 } | 476 } |
| 484 | 477 |
| 485 bool AnimationHost::HasPotentiallyRunningOpacityAnimation( | 478 bool AnimationHost::HasPotentiallyRunningOpacityAnimation( |
| 486 int layer_id, | 479 int layer_id, |
| 487 LayerTreeType tree_type) const { | 480 LayerTreeType tree_type) const { |
| 488 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 481 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 489 return element_animations | 482 return element_animations |
| 490 ? element_animations->IsPotentiallyAnimatingProperty( | 483 ? element_animations->IsPotentiallyAnimatingProperty( |
| 491 TargetProperty::OPACITY, ObserverTypeFromTreeType(tree_type)) | 484 TargetProperty::OPACITY, tree_type) |
| 492 : false; | 485 : false; |
| 493 } | 486 } |
| 494 | 487 |
| 495 bool AnimationHost::HasPotentiallyRunningTransformAnimation( | 488 bool AnimationHost::HasPotentiallyRunningTransformAnimation( |
| 496 int layer_id, | 489 int layer_id, |
| 497 LayerTreeType tree_type) const { | 490 LayerTreeType tree_type) const { |
| 498 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 491 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 499 return element_animations | 492 return element_animations |
| 500 ? element_animations->IsPotentiallyAnimatingProperty( | 493 ? element_animations->IsPotentiallyAnimatingProperty( |
| 501 TargetProperty::TRANSFORM, | 494 TargetProperty::TRANSFORM, tree_type) |
| 502 ObserverTypeFromTreeType(tree_type)) | |
| 503 : false; | 495 : false; |
| 504 } | 496 } |
| 505 | 497 |
| 506 bool AnimationHost::HasAnyAnimationTargetingProperty( | 498 bool AnimationHost::HasAnyAnimationTargetingProperty( |
| 507 int layer_id, | 499 int layer_id, |
| 508 TargetProperty::Type property) const { | 500 TargetProperty::Type property) const { |
| 509 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 501 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 510 if (!element_animations) | 502 if (!element_animations) |
| 511 return false; | 503 return false; |
| 512 | 504 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 return element_animations | 584 return element_animations |
| 593 ? element_animations->TransformAnimationBoundsForBox(box, bounds) | 585 ? element_animations->TransformAnimationBoundsForBox(box, bounds) |
| 594 : true; | 586 : true; |
| 595 } | 587 } |
| 596 | 588 |
| 597 bool AnimationHost::HasOnlyTranslationTransforms( | 589 bool AnimationHost::HasOnlyTranslationTransforms( |
| 598 int layer_id, | 590 int layer_id, |
| 599 LayerTreeType tree_type) const { | 591 LayerTreeType tree_type) const { |
| 600 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 592 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 601 return element_animations | 593 return element_animations |
| 602 ? element_animations->HasOnlyTranslationTransforms( | 594 ? element_animations->HasOnlyTranslationTransforms(tree_type) |
| 603 ObserverTypeFromTreeType(tree_type)) | |
| 604 : true; | 595 : true; |
| 605 } | 596 } |
| 606 | 597 |
| 607 bool AnimationHost::AnimationsPreserveAxisAlignment(int layer_id) const { | 598 bool AnimationHost::AnimationsPreserveAxisAlignment(int layer_id) const { |
| 608 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 599 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 609 return element_animations | 600 return element_animations |
| 610 ? element_animations->AnimationsPreserveAxisAlignment() | 601 ? element_animations->AnimationsPreserveAxisAlignment() |
| 611 : true; | 602 : true; |
| 612 } | 603 } |
| 613 | 604 |
| 614 bool AnimationHost::MaximumTargetScale(int layer_id, | 605 bool AnimationHost::MaximumTargetScale(int layer_id, |
| 615 LayerTreeType tree_type, | 606 LayerTreeType tree_type, |
| 616 float* max_scale) const { | 607 float* max_scale) const { |
| 617 *max_scale = 0.f; | 608 *max_scale = 0.f; |
| 618 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 609 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 619 return element_animations | 610 return element_animations |
| 620 ? element_animations->MaximumTargetScale( | 611 ? element_animations->MaximumTargetScale(tree_type, max_scale) |
| 621 ObserverTypeFromTreeType(tree_type), max_scale) | |
| 622 : true; | 612 : true; |
| 623 } | 613 } |
| 624 | 614 |
| 625 bool AnimationHost::AnimationStartScale(int layer_id, | 615 bool AnimationHost::AnimationStartScale(int layer_id, |
| 626 LayerTreeType tree_type, | 616 LayerTreeType tree_type, |
| 627 float* start_scale) const { | 617 float* start_scale) const { |
| 628 *start_scale = 0.f; | 618 *start_scale = 0.f; |
| 629 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 619 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 630 return element_animations | 620 return element_animations |
| 631 ? element_animations->AnimationStartScale( | 621 ? element_animations->AnimationStartScale(tree_type, start_scale) |
| 632 ObserverTypeFromTreeType(tree_type), start_scale) | |
| 633 : true; | 622 : true; |
| 634 } | 623 } |
| 635 | 624 |
| 636 bool AnimationHost::HasAnyAnimation(int layer_id) const { | 625 bool AnimationHost::HasAnyAnimation(int layer_id) const { |
| 637 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 626 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| 638 return element_animations ? element_animations->has_any_animation() : false; | 627 return element_animations ? element_animations->has_any_animation() : false; |
| 639 } | 628 } |
| 640 | 629 |
| 641 bool AnimationHost::HasActiveAnimationForTesting(int layer_id) const { | 630 bool AnimationHost::HasActiveAnimationForTesting(int layer_id) const { |
| 642 auto element_animations = GetElementAnimationsForLayerId(layer_id); | 631 auto element_animations = GetElementAnimationsForLayerId(layer_id); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 const AnimationHost::LayerToElementAnimationsMap& | 691 const AnimationHost::LayerToElementAnimationsMap& |
| 703 AnimationHost::all_element_animations_for_testing() const { | 692 AnimationHost::all_element_animations_for_testing() const { |
| 704 return layer_to_element_animations_map_; | 693 return layer_to_element_animations_map_; |
| 705 } | 694 } |
| 706 | 695 |
| 707 void AnimationHost::OnAnimationWaitingForDeletion() { | 696 void AnimationHost::OnAnimationWaitingForDeletion() { |
| 708 animation_waiting_for_deletion_ = true; | 697 animation_waiting_for_deletion_ = true; |
| 709 } | 698 } |
| 710 | 699 |
| 711 } // namespace cc | 700 } // namespace cc |
| OLD | NEW |