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); | |
11 | |
12 void InterpolableNumber::interpolate(const InterpolableValue &to, const double p
rogress, InterpolableValue& result) const | 10 void InterpolableNumber::interpolate(const InterpolableValue &to, const double p
rogress, InterpolableValue& result) const |
13 { | 11 { |
14 const InterpolableNumber& toNumber = toInterpolableNumber(to); | 12 const InterpolableNumber& toNumber = toInterpolableNumber(to); |
15 InterpolableNumber& resultNumber = toInterpolableNumber(result); | 13 InterpolableNumber& resultNumber = toInterpolableNumber(result); |
16 | 14 |
17 if (progress == 0 || m_value == toNumber.m_value) | 15 if (progress == 0 || m_value == toNumber.m_value) |
18 resultNumber.m_value = m_value; | 16 resultNumber.m_value = m_value; |
19 else if (progress == 1) | 17 else if (progress == 1) |
20 resultNumber.m_value = toNumber.m_value; | 18 resultNumber.m_value = toNumber.m_value; |
21 else | 19 else |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 52 } |
55 | 53 |
56 void InterpolableList::scaleAndAdd(double scale, const InterpolableValue& other) | 54 void InterpolableList::scaleAndAdd(double scale, const InterpolableValue& other) |
57 { | 55 { |
58 const InterpolableList& otherList = toInterpolableList(other); | 56 const InterpolableList& otherList = toInterpolableList(other); |
59 ASSERT(otherList.m_size == m_size); | 57 ASSERT(otherList.m_size == m_size); |
60 for (size_t i = 0; i < m_size; i++) | 58 for (size_t i = 0; i < m_size; i++) |
61 m_values[i]->scaleAndAdd(scale, *otherList.m_values[i]); | 59 m_values[i]->scaleAndAdd(scale, *otherList.m_values[i]); |
62 } | 60 } |
63 | 61 |
64 DEFINE_TRACE(InterpolableList) | |
65 { | |
66 visitor->trace(m_values); | |
67 InterpolableValue::trace(visitor); | |
68 } | |
69 | |
70 void InterpolableAnimatableValue::interpolate(const InterpolableValue& to, const
double progress, InterpolableValue& result) const | 62 void InterpolableAnimatableValue::interpolate(const InterpolableValue& to, const
double progress, InterpolableValue& result) const |
71 { | 63 { |
72 const InterpolableAnimatableValue& toValue = toInterpolableAnimatableValue(t
o); | 64 const InterpolableAnimatableValue& toValue = toInterpolableAnimatableValue(t
o); |
73 InterpolableAnimatableValue& resultValue = toInterpolableAnimatableValue(res
ult); | 65 InterpolableAnimatableValue& resultValue = toInterpolableAnimatableValue(res
ult); |
74 if (progress == 0) | 66 if (progress == 0) |
75 resultValue.m_value = m_value; | 67 resultValue.m_value = m_value; |
76 if (progress == 1) | 68 if (progress == 1) |
77 resultValue.m_value = toValue.m_value; | 69 resultValue.m_value = toValue.m_value; |
78 resultValue.m_value = AnimatableValue::interpolate(m_value.get(), toValue.m_
value.get(), progress); | 70 resultValue.m_value = AnimatableValue::interpolate(m_value.get(), toValue.m_
value.get(), progress); |
79 } | 71 } |
80 | 72 |
81 DEFINE_TRACE(InterpolableAnimatableValue) | |
82 { | |
83 visitor->trace(m_value); | |
84 InterpolableValue::trace(visitor); | |
85 } | 73 } |
86 | |
87 } | |
OLD | NEW |