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

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

Issue 1950613004: Fix bounds clamping during composited smooth scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit test Created 4 years, 7 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
« no previous file with comments | « no previous file | cc/animation/scroll_offset_animations_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 old_normalized_velocity * old_delta_max_dimension / old_duration; 175 old_normalized_velocity * old_delta_max_dimension / old_duration;
176 double bound = (new_delta_max_dimension / old_true_velocity) * 2.5f; 176 double bound = (new_delta_max_dimension / old_true_velocity) * 2.5f;
177 177
178 // If bound < 0 we are moving in the opposite direction. 178 // If bound < 0 we are moving in the opposite direction.
179 return bound < 0 ? std::numeric_limits<double>::infinity() : bound; 179 return bound < 0 ? std::numeric_limits<double>::infinity() : bound;
180 } 180 }
181 181
182 void ScrollOffsetAnimationCurve::UpdateTarget( 182 void ScrollOffsetAnimationCurve::UpdateTarget(
183 double t, 183 double t,
184 const gfx::ScrollOffset& new_target) { 184 const gfx::ScrollOffset& new_target) {
185 if (std::abs(MaximumDimension(target_value_.DeltaFrom(new_target))) <
186 kEpsilon) {
187 target_value_ = new_target;
188 return;
189 }
185 gfx::ScrollOffset current_position = 190 gfx::ScrollOffset current_position =
186 GetValue(base::TimeDelta::FromSecondsD(t)); 191 GetValue(base::TimeDelta::FromSecondsD(t));
187 gfx::Vector2dF old_delta = target_value_.DeltaFrom(initial_value_); 192 gfx::Vector2dF old_delta = target_value_.DeltaFrom(initial_value_);
188 gfx::Vector2dF new_delta = new_target.DeltaFrom(current_position); 193 gfx::Vector2dF new_delta = new_target.DeltaFrom(current_position);
189 194
190 double old_duration = 195 double old_duration =
191 (total_animation_duration_ - last_retarget_).InSecondsF(); 196 (total_animation_duration_ - last_retarget_).InSecondsF();
192 double old_normalized_velocity = timing_function_->Velocity( 197 double old_normalized_velocity = timing_function_->Velocity(
193 (t - last_retarget_.InSecondsF()) / old_duration); 198 (t - last_retarget_.InSecondsF()) / old_duration);
194 199
(...skipping 20 matching lines...) Expand all
215 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); 220 (MaximumDimension(old_delta) / MaximumDimension(new_delta));
216 221
217 initial_value_ = current_position; 222 initial_value_ = current_position;
218 target_value_ = new_target; 223 target_value_ = new_target;
219 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); 224 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration);
220 last_retarget_ = base::TimeDelta::FromSecondsD(t); 225 last_retarget_ = base::TimeDelta::FromSecondsD(t);
221 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); 226 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity);
222 } 227 }
223 228
224 } // namespace cc 229 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/animation/scroll_offset_animations_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698