Chromium Code Reviews| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/InterpolableValue.h" | 6 #include "core/animation/InterpolableValue.h" |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 | 9 |
| 10 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); | 10 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); |
| 11 | 11 |
| 12 void InterpolableNumber::interpolate(const InterpolableValue &to, const double p rogress, InterpolableValue& result) const | 12 void InterpolableNumber::interpolate(const InterpolableValue &to, const double p rogress, InterpolableValue& result) const |
| 13 { | 13 { |
| 14 const InterpolableNumber& toNumber = toInterpolableNumber(to); | 14 const InterpolableNumber& toNumber = toInterpolableNumber(to); |
| 15 InterpolableNumber& resultNumber = toInterpolableNumber(result); | 15 InterpolableNumber& resultNumber = toInterpolableNumber(result); |
| 16 | 16 |
| 17 if (progress == 0) | 17 if (progress == 0) |
| 18 resultNumber.m_value = m_value; | 18 resultNumber.m_value = m_value; |
| 19 else if (progress == 1) | 19 else if (progress == 1) |
| 20 resultNumber.m_value = toNumber.m_value; | 20 resultNumber.m_value = toNumber.m_value; |
| 21 else | 21 else |
| 22 resultNumber.m_value = m_value * (1 - progress) + toNumber.m_value * pro gress; | 22 resultNumber.m_value = m_value + (toNumber.m_value - m_value) * progress ; |
|
shans
2015/01/07 23:07:49
Don't do this - you'll cause interpolation from la
evemj (not active)
2015/01/07 23:28:03
Done.
| |
| 23 } | 23 } |
| 24 | 24 |
| 25 void InterpolableBool::interpolate(const InterpolableValue &to, const double pro gress, InterpolableValue& result) const | 25 void InterpolableBool::interpolate(const InterpolableValue &to, const double pro gress, InterpolableValue& result) const |
| 26 { | 26 { |
| 27 const InterpolableBool& toBool = toInterpolableBool(to); | 27 const InterpolableBool& toBool = toInterpolableBool(to); |
| 28 InterpolableBool& resultBool = toInterpolableBool(result); | 28 InterpolableBool& resultBool = toInterpolableBool(result); |
| 29 | 29 |
| 30 if (progress < 0.5) | 30 if (progress < 0.5) |
| 31 resultBool.m_value = m_value; | 31 resultBool.m_value = m_value; |
| 32 else | 32 else |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 resultValue.m_value = AnimatableValue::interpolate(m_value.get(), toValue.m_ value.get(), progress); | 117 resultValue.m_value = AnimatableValue::interpolate(m_value.get(), toValue.m_ value.get(), progress); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void InterpolableAnimatableValue::trace(Visitor* visitor) | 120 void InterpolableAnimatableValue::trace(Visitor* visitor) |
| 121 { | 121 { |
| 122 visitor->trace(m_value); | 122 visitor->trace(m_value); |
| 123 InterpolableValue::trace(visitor); | 123 InterpolableValue::trace(visitor); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } | 126 } |
| OLD | NEW |