| 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 "ash/wm/session_state_animator.h" | 5 #include "ash/wm/session_state_animator.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/wm/window_animations.h" | 9 #include "ash/wm/window_animations.h" |
| 10 #include "ash/wm/workspace/workspace_animations.h" | 10 #include "ash/wm/workspace/workspace_animations.h" |
| 11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
| 13 #include "ui/compositor/layer_animation_observer.h" | 13 #include "ui/compositor/layer_animation_observer.h" |
| 14 #include "ui/compositor/layer_animation_sequence.h" | 14 #include "ui/compositor/layer_animation_sequence.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Slightly-smaller size that we scale the screen down to for the pre-lock and | 22 // Slightly-smaller size that we scale the screen down to for the pre-lock and |
| 23 // pre-shutdown states. | 23 // pre-shutdown states. |
| 24 const float kSlowCloseSizeRatio = 0.95f; | 24 const float kSlowCloseSizeRatio = 0.95f; |
| 25 | 25 |
| 26 // Maximum opacity of white layer when animating pre-shutdown state. | 26 // Maximum opacity of white layer when animating pre-shutdown state. |
| 27 const float kPartialFadeRatio = 0.3f; | 27 const float kPartialFadeRatio = 0.3f; |
| 28 | 28 |
| 29 // Minimum size. Not zero as it causes numeric issues. |
| 30 const float kMinimumScale = 1e-4f; |
| 31 |
| 29 // Returns the transform that should be applied to containers for the slow-close | 32 // Returns the transform that should be applied to containers for the slow-close |
| 30 // animation. | 33 // animation. |
| 31 gfx::Transform GetSlowCloseTransform() { | 34 gfx::Transform GetSlowCloseTransform() { |
| 32 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size(); | 35 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size(); |
| 33 gfx::Transform transform; | 36 gfx::Transform transform; |
| 34 transform.SetScale(kSlowCloseSizeRatio, kSlowCloseSizeRatio); | 37 transform.Translate( |
| 35 transform.ConcatTranslate( | |
| 36 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.width() + 0.5), | 38 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.width() + 0.5), |
| 37 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.height() + 0.5)); | 39 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.height() + 0.5)); |
| 38 return transform; | 40 transform.Scale(kSlowCloseSizeRatio, kSlowCloseSizeRatio); |
| 41 return transform; |
| 39 } | 42 } |
| 40 | 43 |
| 41 // Returns the transform that should be applied to containers for the fast-close | 44 // Returns the transform that should be applied to containers for the fast-close |
| 42 // animation. | 45 // animation. |
| 43 gfx::Transform GetFastCloseTransform() { | 46 gfx::Transform GetFastCloseTransform() { |
| 44 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size(); | 47 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size(); |
| 45 gfx::Transform transform; | 48 gfx::Transform transform; |
| 46 transform.SetScale(0.0, 0.0); | 49 transform.Translate(floor(0.5 * root_size.width() + 0.5), |
| 47 transform.ConcatTranslate(floor(0.5 * root_size.width() + 0.5), | 50 floor(0.5 * root_size.height() + 0.5)); |
| 48 floor(0.5 * root_size.height() + 0.5)); | 51 transform.Scale(kMinimumScale, kMinimumScale); |
| 49 return transform; | 52 return transform; |
| 50 } | 53 } |
| 51 | 54 |
| 52 // Slowly shrinks |window| to a slightly-smaller size. | 55 // Slowly shrinks |window| to a slightly-smaller size. |
| 53 void StartSlowCloseAnimationForWindow(aura::Window* window, | 56 void StartSlowCloseAnimationForWindow(aura::Window* window, |
| 54 base::TimeDelta duration, | 57 base::TimeDelta duration, |
| 55 ui::LayerAnimationObserver* observer) { | 58 ui::LayerAnimationObserver* observer) { |
| 56 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 59 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 57 animator->set_preemption_strategy( | 60 animator->set_preemption_strategy( |
| 58 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 61 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 foreground_->SetColor(SK_ColorWHITE); | 501 foreground_->SetColor(SK_ColorWHITE); |
| 499 foreground_->GetWidget()->Show(); | 502 foreground_->GetWidget()->Show(); |
| 500 } | 503 } |
| 501 | 504 |
| 502 void SessionStateAnimator::DropForeground() { | 505 void SessionStateAnimator::DropForeground() { |
| 503 foreground_.reset(); | 506 foreground_.reset(); |
| 504 } | 507 } |
| 505 | 508 |
| 506 } // namespace internal | 509 } // namespace internal |
| 507 } // namespace ash | 510 } // namespace ash |
| OLD | NEW |