From 9badb4e5b7512e9f18d07e252bfa43c3b26653b4 Mon Sep 17 00:00:00 2001 From: "jamescook@chromium.org" Date: Wed, 30 Jan 2013 22:16:46 +0000 Subject: Fix window rotation animation not ending cleanly cros: Sometimes the animation would leave windows partially rotated because it grabbed the current transform (and hence rotation) of the windows rather than the target. If an animation was already playing this could compute an incorrect ending transform. Also cleaned up some includes. BUG=173139 TEST=manual, hit Ctrl-Alt-Shift-F3 repeatedly, windows should always return to original position Review URL: https://chromiumcodereview.appspot.com/12083004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179712 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/rotator/screen_rotation.cc | 16 +++++++--------- ash/rotator/screen_rotation.h | 15 ++++++--------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'ash/rotator') diff --git a/ash/rotator/screen_rotation.cc b/ash/rotator/screen_rotation.cc index ecb45ef..686bc89 100644 --- a/ash/rotator/screen_rotation.cc +++ b/ash/rotator/screen_rotation.cc @@ -4,9 +4,8 @@ #include "ash/rotator/screen_rotation.h" -#include "base/debug/trace_event.h" #include "base/time.h" -#include "ui/compositor/layer_animation_delegate.h" +#include "ui/compositor/layer.h" #include "ui/gfx/interpolated_transform.h" #include "ui/gfx/rect.h" #include "ui/gfx/transform.h" @@ -31,18 +30,17 @@ base::TimeDelta GetTransitionDuration(int degrees) { } // namespace -ScreenRotation::ScreenRotation(int degrees, - ui::LayerAnimationDelegate* delegate) +ScreenRotation::ScreenRotation(int degrees, ui::Layer* layer) : ui::LayerAnimationElement(GetProperties(), GetTransitionDuration(degrees)), degrees_(degrees) { - InitTransform(delegate); + InitTransform(layer); } ScreenRotation::~ScreenRotation() { } -void ScreenRotation::InitTransform(ui::LayerAnimationDelegate* delegate) { +void ScreenRotation::InitTransform(ui::Layer* layer) { // No rotation required, use the identity transform. if (degrees_ == 0) { interpolated_transform_.reset( @@ -50,9 +48,9 @@ void ScreenRotation::InitTransform(ui::LayerAnimationDelegate* delegate) { return; } - const gfx::Transform& current_transform = - delegate->GetTransformForAnimation(); - const gfx::Rect& bounds = delegate->GetBoundsForAnimation(); + // Use the target transform/bounds in case the layer is already animating. + const gfx::Transform& current_transform = layer->GetTargetTransform(); + const gfx::Rect& bounds = layer->GetTargetBounds(); gfx::Point old_pivot; gfx::Point new_pivot; diff --git a/ash/rotator/screen_rotation.h b/ash/rotator/screen_rotation.h index 83d696c..339b99f 100644 --- a/ash/rotator/screen_rotation.h +++ b/ash/rotator/screen_rotation.h @@ -8,14 +8,12 @@ #include "ash/ash_export.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -#include "ui/base/animation/animation_delegate.h" -#include "ui/compositor/compositor_export.h" #include "ui/compositor/layer_animation_element.h" #include "ui/gfx/point.h" namespace ui { class InterpolatedTransform; -class LayerAnimationDelegate; +class Layer; } namespace aura { @@ -30,16 +28,15 @@ namespace ash { // in the middle of a transition. class ASH_EXPORT ScreenRotation : public ui::LayerAnimationElement { public: - // The screen rotation does not own the view or the listener, and these - // objects are required to outlive the Screen rotation object. - // |delegate| is usually a layer. - ScreenRotation(int degrees, ui::LayerAnimationDelegate* delegate); + // |degrees| are clockwise. |layer| is the target of the animation. Does not + // take ownership of |layer|. + ScreenRotation(int degrees, ui::Layer* layer); virtual ~ScreenRotation(); private: // Generates the intermediate transformation matrices used during the // animation. - void InitTransform(ui::LayerAnimationDelegate* delegate); + void InitTransform(ui::Layer* layer); // Implementation of ui::LayerAnimationDelegate virtual void OnStart(ui::LayerAnimationDelegate* delegate) OVERRIDE; @@ -56,7 +53,7 @@ class ASH_EXPORT ScreenRotation : public ui::LayerAnimationElement { // The number of degrees to rotate. int degrees_; - // The target origin + // The target origin. gfx::Point new_origin_; DISALLOW_COPY_AND_ASSIGN(ScreenRotation); -- cgit v1.1