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

Side by Side Diff: ui/compositor/transform_animation_curve_adapter.cc

Issue 22861008: Add support for inverse transform animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the logic into a new curve adapter and did miminal work in the counter transform element. Created 7 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/transform_animation_curve_adapter.h" 5 #include "ui/compositor/transform_animation_curve_adapter.h"
6 6
7 namespace ui { 7 namespace ui {
8 8
9 TransformAnimationCurveAdapter::TransformAnimationCurveAdapter( 9 TransformAnimationCurveAdapter::TransformAnimationCurveAdapter(
10 Tween::Type tween_type, 10 Tween::Type tween_type,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 double progress = t / duration_.InSecondsF(); 44 double progress = t / duration_.InSecondsF();
45 45
46 gfx::DecomposedTransform to_return; 46 gfx::DecomposedTransform to_return;
47 gfx::BlendDecomposedTransforms(&to_return, 47 gfx::BlendDecomposedTransforms(&to_return,
48 decomposed_target_value_, 48 decomposed_target_value_,
49 decomposed_initial_value_, 49 decomposed_initial_value_,
50 Tween::CalculateValue(tween_type_, progress)); 50 Tween::CalculateValue(tween_type_, progress));
51 return gfx::ComposeTransform(to_return); 51 return gfx::ComposeTransform(to_return);
52 } 52 }
53 53
54 CounterTransformCurveAdapter::CounterTransformCurveAdapter(
55 TransformAnimationCurveAdapter parent_curve,
56 gfx::Transform initial_value,
57 base::TimeDelta duration)
58 : parent_curve_(parent_curve),
59 initial_value_(initial_value),
60 duration_(duration) {
61 effective_initial_value_ = parent_curve_.GetValue(0.0)
62 * initial_value_;
Ian Vollick 2013/08/23 12:45:19 nit: weird leading whitespace.
avallee 2013/08/23 15:01:19 Done.
63 }
64
65 CounterTransformCurveAdapter::~CounterTransformCurveAdapter() {
66 }
67
68 double CounterTransformCurveAdapter::Duration() const {
69 return duration_.InSeconds();
70 }
71
72 scoped_ptr<cc::AnimationCurve> CounterTransformCurveAdapter::Clone() const {
73 scoped_ptr<CounterTransformCurveAdapter> to_return(
74 new CounterTransformCurveAdapter(parent_curve_,
75 initial_value_,
76 duration_));
77 return to_return.PassAs<cc::AnimationCurve>();
78 }
79
80 gfx::Transform CounterTransformCurveAdapter::GetValue(
81 double t) const {
82 if (t <= 0.0)
83 return initial_value_;
84
85 gfx::Transform parent_transform = parent_curve_.GetValue(t);
86 // Invert parent
87 gfx::Transform to_return(gfx::Transform::kSkipInitialization);
88 DCHECK(parent_transform.GetInverse(&to_return));
89
90 to_return.PreconcatTransform(effective_initial_value_);
91 return to_return;
92 }
93
54 } // namespace ui 94 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698