Index: ui/compositor/layer_animation_element.cc |
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc |
index 79f4a7f0d49a7f2dc091931760be3de4c4f7276b..076f1cf34599bb9c4bccce117b578b73c5eed2fd 100644 |
--- a/ui/compositor/layer_animation_element.cc |
+++ b/ui/compositor/layer_animation_element.cc |
@@ -9,8 +9,10 @@ |
#include "cc/animation_id_provider.h" |
#include "ui/base/animation/tween.h" |
#include "ui/compositor/float_animation_curve_adapter.h" |
+#include "ui/compositor/layer.h" |
#include "ui/compositor/layer_animation_delegate.h" |
#include "ui/compositor/layer_animator.h" |
+#include "ui/compositor/transform_animation_curve_adapter.h" |
#include "ui/gfx/interpolated_transform.h" |
namespace ui { |
@@ -486,6 +488,77 @@ class ThreadedOpacityTransition : public ThreadedLayerAnimationElement { |
DISALLOW_COPY_AND_ASSIGN(ThreadedOpacityTransition); |
}; |
+// ThreadedTransformTransition ------------------------------------------------- |
+ |
+class ThreadedTransformTransition : public ThreadedLayerAnimationElement { |
+ public: |
+ ThreadedTransformTransition(const gfx::Transform& target, |
+ base::TimeDelta duration) |
+ : ThreadedLayerAnimationElement(GetProperties(), duration), |
+ target_(target) { |
+ } |
+ virtual ~ThreadedTransformTransition() {} |
+ |
+ protected: |
+ virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { |
+ gfx::Transform start_ = delegate->GetTransformForAnimation(); |
+ gfx::Rect bounds = delegate->GetBoundsForAnimation(); |
+ float device_scale_factor = delegate->GetDeviceScaleFactor(); |
+ cc_start_ = Layer::ConvertTransformToCCTransform(start_, |
+ bounds, |
+ device_scale_factor); |
+ cc_target_ = Layer::ConvertTransformToCCTransform(target_, |
+ bounds, |
+ device_scale_factor); |
+ } |
+ |
+ virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE { |
+ if (delegate && animation_id()) { |
+ ThreadedLayerAnimationElement::OnAbort(delegate); |
+ delegate->SetTransformFromAnimation(Tween::ValueBetween( |
+ Tween::CalculateValue(tween_type(), last_progressed_fraction()), |
+ start_, |
+ target_)); |
+ } |
+ } |
+ |
+ virtual void OnEnd(LayerAnimationDelegate* delegate) OVERRIDE { |
+ delegate->SetTransformFromAnimation(target_); |
+ } |
+ |
+ virtual scoped_ptr<cc::Animation> CreateCCAnimation() OVERRIDE { |
+ scoped_ptr<cc::AnimationCurve> animation_curve( |
+ new TransformAnimationCurveAdapter(tween_type(), |
+ cc_start_, |
+ cc_target_, |
+ duration())); |
+ scoped_ptr<cc::Animation> animation( |
+ cc::Animation::create(animation_curve.Pass(), |
+ animation_id(), |
+ animation_group_id(), |
+ cc::Animation::Transform)); |
+ return animation.Pass(); |
+ } |
+ |
+ virtual void OnGetTarget(TargetValue* target) const OVERRIDE { |
+ target->transform = target_; |
+ } |
+ |
+ private: |
+ static AnimatableProperties GetProperties() { |
+ AnimatableProperties properties; |
+ properties.insert(LayerAnimationElement::TRANSFORM); |
+ return properties; |
+ } |
+ |
+ gfx::Transform start_; |
+ gfx::Transform cc_start_; |
+ const gfx::Transform target_; |
+ gfx::Transform cc_target_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ThreadedTransformTransition); |
+}; |
+ |
} // namespace |
// LayerAnimationElement::TargetValue ------------------------------------------ |
@@ -641,7 +714,7 @@ base::TimeDelta LayerAnimationElement::GetEffectiveDuration( |
LayerAnimationElement* LayerAnimationElement::CreateTransformElement( |
const gfx::Transform& transform, |
base::TimeDelta duration) { |
- return new TransformTransition(transform, duration); |
+ return new ThreadedTransformTransition(transform, duration); |
} |
// static |