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