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

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

Issue 975943002: Implemented screen rotation animation experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ash-screen-rotation-animation entry to histograms.xml. Created 5 years, 9 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/rotator/screen_rotation_animation.h ('k') | ash/rotator/screen_rotation_animator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/rotator/screen_rotation_animation.h"
6
7 #include "base/time/time.h"
8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/layer_animation_delegate.h"
10 #include "ui/gfx/animation/tween.h"
11 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/interpolated_transform.h"
13 #include "ui/gfx/transform.h"
14
15 namespace ash {
16
17 ScreenRotationAnimation::ScreenRotationAnimation(
18 ui::Layer* layer,
19 int start_degrees,
20 int end_degrees,
21 float initial_opacity,
22 float target_opacity,
23 const gfx::Point3F& initial_scale,
24 const gfx::Point3F& target_scale,
25 gfx::Point pivot,
26 base::TimeDelta duration,
27 gfx::Tween::Type tween_type)
28 : ui::LayerAnimationElement(
29 LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY,
30 duration),
31 tween_type_(tween_type),
32 initial_opacity_(initial_opacity),
33 target_opacity_(target_opacity) {
34 scoped_ptr<ui::InterpolatedTransform> scale(
35 new ui::InterpolatedTransformAboutPivot(
36 pivot, new ui::InterpolatedScale(initial_scale, target_scale)));
37
38 scoped_ptr<ui::InterpolatedTransform> rotation(
39 new ui::InterpolatedTransformAboutPivot(
40 pivot, new ui::InterpolatedRotation(start_degrees, end_degrees)));
41
42 // Use the target transform/bounds in case the layer is already animating.
43 gfx::Transform current_transform = layer->GetTargetTransform();
44 interpolated_transform_.reset(
45 new ui::InterpolatedConstantTransform(current_transform));
46 scale->SetChild(rotation.release());
47 interpolated_transform_->SetChild(scale.release());
48 }
49
50 ScreenRotationAnimation::~ScreenRotationAnimation() {
51 }
52
53 void ScreenRotationAnimation::OnStart(ui::LayerAnimationDelegate* delegate) {
54 }
55
56 bool ScreenRotationAnimation::OnProgress(double current,
57 ui::LayerAnimationDelegate* delegate) {
58 const double tweened = gfx::Tween::CalculateValue(tween_type_, current);
59 delegate->SetTransformFromAnimation(
60 interpolated_transform_->Interpolate(tweened));
61 delegate->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween(
62 tweened, initial_opacity_, target_opacity_));
63 return true;
64 }
65
66 void ScreenRotationAnimation::OnGetTarget(TargetValue* target) const {
67 target->transform = interpolated_transform_->Interpolate(1.0);
68 }
69
70 void ScreenRotationAnimation::OnAbort(ui::LayerAnimationDelegate* delegate) {
71 }
72
73 } // namespace ash
OLDNEW
« no previous file with comments | « ash/rotator/screen_rotation_animation.h ('k') | ash/rotator/screen_rotation_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698