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

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: Addressed mukai@'s comments from patch set 1. 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
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 const gfx::Point3F& initial_scale,
22 const gfx::Point3F& target_scale,
23 gfx::Point pivot,
24 base::TimeDelta duration)
25 : ui::LayerAnimationElement(
26 LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY,
27 duration),
28 tween_type_(gfx::Tween::LINEAR),
29 initial_opacity_(layer->opacity()),
30 target_opacity_(layer->GetTargetOpacity()) {
31 scoped_ptr<ui::InterpolatedTransform> scale(
32 new ui::InterpolatedTransformAboutPivot(
33 pivot, new ui::InterpolatedScale(initial_scale, target_scale)));
34
35 scoped_ptr<ui::InterpolatedTransform> rotation(
36 new ui::InterpolatedTransformAboutPivot(
37 pivot, new ui::InterpolatedRotation(start_degrees, end_degrees)));
38
39 // Use the target transform/bounds in case the layer is already animating.
40 gfx::Transform current_transform = layer->GetTargetTransform();
41 interpolated_transform_.reset(
42 new ui::InterpolatedConstantTransform(current_transform));
43 scale->SetChild(rotation.release());
44 interpolated_transform_->SetChild(scale.release());
45 }
46
47 ScreenRotationAnimation::~ScreenRotationAnimation() {
48 }
49
50 void ScreenRotationAnimation::OnStart(ui::LayerAnimationDelegate* delegate) {
51 }
52
53 bool ScreenRotationAnimation::OnProgress(double t,
oshima 2015/03/04 21:31:35 current? I see all other places uses t, but they s
bruthig 2015/03/06 16:00:33 Done.
54 ui::LayerAnimationDelegate* delegate) {
55 double tweened_t = gfx::Tween::CalculateValue(tween_type_, t);
56 delegate->SetTransformFromAnimation(
57 interpolated_transform_->Interpolate(tweened_t));
58 delegate->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween(
59 tweened_t, initial_opacity_, target_opacity_));
60 return true;
61 }
62
63 void ScreenRotationAnimation::OnGetTarget(TargetValue* target) const {
64 target->transform = interpolated_transform_->Interpolate(1.0);
65 }
66
67 void ScreenRotationAnimation::OnAbort(ui::LayerAnimationDelegate* delegate) {
68 }
69
70 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698