| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gfx/android/scroller.h" | 5 #include "ui/gfx/android/scroller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 | 10 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 final_y_ = start_y + total_distance * coeff_y; | 269 final_y_ = start_y + total_distance * coeff_y; |
| 270 final_y_ = Clamped(final_y_, min_y_, max_y_); | 270 final_y_ = Clamped(final_y_, min_y_, max_y_); |
| 271 | 271 |
| 272 RecomputeDeltas(); | 272 RecomputeDeltas(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 bool Scroller::ComputeScrollOffset(base::TimeTicks time) { | 275 bool Scroller::ComputeScrollOffset(base::TimeTicks time) { |
| 276 if (finished_) | 276 if (finished_) |
| 277 return false; | 277 return false; |
| 278 | 278 |
| 279 if (time == curr_time_) | |
| 280 return true; | |
| 281 | |
| 282 base::TimeDelta time_passed = time - start_time_; | 279 base::TimeDelta time_passed = time - start_time_; |
| 283 | 280 |
| 284 if (time_passed < base::TimeDelta()) { | 281 if (time_passed < base::TimeDelta()) { |
| 285 time_passed = base::TimeDelta(); | 282 time_passed = base::TimeDelta(); |
| 286 } | 283 } |
| 287 | 284 |
| 288 if (time_passed >= duration_) { | 285 if (time_passed >= duration_) { |
| 289 curr_x_ = final_x_; | 286 curr_x_ = final_x_; |
| 290 curr_y_ = final_y_; | 287 curr_y_ = final_y_; |
| 291 curr_time_ = start_time_ + duration_; | 288 curr_time_ = start_time_ + duration_; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 427 } |
| 431 | 428 |
| 432 double Scroller::GetSplineFlingDistance(float velocity) const { | 429 double Scroller::GetSplineFlingDistance(float velocity) const { |
| 433 const double l = GetSplineDeceleration(velocity); | 430 const double l = GetSplineDeceleration(velocity); |
| 434 const double decel_minus_one = kDecelerationRate - 1.0; | 431 const double decel_minus_one = kDecelerationRate - 1.0; |
| 435 return fling_friction_ * tuning_coeff_ * | 432 return fling_friction_ * tuning_coeff_ * |
| 436 std::exp(kDecelerationRate / decel_minus_one * l); | 433 std::exp(kDecelerationRate / decel_minus_one * l); |
| 437 } | 434 } |
| 438 | 435 |
| 439 } // namespace gfx | 436 } // namespace gfx |
| OLD | NEW |