| 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 "cc/animation/animation_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 new_target.SetToMax(gfx::ScrollOffset()); | 91 new_target.SetToMax(gfx::ScrollOffset()); |
| 92 new_target.SetToMin(max_scroll_offset); | 92 new_target.SetToMin(max_scroll_offset); |
| 93 | 93 |
| 94 curve->UpdateTarget(animation->TrimTimeToCurrentIteration( | 94 curve->UpdateTarget(animation->TrimTimeToCurrentIteration( |
| 95 frame_monotonic_time).InSecondsF(), | 95 frame_monotonic_time).InSecondsF(), |
| 96 new_target); | 96 new_target); |
| 97 | 97 |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ScrollAnimationAbort() { | 101 void ScrollAnimationAbort(bool needs_completion) { |
| 102 DCHECK(scroll_offset_animation_player_); | 102 DCHECK(scroll_offset_animation_player_); |
| 103 scroll_offset_animation_player_->AbortAnimations( | 103 scroll_offset_animation_player_->AbortAnimations( |
| 104 TargetProperty::SCROLL_OFFSET); | 104 TargetProperty::SCROLL_OFFSET, needs_completion); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // AnimationDelegate implementation. | 107 // AnimationDelegate implementation. |
| 108 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 108 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 109 TargetProperty::Type target_property, | 109 TargetProperty::Type target_property, |
| 110 int group) override {} | 110 int group) override {} |
| 111 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 111 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 112 TargetProperty::Type target_property, | 112 TargetProperty::Type target_property, |
| 113 int group) override { | 113 int group) override { |
| 114 DCHECK_EQ(target_property, TargetProperty::SCROLL_OFFSET); | 114 DCHECK_EQ(target_property, TargetProperty::SCROLL_OFFSET); |
| 115 DCHECK(animation_host_->mutator_host_client()); | 115 DCHECK(animation_host_->mutator_host_client()); |
| 116 animation_host_->mutator_host_client()->ScrollOffsetAnimationFinished(); | 116 animation_host_->mutator_host_client()->ScrollOffsetAnimationFinished(); |
| 117 } | 117 } |
| 118 void NotifyAnimationAborted(base::TimeTicks monotonic_time, | 118 void NotifyAnimationAborted(base::TimeTicks monotonic_time, |
| 119 TargetProperty::Type target_property, | 119 TargetProperty::Type target_property, |
| 120 int group) override {} | 120 int group) override {} |
| 121 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, |
| 122 double animation_start_time, |
| 123 scoped_ptr<AnimationCurve> curve) override {} |
| 121 | 124 |
| 122 private: | 125 private: |
| 123 void ReattachScrollOffsetPlayerIfNeeded(int layer_id) { | 126 void ReattachScrollOffsetPlayerIfNeeded(int layer_id) { |
| 124 if (scroll_offset_animation_player_->layer_id() != layer_id) { | 127 if (scroll_offset_animation_player_->layer_id() != layer_id) { |
| 125 if (scroll_offset_animation_player_->layer_id()) | 128 if (scroll_offset_animation_player_->layer_id()) |
| 126 scroll_offset_animation_player_->DetachLayer(); | 129 scroll_offset_animation_player_->DetachLayer(); |
| 127 if (layer_id) | 130 if (layer_id) |
| 128 scroll_offset_animation_player_->AttachLayer(layer_id); | 131 scroll_offset_animation_player_->AttachLayer(layer_id); |
| 129 } | 132 } |
| 130 } | 133 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 472 |
| 470 bool AnimationHost::OpacityIsAnimatingOnImplOnly(int layer_id) const { | 473 bool AnimationHost::OpacityIsAnimatingOnImplOnly(int layer_id) const { |
| 471 LayerAnimationController* controller = GetControllerForLayerId(layer_id); | 474 LayerAnimationController* controller = GetControllerForLayerId(layer_id); |
| 472 if (!controller) | 475 if (!controller) |
| 473 return false; | 476 return false; |
| 474 | 477 |
| 475 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); | 478 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); |
| 476 return animation && animation->is_impl_only(); | 479 return animation && animation->is_impl_only(); |
| 477 } | 480 } |
| 478 | 481 |
| 482 bool AnimationHost::ScrollOffsetIsAnimatingOnImplOnly(int layer_id) const { |
| 483 LayerAnimationController* controller = GetControllerForLayerId(layer_id); |
| 484 if (!controller) |
| 485 return false; |
| 486 |
| 487 Animation* animation = |
| 488 controller->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 489 return animation && animation->is_impl_only(); |
| 490 } |
| 491 |
| 479 bool AnimationHost::TransformIsAnimatingOnImplOnly(int layer_id) const { | 492 bool AnimationHost::TransformIsAnimatingOnImplOnly(int layer_id) const { |
| 480 LayerAnimationController* controller = GetControllerForLayerId(layer_id); | 493 LayerAnimationController* controller = GetControllerForLayerId(layer_id); |
| 481 if (!controller) | 494 if (!controller) |
| 482 return false; | 495 return false; |
| 483 | 496 |
| 484 Animation* animation = controller->GetAnimation(TargetProperty::TRANSFORM); | 497 Animation* animation = controller->GetAnimation(TargetProperty::TRANSFORM); |
| 485 return animation && animation->is_impl_only(); | 498 return animation && animation->is_impl_only(); |
| 486 } | 499 } |
| 487 | 500 |
| 488 bool AnimationHost::HasFilterAnimationThatInflatesBounds(int layer_id) const { | 501 bool AnimationHost::HasFilterAnimationThatInflatesBounds(int layer_id) const { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 bool AnimationHost::ImplOnlyScrollAnimationUpdateTarget( | 592 bool AnimationHost::ImplOnlyScrollAnimationUpdateTarget( |
| 580 int layer_id, | 593 int layer_id, |
| 581 const gfx::Vector2dF& scroll_delta, | 594 const gfx::Vector2dF& scroll_delta, |
| 582 const gfx::ScrollOffset& max_scroll_offset, | 595 const gfx::ScrollOffset& max_scroll_offset, |
| 583 base::TimeTicks frame_monotonic_time) { | 596 base::TimeTicks frame_monotonic_time) { |
| 584 DCHECK(scroll_offset_animations_); | 597 DCHECK(scroll_offset_animations_); |
| 585 return scroll_offset_animations_->ScrollAnimationUpdateTarget( | 598 return scroll_offset_animations_->ScrollAnimationUpdateTarget( |
| 586 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); | 599 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); |
| 587 } | 600 } |
| 588 | 601 |
| 589 void AnimationHost::ScrollAnimationAbort() { | 602 void AnimationHost::ScrollAnimationAbort(bool needs_completion) { |
| 590 DCHECK(scroll_offset_animations_); | 603 DCHECK(scroll_offset_animations_); |
| 591 return scroll_offset_animations_->ScrollAnimationAbort(); | 604 return scroll_offset_animations_->ScrollAnimationAbort(needs_completion); |
| 592 } | 605 } |
| 593 | 606 |
| 594 } // namespace cc | 607 } // namespace cc |
| OLD | NEW |