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

Unified 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: Remove duration parameters from the child and have the factory method pass it in. Created 7 years, 4 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
Index: ui/compositor/transform_animation_curve_adapter.cc
diff --git a/ui/compositor/transform_animation_curve_adapter.cc b/ui/compositor/transform_animation_curve_adapter.cc
index 96500b3de521210c77a8bb853a5db7dace2e708c..ff3948047e07e883dc9b134f6aa77a242af24336 100644
--- a/ui/compositor/transform_animation_curve_adapter.cc
+++ b/ui/compositor/transform_animation_curve_adapter.cc
@@ -51,4 +51,43 @@ gfx::Transform TransformAnimationCurveAdapter::GetValue(
return gfx::ComposeTransform(to_return);
}
+CounterTransformCurveAdapter::CounterTransformCurveAdapter(
+ TransformAnimationCurveAdapter parent_curve,
+ gfx::Transform initial_value,
+ base::TimeDelta duration)
+ : parent_curve_(parent_curve),
+ initial_value_(initial_value),
+ duration_(duration) {
+ effective_initial_value_ = parent_curve_.GetValue(0.0) * initial_value_;
+}
+
+CounterTransformCurveAdapter::~CounterTransformCurveAdapter() {
+}
+
+double CounterTransformCurveAdapter::Duration() const {
+ return duration_.InSeconds();
+}
+
+scoped_ptr<cc::AnimationCurve> CounterTransformCurveAdapter::Clone() const {
+ scoped_ptr<CounterTransformCurveAdapter> to_return(
+ new CounterTransformCurveAdapter(parent_curve_,
+ initial_value_,
+ duration_));
+ return to_return.PassAs<cc::AnimationCurve>();
+}
+
+gfx::Transform CounterTransformCurveAdapter::GetValue(
+ double t) const {
+ if (t <= 0.0)
+ return initial_value_;
+
+ gfx::Transform parent_transform = parent_curve_.GetValue(t);
+ // Invert parent
+ gfx::Transform to_return(gfx::Transform::kSkipInitialization);
+ DCHECK(parent_transform.GetInverse(&to_return));
+
+ to_return.PreconcatTransform(effective_initial_value_);
+ return to_return;
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698