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

Side by Side Diff: cc/animation/scroll_offset_animation_curve.cc

Issue 1734063003: Share animations from compositor to main thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make NotifyAnimationTakeover pure virtual Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/animation/scroll_offset_animation_curve.h" 5 #include "cc/animation/scroll_offset_animation_curve.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 base::TimeDelta ScrollOffsetAnimationCurve::Duration() const { 128 base::TimeDelta ScrollOffsetAnimationCurve::Duration() const {
129 return total_animation_duration_; 129 return total_animation_duration_;
130 } 130 }
131 131
132 AnimationCurve::CurveType ScrollOffsetAnimationCurve::Type() const { 132 AnimationCurve::CurveType ScrollOffsetAnimationCurve::Type() const {
133 return SCROLL_OFFSET; 133 return SCROLL_OFFSET;
134 } 134 }
135 135
136 scoped_ptr<AnimationCurve> ScrollOffsetAnimationCurve::Clone() const { 136 scoped_ptr<AnimationCurve> ScrollOffsetAnimationCurve::Clone() const {
137 return CloneToScrollOffsetAnimationCurve();
138 }
139
140 scoped_ptr<ScrollOffsetAnimationCurve>
141 ScrollOffsetAnimationCurve::CloneToScrollOffsetAnimationCurve() const {
137 scoped_ptr<TimingFunction> timing_function( 142 scoped_ptr<TimingFunction> timing_function(
138 static_cast<TimingFunction*>(timing_function_->Clone().release())); 143 static_cast<TimingFunction*>(timing_function_->Clone().release()));
139 scoped_ptr<ScrollOffsetAnimationCurve> curve_clone = 144 scoped_ptr<ScrollOffsetAnimationCurve> curve_clone =
140 Create(target_value_, std::move(timing_function), duration_behavior_); 145 Create(target_value_, std::move(timing_function), duration_behavior_);
141 curve_clone->initial_value_ = initial_value_; 146 curve_clone->initial_value_ = initial_value_;
142 curve_clone->total_animation_duration_ = total_animation_duration_; 147 curve_clone->total_animation_duration_ = total_animation_duration_;
143 curve_clone->last_retarget_ = last_retarget_; 148 curve_clone->last_retarget_ = last_retarget_;
144 curve_clone->has_set_initial_value_ = has_set_initial_value_; 149 curve_clone->has_set_initial_value_ = has_set_initial_value_;
145 return std::move(curve_clone); 150 return curve_clone;
146 } 151 }
147 152
148 static double VelocityBasedDurationBound(gfx::Vector2dF old_delta, 153 static double VelocityBasedDurationBound(gfx::Vector2dF old_delta,
149 double old_normalized_velocity, 154 double old_normalized_velocity,
150 double old_duration, 155 double old_duration,
151 gfx::Vector2dF new_delta) { 156 gfx::Vector2dF new_delta) {
152 double old_delta_max_dimension = MaximumDimension(old_delta); 157 double old_delta_max_dimension = MaximumDimension(old_delta);
153 double new_delta_max_dimension = MaximumDimension(new_delta); 158 double new_delta_max_dimension = MaximumDimension(new_delta);
154 159
155 // If we are already at the target, stop animating. 160 // If we are already at the target, stop animating.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); 213 (MaximumDimension(old_delta) / MaximumDimension(new_delta));
209 214
210 initial_value_ = current_position; 215 initial_value_ = current_position;
211 target_value_ = new_target; 216 target_value_ = new_target;
212 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); 217 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration);
213 last_retarget_ = base::TimeDelta::FromSecondsD(t); 218 last_retarget_ = base::TimeDelta::FromSecondsD(t);
214 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); 219 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity);
215 } 220 }
216 221
217 } // namespace cc 222 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698