Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: ash/rotator/screen_rotation_animation.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/root_window_settings.cc ('k') | ash/rotator/screen_rotation_animator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/time/time.h" 7 #include "base/time/time.h"
8 #include "ui/compositor/layer.h" 8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/layer_animation_delegate.h" 9 #include "ui/compositor/layer_animation_delegate.h"
10 #include "ui/gfx/animation/tween.h" 10 #include "ui/gfx/animation/tween.h"
11 #include "ui/gfx/geometry/point.h" 11 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/interpolated_transform.h" 12 #include "ui/gfx/interpolated_transform.h"
13 #include "ui/gfx/transform.h" 13 #include "ui/gfx/transform.h"
14 14
15 namespace ash { 15 namespace ash {
16 16
17 ScreenRotationAnimation::ScreenRotationAnimation( 17 ScreenRotationAnimation::ScreenRotationAnimation(ui::Layer* layer,
18 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)
26 : ui::LayerAnimationElement( 25 : ui::LayerAnimationElement(
27 LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY, 26 LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY,
28 duration), 27 duration),
29 tween_type_(tween_type), 28 tween_type_(tween_type),
30 initial_opacity_(initial_opacity), 29 initial_opacity_(initial_opacity),
31 target_opacity_(target_opacity) { 30 target_opacity_(target_opacity) {
32 std::unique_ptr<ui::InterpolatedTransform> rotation( 31 std::unique_ptr<ui::InterpolatedTransform> rotation(
33 new ui::InterpolatedTransformAboutPivot( 32 new ui::InterpolatedTransformAboutPivot(
34 pivot, new ui::InterpolatedRotation(start_degrees, end_degrees))); 33 pivot, new ui::InterpolatedRotation(start_degrees, end_degrees)));
35 34
36 // Use the target transform/bounds in case the layer is already animating. 35 // Use the target transform/bounds in case the layer is already animating.
37 gfx::Transform current_transform = layer->GetTargetTransform(); 36 gfx::Transform current_transform = layer->GetTargetTransform();
38 interpolated_transform_.reset( 37 interpolated_transform_.reset(
39 new ui::InterpolatedConstantTransform(current_transform)); 38 new ui::InterpolatedConstantTransform(current_transform));
40 interpolated_transform_->SetChild(rotation.release()); 39 interpolated_transform_->SetChild(rotation.release());
41 } 40 }
42 41
43 ScreenRotationAnimation::~ScreenRotationAnimation() { 42 ScreenRotationAnimation::~ScreenRotationAnimation() {}
44 }
45 43
46 void ScreenRotationAnimation::OnStart(ui::LayerAnimationDelegate* delegate) { 44 void ScreenRotationAnimation::OnStart(ui::LayerAnimationDelegate* delegate) {}
47 }
48 45
49 bool ScreenRotationAnimation::OnProgress(double current, 46 bool ScreenRotationAnimation::OnProgress(double current,
50 ui::LayerAnimationDelegate* delegate) { 47 ui::LayerAnimationDelegate* delegate) {
51 const double tweened = gfx::Tween::CalculateValue(tween_type_, current); 48 const double tweened = gfx::Tween::CalculateValue(tween_type_, current);
52 delegate->SetTransformFromAnimation( 49 delegate->SetTransformFromAnimation(
53 interpolated_transform_->Interpolate(tweened)); 50 interpolated_transform_->Interpolate(tweened));
54 delegate->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween( 51 delegate->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween(
55 tweened, initial_opacity_, target_opacity_)); 52 tweened, initial_opacity_, target_opacity_));
56 return true; 53 return true;
57 } 54 }
58 55
59 void ScreenRotationAnimation::OnGetTarget(TargetValue* target) const { 56 void ScreenRotationAnimation::OnGetTarget(TargetValue* target) const {
60 target->transform = interpolated_transform_->Interpolate(1.0); 57 target->transform = interpolated_transform_->Interpolate(1.0);
61 } 58 }
62 59
63 void ScreenRotationAnimation::OnAbort(ui::LayerAnimationDelegate* delegate) { 60 void ScreenRotationAnimation::OnAbort(ui::LayerAnimationDelegate* delegate) {
64 TargetValue target_value; 61 TargetValue target_value;
65 OnGetTarget(&target_value); 62 OnGetTarget(&target_value);
66 delegate->SetTransformFromAnimation(target_value.transform); 63 delegate->SetTransformFromAnimation(target_value.transform);
67 } 64 }
68 65
69 } // namespace ash 66 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_settings.cc ('k') | ash/rotator/screen_rotation_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698