| Index: ui/views/animation/flood_fill_ink_drop_ripple.cc
|
| diff --git a/ui/views/animation/flood_fill_ink_drop_ripple.cc b/ui/views/animation/flood_fill_ink_drop_ripple.cc
|
| index 10459d8c956d81588dbb6497b2631fd6b9415ffe..5ed22814c1b497d876ddb939af4ca9d8f588e13c 100644
|
| --- a/ui/views/animation/flood_fill_ink_drop_ripple.cc
|
| +++ b/ui/views/animation/flood_fill_ink_drop_ripple.cc
|
| @@ -215,11 +215,10 @@ void FloodFillInkDropRipple::AnimateStateChange(
|
| GetAnimationDuration(ACTION_PENDING_FADE_IN),
|
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
|
| gfx::Tween::EASE_IN, animation_observer);
|
| - AnimateToOpacity(visible_opacity_,
|
| - GetAnimationDuration(ACTION_PENDING_TRANSFORM) -
|
| - GetAnimationDuration(ACTION_PENDING_FADE_IN),
|
| - ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
|
| - gfx::Tween::EASE_IN, animation_observer);
|
| + PauseOpacityAnimation(GetAnimationDuration(ACTION_PENDING_TRANSFORM) -
|
| + GetAnimationDuration(ACTION_PENDING_FADE_IN),
|
| + ui::LayerAnimator::ENQUEUE_NEW_ANIMATION,
|
| + animation_observer);
|
|
|
| AnimateToTransform(GetMaxSizeTargetTransform(),
|
| GetAnimationDuration(ACTION_PENDING_TRANSFORM),
|
| @@ -260,14 +259,28 @@ void FloodFillInkDropRipple::AnimateStateChange(
|
| gfx::Tween::EASE_IN_OUT, animation_observer);
|
| break;
|
| case InkDropState::ACTIVATED: {
|
| - AnimateToOpacity(visible_opacity_,
|
| - GetAnimationDuration(ACTIVATED_FADE_IN),
|
| - ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
|
| - gfx::Tween::EASE_IN, animation_observer);
|
| - AnimateToTransform(GetMaxSizeTargetTransform(),
|
| - GetAnimationDuration(ACTIVATED_TRANSFORM),
|
| + if (old_ink_drop_state == InkDropState::ACTION_PENDING) {
|
| + // The final state of pending animation is the same as the final state
|
| + // of activated animation. We only need to enqueue a zero-length pause
|
| + // so that animation observers are notified in order.
|
| + PauseOpacityAnimation(
|
| + base::TimeDelta(),
|
| + ui::LayerAnimator::PreemptionStrategy::ENQUEUE_NEW_ANIMATION,
|
| + animation_observer);
|
| + PauseTransformAnimation(
|
| + base::TimeDelta(),
|
| + ui::LayerAnimator::PreemptionStrategy::ENQUEUE_NEW_ANIMATION,
|
| + animation_observer);
|
| + } else {
|
| + AnimateToOpacity(visible_opacity_,
|
| + GetAnimationDuration(ACTIVATED_FADE_IN),
|
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
|
| - gfx::Tween::EASE_IN_OUT, animation_observer);
|
| + gfx::Tween::EASE_IN, animation_observer);
|
| + AnimateToTransform(GetMaxSizeTargetTransform(),
|
| + GetAnimationDuration(ACTIVATED_TRANSFORM),
|
| + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET,
|
| + gfx::Tween::EASE_IN_OUT, animation_observer);
|
| + }
|
| break;
|
| }
|
| case InkDropState::DEACTIVATED:
|
| @@ -313,6 +326,27 @@ void FloodFillInkDropRipple::AnimateToTransform(
|
| animator->StartAnimation(sequence);
|
| }
|
|
|
| +void FloodFillInkDropRipple::PauseTransformAnimation(
|
| + base::TimeDelta duration,
|
| + ui::LayerAnimator::PreemptionStrategy preemption_strategy,
|
| + ui::LayerAnimationObserver* observer) {
|
| + ui::LayerAnimator* animator = painted_layer_.GetAnimator();
|
| + ui::ScopedLayerAnimationSettings animation(animator);
|
| + animation.SetPreemptionStrategy(preemption_strategy);
|
| +
|
| + std::unique_ptr<ui::LayerAnimationElement> element =
|
| + ui::LayerAnimationElement::CreatePauseElement(
|
| + ui::LayerAnimationElement::TRANSFORM, duration);
|
| +
|
| + ui::LayerAnimationSequence* sequence =
|
| + new ui::LayerAnimationSequence(std::move(element));
|
| +
|
| + if (observer)
|
| + sequence->AddObserver(observer);
|
| +
|
| + animator->StartAnimation(sequence);
|
| +}
|
| +
|
| void FloodFillInkDropRipple::SetOpacity(float opacity) {
|
| root_layer_.SetOpacity(opacity);
|
| }
|
| @@ -338,6 +372,27 @@ void FloodFillInkDropRipple::AnimateToOpacity(
|
| animator->StartAnimation(animation_sequence);
|
| }
|
|
|
| +void FloodFillInkDropRipple::PauseOpacityAnimation(
|
| + base::TimeDelta duration,
|
| + ui::LayerAnimator::PreemptionStrategy preemption_strategy,
|
| + ui::LayerAnimationObserver* observer) {
|
| + ui::LayerAnimator* animator = root_layer_.GetAnimator();
|
| + ui::ScopedLayerAnimationSettings animation(animator);
|
| + animation.SetPreemptionStrategy(preemption_strategy);
|
| +
|
| + std::unique_ptr<ui::LayerAnimationElement> element =
|
| + ui::LayerAnimationElement::CreatePauseElement(
|
| + ui::LayerAnimationElement::OPACITY, duration);
|
| +
|
| + ui::LayerAnimationSequence* sequence =
|
| + new ui::LayerAnimationSequence(std::move(element));
|
| +
|
| + if (observer)
|
| + sequence->AddObserver(observer);
|
| +
|
| + animator->StartAnimation(sequence);
|
| +}
|
| +
|
| gfx::Transform FloodFillInkDropRipple::CalculateTransform(
|
| float target_radius) const {
|
| const float target_scale = target_radius / circle_layer_delegate_.radius();
|
|
|