OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_animation.h" | 5 #include "ash/rotator/screen_rotation_animation.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "base/time/time.h" | 8 #include "base/time/time.h" |
8 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
9 #include "ui/compositor/layer_animation_delegate.h" | 10 #include "ui/compositor/layer_animation_delegate.h" |
10 #include "ui/gfx/animation/tween.h" | 11 #include "ui/gfx/animation/tween.h" |
11 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
12 #include "ui/gfx/interpolated_transform.h" | 13 #include "ui/gfx/interpolated_transform.h" |
13 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
14 | 15 |
15 namespace ash { | 16 namespace ash { |
16 | 17 |
17 ScreenRotationAnimation::ScreenRotationAnimation(ui::Layer* layer, | 18 ScreenRotationAnimation::ScreenRotationAnimation(ui::Layer* layer, |
18 int start_degrees, | 19 int start_degrees, |
19 int end_degrees, | 20 int end_degrees, |
20 float initial_opacity, | 21 float initial_opacity, |
21 float target_opacity, | 22 float target_opacity, |
22 gfx::Point pivot, | 23 gfx::Point pivot, |
23 base::TimeDelta duration, | 24 base::TimeDelta duration, |
24 gfx::Tween::Type tween_type) | 25 gfx::Tween::Type tween_type) |
25 : ui::LayerAnimationElement( | 26 : ui::LayerAnimationElement( |
26 LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY, | 27 LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY, |
27 duration), | 28 duration), |
28 tween_type_(tween_type), | 29 tween_type_(tween_type), |
29 initial_opacity_(initial_opacity), | 30 initial_opacity_(initial_opacity), |
30 target_opacity_(target_opacity) { | 31 target_opacity_(target_opacity) { |
31 std::unique_ptr<ui::InterpolatedTransform> rotation( | 32 std::unique_ptr<ui::InterpolatedTransform> rotation = |
32 new ui::InterpolatedTransformAboutPivot( | 33 base::MakeUnique<ui::InterpolatedTransformAboutPivot>( |
33 pivot, new ui::InterpolatedRotation(start_degrees, end_degrees))); | 34 pivot, base::MakeUnique<ui::InterpolatedRotation>(start_degrees, |
| 35 end_degrees)); |
34 | 36 |
35 // Use the target transform/bounds in case the layer is already animating. | 37 // Use the target transform/bounds in case the layer is already animating. |
36 gfx::Transform current_transform = layer->GetTargetTransform(); | 38 gfx::Transform current_transform = layer->GetTargetTransform(); |
37 interpolated_transform_.reset( | 39 interpolated_transform_.reset( |
38 new ui::InterpolatedConstantTransform(current_transform)); | 40 new ui::InterpolatedConstantTransform(current_transform)); |
39 interpolated_transform_->SetChild(rotation.release()); | 41 interpolated_transform_->SetChild(std::move(rotation)); |
40 } | 42 } |
41 | 43 |
42 ScreenRotationAnimation::~ScreenRotationAnimation() {} | 44 ScreenRotationAnimation::~ScreenRotationAnimation() {} |
43 | 45 |
44 void ScreenRotationAnimation::OnStart(ui::LayerAnimationDelegate* delegate) {} | 46 void ScreenRotationAnimation::OnStart(ui::LayerAnimationDelegate* delegate) {} |
45 | 47 |
46 bool ScreenRotationAnimation::OnProgress(double current, | 48 bool ScreenRotationAnimation::OnProgress(double current, |
47 ui::LayerAnimationDelegate* delegate) { | 49 ui::LayerAnimationDelegate* delegate) { |
48 const double tweened = gfx::Tween::CalculateValue(tween_type_, current); | 50 const double tweened = gfx::Tween::CalculateValue(tween_type_, current); |
49 delegate->SetTransformFromAnimation( | 51 delegate->SetTransformFromAnimation( |
(...skipping 12 matching lines...) Expand all Loading... |
62 // deleting it. This is then passed here: http://crbug.com/661313 | 64 // deleting it. This is then passed here: http://crbug.com/661313 |
63 if (!delegate) | 65 if (!delegate) |
64 return; | 66 return; |
65 | 67 |
66 TargetValue target_value; | 68 TargetValue target_value; |
67 OnGetTarget(&target_value); | 69 OnGetTarget(&target_value); |
68 delegate->SetTransformFromAnimation(target_value.transform); | 70 delegate->SetTransformFromAnimation(target_value.transform); |
69 } | 71 } |
70 | 72 |
71 } // namespace ash | 73 } // namespace ash |
OLD | NEW |