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

Unified Diff: ui/compositor/layer_animation_element.cc

Issue 12226080: Thread ui transform animations (Closed) Base URL: http://git.chromium.org/chromium/src.git@DefineThreadedLayerAnimationElements
Patch Set: Speed up animations in WebContentsViewAuraTest.QuickOverscrollDirectionChange Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/layer_animation_element.h ('k') | ui/compositor/layer_animation_element_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_animation_element.cc
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc
index 015e3f7f3d6fe9b9a89612496933bdf8908efd0f..899306bd71c161c803f9bd2ceb7c2060b0d2b2e4 100644
--- a/ui/compositor/layer_animation_element.cc
+++ b/ui/compositor/layer_animation_element.cc
@@ -9,9 +9,11 @@
#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/scoped_animation_duration_scale_mode.h"
+#include "ui/compositor/transform_animation_curve_adapter.h"
#include "ui/gfx/interpolated_transform.h"
namespace ui {
@@ -493,6 +495,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 ------------------------------------------
@@ -654,7 +727,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
« no previous file with comments | « ui/compositor/layer_animation_element.h ('k') | ui/compositor/layer_animation_element_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698