diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-27 05:51:20 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-27 05:51:20 +0000 |
commit | 8d2a9a32d0d09d09abf561bea48e97e436f84609 (patch) | |
tree | ac5e6cb24a9e0f05ba32ad735a0648982d909d11 /ash/rotator | |
parent | 4f0e111044e56a31274813aecd8ae1384e6a0a12 (diff) | |
download | chromium_src-8d2a9a32d0d09d09abf561bea48e97e436f84609.zip chromium_src-8d2a9a32d0d09d09abf561bea48e97e436f84609.tar.gz chromium_src-8d2a9a32d0d09d09abf561bea48e97e436f84609.tar.bz2 |
cros: Fix crash with screen rotation animation
Ensure the interpolated_transform_ member is initialized in the constructor
such that OnGetTarget() can be called before OnStart(). I added the animation
delegate to the constructor as we need it to initialize the transformation
matrix.
BUG=172328
TEST=manual, Ctrl-Alt-Shift-F3 should spin the windows and not crash
Review URL: https://chromiumcodereview.appspot.com/12087009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/rotator')
-rw-r--r-- | ash/rotator/screen_rotation.cc | 16 | ||||
-rw-r--r-- | ash/rotator/screen_rotation.h | 9 |
2 files changed, 18 insertions, 7 deletions
diff --git a/ash/rotator/screen_rotation.cc b/ash/rotator/screen_rotation.cc index d4330a4..ecb45ef 100644 --- a/ash/rotator/screen_rotation.cc +++ b/ash/rotator/screen_rotation.cc @@ -31,19 +31,24 @@ base::TimeDelta GetTransitionDuration(int degrees) { } // namespace -ScreenRotation::ScreenRotation(int degrees) +ScreenRotation::ScreenRotation(int degrees, + ui::LayerAnimationDelegate* delegate) : ui::LayerAnimationElement(GetProperties(), GetTransitionDuration(degrees)), degrees_(degrees) { + InitTransform(delegate); } ScreenRotation::~ScreenRotation() { } -void ScreenRotation::OnStart(ui::LayerAnimationDelegate* delegate) { - // No rotation required. - if (degrees_ == 0) +void ScreenRotation::InitTransform(ui::LayerAnimationDelegate* delegate) { + // No rotation required, use the identity transform. + if (degrees_ == 0) { + interpolated_transform_.reset( + new ui::InterpolatedConstantTransform(gfx::Transform())); return; + } const gfx::Transform& current_transform = delegate->GetTransformForAnimation(); @@ -101,6 +106,9 @@ void ScreenRotation::OnStart(ui::LayerAnimationDelegate* delegate) { interpolated_transform_->SetChild(rotation.release()); } +void ScreenRotation::OnStart(ui::LayerAnimationDelegate* delegate) { +} + bool ScreenRotation::OnProgress(double t, ui::LayerAnimationDelegate* delegate) { delegate->SetTransformFromAnimation(interpolated_transform_->Interpolate(t)); diff --git a/ash/rotator/screen_rotation.h b/ash/rotator/screen_rotation.h index 88bad2b..83d696c 100644 --- a/ash/rotator/screen_rotation.h +++ b/ash/rotator/screen_rotation.h @@ -32,10 +32,15 @@ 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. - ScreenRotation(int degrees); + // |delegate| is usually a layer. + ScreenRotation(int degrees, ui::LayerAnimationDelegate* delegate); virtual ~ScreenRotation(); private: + // Generates the intermediate transformation matrices used during the + // animation. + void InitTransform(ui::LayerAnimationDelegate* delegate); + // Implementation of ui::LayerAnimationDelegate virtual void OnStart(ui::LayerAnimationDelegate* delegate) OVERRIDE; virtual bool OnProgress(double t, @@ -46,8 +51,6 @@ class ASH_EXPORT ScreenRotation : public ui::LayerAnimationElement { static const ui::LayerAnimationElement::AnimatableProperties& GetProperties(); - // Generates the intermediate transformation matrices used during the - // animation. scoped_ptr<ui::InterpolatedTransform> interpolated_transform_; // The number of degrees to rotate. |