Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/android/vr_shell/easing.h" | 5 #include "chrome/browser/android/vr_shell/easing.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 EaseIn::EaseIn(double power) : power_(power) {} | 26 EaseIn::EaseIn(double power) : power_(power) {} |
| 27 double EaseIn::CalculateValueImpl(double state) { | 27 double EaseIn::CalculateValueImpl(double state) { |
| 28 return pow(state, power_); | 28 return pow(state, power_); |
| 29 } | 29 } |
| 30 | 30 |
| 31 EaseOut::EaseOut(double power) : power_(power) {} | 31 EaseOut::EaseOut(double power) : power_(power) {} |
| 32 double EaseOut::CalculateValueImpl(double state) { | 32 double EaseOut::CalculateValueImpl(double state) { |
| 33 return 1.0 - pow(1.0 - state, power_); | 33 return 1.0 - pow(1.0 - state, power_); |
| 34 } | 34 } |
| 35 | 35 |
| 36 EaseInOut::EaseInOut(double power) : ease_in_(power), ease_out_(power) {} | |
| 37 double EaseInOut::CalculateValueImpl(double state) { | |
| 38 if (state < 0.5) { | |
| 39 return ease_in_.CalculateValueImpl(state * 2) / 2; | |
| 40 } else { | |
| 41 return ease_out_.CalculateValueImpl((state - 0.5) * 2) / 2 + 0.5; | |
|
mthiesse
2017/02/16 15:36:43
Could reuse ease_in_, i.e. return 1.0 - (ease_in_.
tiborg
2017/02/16 18:39:33
Good call. Math works. Should we do the same for E
mthiesse
2017/02/16 19:15:07
I wouldn't bother, I don't think that would simpli
| |
| 42 } | |
| 43 } | |
| 44 | |
| 36 double Linear::CalculateValueImpl(double state) { | 45 double Linear::CalculateValueImpl(double state) { |
| 37 return state; | 46 return state; |
| 38 } | 47 } |
| 39 | 48 |
| 40 } // namespace easing | 49 } // namespace easing |
| 41 } // namespace vr_shell | 50 } // namespace vr_shell |
| OLD | NEW |