| 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/workspace/workspace_animations.h" | 5 #include "ash/wm/workspace/workspace_animations.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 enum WorkspaceScaleType { | 27 enum WorkspaceScaleType { |
| 28 WORKSPACE_SCALE_ABOVE, | 28 WORKSPACE_SCALE_ABOVE, |
| 29 WORKSPACE_SCALE_BELOW, | 29 WORKSPACE_SCALE_BELOW, |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // Applies the specified WorkspaceScaleType. | 32 // Applies the specified WorkspaceScaleType. |
| 33 void ApplyWorkspaceScale(ui::Layer* layer, WorkspaceScaleType type) { | 33 void ApplyWorkspaceScale(ui::Layer* layer, WorkspaceScaleType type) { |
| 34 const float scale = type == WORKSPACE_SCALE_ABOVE ? kWorkspaceScaleAbove : | 34 const float scale = type == WORKSPACE_SCALE_ABOVE ? kWorkspaceScaleAbove : |
| 35 kWorkspaceScaleBelow; | 35 kWorkspaceScaleBelow; |
| 36 gfx::Transform transform; | 36 gfx::Transform transform; |
| 37 transform.ConcatScale(scale, scale); | 37 transform.Translate(-layer->bounds().width() * (scale - 1.0f) / 2, |
| 38 transform.ConcatTranslate( | 38 -layer->bounds().height() * (scale - 1.0f) / 2); |
| 39 -layer->bounds().width() * (scale - 1.0f) / 2, | 39 transform.Scale(scale, scale); |
| 40 -layer->bounds().height() * (scale - 1.0f) / 2); | |
| 41 layer->SetTransform(transform); | 40 layer->SetTransform(transform); |
| 42 } | 41 } |
| 43 | 42 |
| 44 // If |details.duration| is not-empty it is returned, otherwise | 43 // If |details.duration| is not-empty it is returned, otherwise |
| 45 // |kWorkspaceSwitchTimeMS| is returned. | 44 // |kWorkspaceSwitchTimeMS| is returned. |
| 46 base::TimeDelta DurationForWorkspaceShowOrHide( | 45 base::TimeDelta DurationForWorkspaceShowOrHide( |
| 47 const WorkspaceAnimationDetails& details) { | 46 const WorkspaceAnimationDetails& details) { |
| 48 return details.duration == base::TimeDelta() ? | 47 return details.duration == base::TimeDelta() ? |
| 49 base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS) : | 48 base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS) : |
| 50 details.duration; | 49 details.duration; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // After the animation completes snap the transform back to the identity, | 151 // After the animation completes snap the transform back to the identity, |
| 153 // otherwise any one that asks for screen bounds gets a slightly scaled | 152 // otherwise any one that asks for screen bounds gets a slightly scaled |
| 154 // version. | 153 // version. |
| 155 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 154 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 156 settings.SetTransitionDuration(base::TimeDelta()); | 155 settings.SetTransitionDuration(base::TimeDelta()); |
| 157 window->layer()->SetTransform(gfx::Transform()); | 156 window->layer()->SetTransform(gfx::Transform()); |
| 158 } | 157 } |
| 159 | 158 |
| 160 } // namespace internal | 159 } // namespace internal |
| 161 } // namespace ash | 160 } // namespace ash |
| OLD | NEW |