Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/wm/core/window_animations.h" | 5 #include "ui/wm/core/window_animations.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 344 |
| 345 // Show/Hide windows using a fade. | 345 // Show/Hide windows using a fade. |
| 346 void AnimateShowWindow_Fade(aura::Window* window) { | 346 void AnimateShowWindow_Fade(aura::Window* window) { |
| 347 AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform()); | 347 AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void AnimateHideWindow_Fade(aura::Window* window) { | 350 void AnimateHideWindow_Fade(aura::Window* window) { |
| 351 AnimateHideWindowCommon(window, gfx::Transform()); | 351 AnimateHideWindowCommon(window, gfx::Transform()); |
| 352 } | 352 } |
| 353 | 353 |
| 354 ui::LayerAnimationElement* CreateGrowShrinkElement( | 354 std::unique_ptr<ui::LayerAnimationElement> CreateGrowShrinkElement( |
| 355 aura::Window* window, bool grow) { | 355 aura::Window* window, |
| 356 bool grow) { | |
| 356 std::unique_ptr<ui::InterpolatedTransform> scale( | 357 std::unique_ptr<ui::InterpolatedTransform> scale( |
| 357 new ui::InterpolatedScale(gfx::Point3F(kWindowAnimation_Bounce_Scale, | 358 new ui::InterpolatedScale(gfx::Point3F(kWindowAnimation_Bounce_Scale, |
| 358 kWindowAnimation_Bounce_Scale, 1), | 359 kWindowAnimation_Bounce_Scale, 1), |
| 359 gfx::Point3F(1, 1, 1))); | 360 gfx::Point3F(1, 1, 1))); |
| 360 std::unique_ptr<ui::InterpolatedTransform> scale_about_pivot( | 361 std::unique_ptr<ui::InterpolatedTransform> scale_about_pivot( |
| 361 new ui::InterpolatedTransformAboutPivot( | 362 new ui::InterpolatedTransformAboutPivot( |
| 362 gfx::Point(window->bounds().width() * 0.5, | 363 gfx::Point(window->bounds().width() * 0.5, |
| 363 window->bounds().height() * 0.5), | 364 window->bounds().height() * 0.5), |
| 364 scale.release())); | 365 scale.release())); |
| 365 scale_about_pivot->SetReversed(grow); | 366 scale_about_pivot->SetReversed(grow); |
| 366 std::unique_ptr<ui::LayerAnimationElement> transition( | 367 std::unique_ptr<ui::LayerAnimationElement> transition = |
| 367 ui::LayerAnimationElement::CreateInterpolatedTransformElement( | 368 ui::LayerAnimationElement::CreateInterpolatedTransformElement( |
| 368 scale_about_pivot.release(), | 369 scale_about_pivot.release(), |
| 369 base::TimeDelta::FromMilliseconds( | 370 base::TimeDelta::FromMilliseconds( |
| 370 kWindowAnimation_Bounce_DurationMS * | 371 kWindowAnimation_Bounce_DurationMS * |
| 371 kWindowAnimation_Bounce_GrowShrinkDurationPercent / 100))); | 372 kWindowAnimation_Bounce_GrowShrinkDurationPercent / 100)); |
| 372 transition->set_tween_type(grow ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN); | 373 transition->set_tween_type(grow ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN); |
| 373 return transition.release(); | 374 return transition; |
| 374 } | 375 } |
| 375 | 376 |
| 376 void AnimateBounce(aura::Window* window) { | 377 void AnimateBounce(aura::Window* window) { |
| 377 ui::ScopedLayerAnimationSettings scoped_settings( | 378 ui::ScopedLayerAnimationSettings scoped_settings( |
| 378 window->layer()->GetAnimator()); | 379 window->layer()->GetAnimator()); |
| 379 scoped_settings.SetPreemptionStrategy( | 380 scoped_settings.SetPreemptionStrategy( |
| 380 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 381 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 381 std::unique_ptr<ui::LayerAnimationSequence> sequence( | 382 std::unique_ptr<ui::LayerAnimationSequence> sequence( |
| 382 new ui::LayerAnimationSequence); | 383 new ui::LayerAnimationSequence); |
| 383 sequence->AddElement(CreateGrowShrinkElement(window, true)); | 384 sequence->AddElement(CreateGrowShrinkElement(window, true)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 kWindowAnimation_Rotate_DurationMS); | 430 kWindowAnimation_Rotate_DurationMS); |
| 430 | 431 |
| 431 RotateHidingWindowAnimationObserver* observer = NULL; | 432 RotateHidingWindowAnimationObserver* observer = NULL; |
| 432 | 433 |
| 433 if (!show) { | 434 if (!show) { |
| 434 observer = new RotateHidingWindowAnimationObserver(window); | 435 observer = new RotateHidingWindowAnimationObserver(window); |
| 435 window->layer()->GetAnimator()->SchedulePauseForProperties( | 436 window->layer()->GetAnimator()->SchedulePauseForProperties( |
| 436 duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100, | 437 duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100, |
| 437 ui::LayerAnimationElement::OPACITY); | 438 ui::LayerAnimationElement::OPACITY); |
| 438 } | 439 } |
| 439 std::unique_ptr<ui::LayerAnimationElement> opacity( | 440 std::unique_ptr<ui::LayerAnimationElement> opacity = |
| 440 ui::LayerAnimationElement::CreateOpacityElement( | 441 ui::LayerAnimationElement::CreateOpacityElement( |
| 441 show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity, | 442 show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity, |
| 442 duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100)); | 443 duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100); |
| 443 opacity->set_tween_type(gfx::Tween::EASE_IN_OUT); | 444 opacity->set_tween_type(gfx::Tween::EASE_IN_OUT); |
| 444 window->layer()->GetAnimator()->ScheduleAnimation( | 445 window->layer()->GetAnimator()->ScheduleAnimation( |
| 445 new ui::LayerAnimationSequence(opacity.release())); | 446 new ui::LayerAnimationSequence(opacity.release())); |
| 446 | 447 |
| 447 float xcenter = window->bounds().width() * 0.5; | 448 float xcenter = window->bounds().width() * 0.5; |
| 448 | 449 |
| 449 gfx::Transform transform; | 450 gfx::Transform transform; |
| 450 transform.Translate(xcenter, 0); | 451 transform.Translate(xcenter, 0); |
| 451 transform.ApplyPerspectiveDepth(kWindowAnimation_Rotate_PerspectiveDepth); | 452 transform.ApplyPerspectiveDepth(kWindowAnimation_Rotate_PerspectiveDepth); |
| 452 transform.Translate(-xcenter, 0); | 453 transform.Translate(-xcenter, 0); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 466 | 467 |
| 467 std::unique_ptr<ui::InterpolatedTransform> rotation( | 468 std::unique_ptr<ui::InterpolatedTransform> rotation( |
| 468 new ui::InterpolatedAxisAngleRotation(gfx::Vector3dF(1, 0, 0), 0, | 469 new ui::InterpolatedAxisAngleRotation(gfx::Vector3dF(1, 0, 0), 0, |
| 469 kWindowAnimation_Rotate_DegreesX)); | 470 kWindowAnimation_Rotate_DegreesX)); |
| 470 | 471 |
| 471 scale_about_pivot->SetChild(perspective.release()); | 472 scale_about_pivot->SetChild(perspective.release()); |
| 472 translation->SetChild(scale_about_pivot.release()); | 473 translation->SetChild(scale_about_pivot.release()); |
| 473 rotation->SetChild(translation.release()); | 474 rotation->SetChild(translation.release()); |
| 474 rotation->SetReversed(show); | 475 rotation->SetReversed(show); |
| 475 | 476 |
| 476 std::unique_ptr<ui::LayerAnimationElement> transition( | 477 std::unique_ptr<ui::LayerAnimationElement> transition = |
| 477 ui::LayerAnimationElement::CreateInterpolatedTransformElement( | 478 ui::LayerAnimationElement::CreateInterpolatedTransformElement( |
| 478 rotation.release(), duration)); | 479 rotation.release(), duration); |
|
loyso (OOO)
2016/12/08 00:05:21
std::move ?
| |
| 479 ui::LayerAnimationSequence* last_sequence = | 480 ui::LayerAnimationSequence* last_sequence = |
| 480 new ui::LayerAnimationSequence(transition.release()); | 481 new ui::LayerAnimationSequence(std::move(transition)); |
| 481 window->layer()->GetAnimator()->ScheduleAnimation(last_sequence); | 482 window->layer()->GetAnimator()->ScheduleAnimation(last_sequence); |
| 482 | 483 |
| 483 if (observer) { | 484 if (observer) { |
| 484 observer->SetLastSequence(last_sequence); | 485 observer->SetLastSequence(last_sequence); |
| 485 observer->DetachAndRecreateLayers(); | 486 observer->DetachAndRecreateLayers(); |
| 486 } | 487 } |
| 487 } | 488 } |
| 488 | 489 |
| 489 void AnimateShowWindow_Rotate(aura::Window* window) { | 490 void AnimateShowWindow_Rotate(aura::Window* window) { |
| 490 AddLayerAnimationsForRotate(window, true); | 491 AddLayerAnimationsForRotate(window, true); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 // being accessed via Remote Desktop. | 661 // being accessed via Remote Desktop. |
| 661 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() == | 662 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() == |
| 662 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION) | 663 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION) |
| 663 return false; | 664 return false; |
| 664 | 665 |
| 665 // Let the user decide whether or not to play the animation. | 666 // Let the user decide whether or not to play the animation. |
| 666 return !gfx::Animation::ShouldRenderRichAnimation(); | 667 return !gfx::Animation::ShouldRenderRichAnimation(); |
| 667 } | 668 } |
| 668 | 669 |
| 669 } // namespace wm | 670 } // namespace wm |
| OLD | NEW |