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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: ash/rotator/screen_rotation_animation.cc
diff --git a/ash/rotator/screen_rotation_animation.cc b/ash/rotator/screen_rotation_animation.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8fc0b3798b9c0ca43de23441522ac514d957536
--- /dev/null
+++ b/ash/rotator/screen_rotation_animation.cc
@@ -0,0 +1,70 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/rotator/screen_rotation_animation.h"
+
+#include "base/time/time.h"
+#include "ui/compositor/layer.h"
+#include "ui/compositor/layer_animation_delegate.h"
+#include "ui/gfx/animation/tween.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/interpolated_transform.h"
+#include "ui/gfx/transform.h"
+
+namespace ash {
+
+ScreenRotationAnimation::ScreenRotationAnimation(
+ ui::Layer* layer,
+ int start_degrees,
+ int end_degrees,
+ const gfx::Point3F& initial_scale,
+ const gfx::Point3F& target_scale,
+ gfx::Point pivot,
+ base::TimeDelta duration)
+ : ui::LayerAnimationElement(
+ LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY,
+ duration),
+ tween_type_(gfx::Tween::LINEAR),
+ initial_opacity_(layer->opacity()),
+ target_opacity_(layer->GetTargetOpacity()) {
+ scoped_ptr<ui::InterpolatedTransform> scale(
+ new ui::InterpolatedTransformAboutPivot(
+ pivot, new ui::InterpolatedScale(initial_scale, target_scale)));
+
+ scoped_ptr<ui::InterpolatedTransform> rotation(
+ new ui::InterpolatedTransformAboutPivot(
+ pivot, new ui::InterpolatedRotation(start_degrees, end_degrees)));
+
+ // Use the target transform/bounds in case the layer is already animating.
+ gfx::Transform current_transform = layer->GetTargetTransform();
+ interpolated_transform_.reset(
+ new ui::InterpolatedConstantTransform(current_transform));
+ scale->SetChild(rotation.release());
+ interpolated_transform_->SetChild(scale.release());
+}
+
+ScreenRotationAnimation::~ScreenRotationAnimation() {
+}
+
+void ScreenRotationAnimation::OnStart(ui::LayerAnimationDelegate* delegate) {
+}
+
+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.
+ ui::LayerAnimationDelegate* delegate) {
+ double tweened_t = gfx::Tween::CalculateValue(tween_type_, t);
+ delegate->SetTransformFromAnimation(
+ interpolated_transform_->Interpolate(tweened_t));
+ delegate->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween(
+ tweened_t, initial_opacity_, target_opacity_));
+ return true;
+}
+
+void ScreenRotationAnimation::OnGetTarget(TargetValue* target) const {
+ target->transform = interpolated_transform_->Interpolate(1.0);
+}
+
+void ScreenRotationAnimation::OnAbort(ui::LayerAnimationDelegate* delegate) {
+}
+
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698