| 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/window_rotation.h" | 5 #include "ash/rotator/window_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/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/interpolated_transform.h" | 10 #include "ui/gfx/interpolated_transform.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 new_pivot = old_pivot = gfx::Point(width / 2, height / 2); | 69 new_pivot = old_pivot = gfx::Point(width / 2, height / 2); |
| 70 new_origin_.SetPoint(width, height); | 70 new_origin_.SetPoint(width, height); |
| 71 break; | 71 break; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Convert points to world space. | 74 // Convert points to world space. |
| 75 current_transform.TransformPoint(&old_pivot); | 75 current_transform.TransformPoint(&old_pivot); |
| 76 current_transform.TransformPoint(&new_pivot); | 76 current_transform.TransformPoint(&new_pivot); |
| 77 current_transform.TransformPoint(&new_origin_); | 77 current_transform.TransformPoint(&new_origin_); |
| 78 | 78 |
| 79 std::unique_ptr<ui::InterpolatedTransform> rotation( | 79 std::unique_ptr<ui::InterpolatedTransform> rotation = |
| 80 new ui::InterpolatedTransformAboutPivot( | 80 base::MakeUnique<ui::InterpolatedTransformAboutPivot>( |
| 81 old_pivot, new ui::InterpolatedRotation(0, degrees_))); | 81 old_pivot, base::MakeUnique<ui::InterpolatedRotation>(0, degrees_)); |
| 82 | 82 |
| 83 std::unique_ptr<ui::InterpolatedTransform> translation( | 83 std::unique_ptr<ui::InterpolatedTransform> translation = |
| 84 new ui::InterpolatedTranslation( | 84 base::MakeUnique<ui::InterpolatedTranslation>( |
| 85 gfx::PointF(), gfx::PointF(new_pivot.x() - old_pivot.x(), | 85 gfx::PointF(), gfx::PointF(new_pivot.x() - old_pivot.x(), |
| 86 new_pivot.y() - old_pivot.y()))); | 86 new_pivot.y() - old_pivot.y())); |
| 87 | 87 |
| 88 float scale_factor = 0.9f; | 88 float scale_factor = 0.9f; |
| 89 std::unique_ptr<ui::InterpolatedTransform> scale_down( | 89 std::unique_ptr<ui::InterpolatedTransform> scale_down = |
| 90 new ui::InterpolatedScale(1.0f, scale_factor, 0.0f, 0.5f)); | 90 base::MakeUnique<ui::InterpolatedScale>(1.0f, scale_factor, 0.0f, 0.5f); |
| 91 | 91 |
| 92 std::unique_ptr<ui::InterpolatedTransform> scale_up( | 92 std::unique_ptr<ui::InterpolatedTransform> scale_up = |
| 93 new ui::InterpolatedScale(1.0f, 1.0f / scale_factor, 0.5f, 1.0f)); | 93 base::MakeUnique<ui::InterpolatedScale>(1.0f, 1.0f / scale_factor, 0.5f, |
| 94 1.0f); |
| 94 | 95 |
| 95 interpolated_transform_.reset( | 96 interpolated_transform_.reset( |
| 96 new ui::InterpolatedConstantTransform(current_transform)); | 97 new ui::InterpolatedConstantTransform(current_transform)); |
| 97 | 98 |
| 98 scale_up->SetChild(scale_down.release()); | 99 scale_up->SetChild(std::move(scale_down)); |
| 99 translation->SetChild(scale_up.release()); | 100 translation->SetChild(std::move(scale_up)); |
| 100 rotation->SetChild(translation.release()); | 101 rotation->SetChild(std::move(translation)); |
| 101 interpolated_transform_->SetChild(rotation.release()); | 102 interpolated_transform_->SetChild(std::move(rotation)); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void WindowRotation::OnStart(ui::LayerAnimationDelegate* delegate) {} | 105 void WindowRotation::OnStart(ui::LayerAnimationDelegate* delegate) {} |
| 105 | 106 |
| 106 bool WindowRotation::OnProgress(double t, | 107 bool WindowRotation::OnProgress(double t, |
| 107 ui::LayerAnimationDelegate* delegate) { | 108 ui::LayerAnimationDelegate* delegate) { |
| 108 delegate->SetTransformFromAnimation(interpolated_transform_->Interpolate(t)); | 109 delegate->SetTransformFromAnimation(interpolated_transform_->Interpolate(t)); |
| 109 return true; | 110 return true; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void WindowRotation::OnGetTarget(TargetValue* target) const { | 113 void WindowRotation::OnGetTarget(TargetValue* target) const { |
| 113 target->transform = interpolated_transform_->Interpolate(1.0); | 114 target->transform = interpolated_transform_->Interpolate(1.0); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void WindowRotation::OnAbort(ui::LayerAnimationDelegate* delegate) {} | 117 void WindowRotation::OnAbort(ui::LayerAnimationDelegate* delegate) {} |
| 117 | 118 |
| 118 } // namespace ash | 119 } // namespace ash |
| OLD | NEW |