| 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/rotator/screen_rotation.h" | 5 #include "ash/rotator/screen_rotation.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
| 9 #include "ui/gfx/interpolated_transform.h" | 9 #include "ui/gfx/interpolated_transform.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 if (degrees == 180) | 24 if (degrees == 180) |
| 25 return base::TimeDelta::FromMilliseconds(k180DegreeTransitionDurationMs); | 25 return base::TimeDelta::FromMilliseconds(k180DegreeTransitionDurationMs); |
| 26 if (degrees == 0) | 26 if (degrees == 0) |
| 27 return base::TimeDelta::FromMilliseconds(0); | 27 return base::TimeDelta::FromMilliseconds(0); |
| 28 return base::TimeDelta::FromMilliseconds(k90DegreeTransitionDurationMs); | 28 return base::TimeDelta::FromMilliseconds(k90DegreeTransitionDurationMs); |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 ScreenRotation::ScreenRotation(int degrees, ui::Layer* layer) | 33 ScreenRotation::ScreenRotation(int degrees, ui::Layer* layer) |
| 34 : ui::LayerAnimationElement(GetProperties(), | 34 : ui::LayerAnimationElement(LayerAnimationElement::TRANSFORM, |
| 35 GetTransitionDuration(degrees)), | 35 GetTransitionDuration(degrees)), |
| 36 degrees_(degrees) { | 36 degrees_(degrees) { |
| 37 InitTransform(layer); | 37 InitTransform(layer); |
| 38 } | 38 } |
| 39 | 39 |
| 40 ScreenRotation::~ScreenRotation() { | 40 ScreenRotation::~ScreenRotation() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ScreenRotation::InitTransform(ui::Layer* layer) { | 43 void ScreenRotation::InitTransform(ui::Layer* layer) { |
| 44 // No rotation required, use the identity transform. | 44 // No rotation required, use the identity transform. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void ScreenRotation::OnGetTarget(TargetValue* target) const { | 116 void ScreenRotation::OnGetTarget(TargetValue* target) const { |
| 117 target->transform = interpolated_transform_->Interpolate(1.0); | 117 target->transform = interpolated_transform_->Interpolate(1.0); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ScreenRotation::OnAbort(ui::LayerAnimationDelegate* delegate) { | 120 void ScreenRotation::OnAbort(ui::LayerAnimationDelegate* delegate) { |
| 121 } | 121 } |
| 122 | 122 |
| 123 // static | |
| 124 const ui::LayerAnimationElement::AnimatableProperties& | |
| 125 ScreenRotation::GetProperties() { | |
| 126 static ui::LayerAnimationElement::AnimatableProperties properties; | |
| 127 if (properties.empty()) | |
| 128 properties.insert(ui::LayerAnimationElement::TRANSFORM); | |
| 129 return properties; | |
| 130 } | |
| 131 | |
| 132 } // namespace ash | 123 } // namespace ash |
| OLD | NEW |