OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/keyframed_animation_curve.h" | 5 #include "cc/keyframed_animation_curve.h" |
6 | 6 |
7 using WebKit::WebTransformationMatrix; | 7 using WebKit::WebTransformationMatrix; |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 scoped_ptr<FloatKeyframe> FloatKeyframe::clone() const | 79 scoped_ptr<FloatKeyframe> FloatKeyframe::clone() const |
80 { | 80 { |
81 scoped_ptr<TimingFunction> func; | 81 scoped_ptr<TimingFunction> func; |
82 if (timingFunction()) | 82 if (timingFunction()) |
83 func = cloneTimingFunction(timingFunction()); | 83 func = cloneTimingFunction(timingFunction()); |
84 return FloatKeyframe::create(time(), value(), func.Pass()); | 84 return FloatKeyframe::create(time(), value(), func.Pass()); |
85 } | 85 } |
86 | 86 |
87 scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const WebKi
t::WebTransformOperations& value, scoped_ptr<TimingFunction> timingFunction) | 87 scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const Trans
formOperations& value, scoped_ptr<TimingFunction> timingFunction) |
88 { | 88 { |
89 return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pas
s())); | 89 return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pas
s())); |
90 } | 90 } |
91 | 91 |
92 TransformKeyframe::TransformKeyframe(double time, const WebKit::WebTransformOper
ations& value, scoped_ptr<TimingFunction> timingFunction) | 92 TransformKeyframe::TransformKeyframe(double time, const TransformOperations& val
ue, scoped_ptr<TimingFunction> timingFunction) |
93 : Keyframe(time, timingFunction.Pass()) | 93 : Keyframe(time, timingFunction.Pass()) |
94 , m_value(value) | 94 , m_value(value) |
95 { | 95 { |
96 } | 96 } |
97 | 97 |
98 TransformKeyframe::~TransformKeyframe() | 98 TransformKeyframe::~TransformKeyframe() |
99 { | 99 { |
100 } | 100 } |
101 | 101 |
102 const WebKit::WebTransformOperations& TransformKeyframe::value() const | 102 const TransformOperations& TransformKeyframe::value() const |
103 { | 103 { |
104 return m_value; | 104 return m_value; |
105 } | 105 } |
106 | 106 |
107 scoped_ptr<TransformKeyframe> TransformKeyframe::clone() const | 107 scoped_ptr<TransformKeyframe> TransformKeyframe::clone() const |
108 { | 108 { |
109 scoped_ptr<TimingFunction> func; | 109 scoped_ptr<TimingFunction> func; |
110 if (timingFunction()) | 110 if (timingFunction()) |
111 func = cloneTimingFunction(timingFunction()); | 111 func = cloneTimingFunction(timingFunction()); |
112 return TransformKeyframe::create(time(), value(), func.Pass()); | 112 return TransformKeyframe::create(time(), value(), func.Pass()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 { | 192 { |
193 scoped_ptr<KeyframedTransformAnimationCurve> toReturn(KeyframedTransformAnim
ationCurve::create()); | 193 scoped_ptr<KeyframedTransformAnimationCurve> toReturn(KeyframedTransformAnim
ationCurve::create()); |
194 for (size_t i = 0; i < m_keyframes.size(); ++i) | 194 for (size_t i = 0; i < m_keyframes.size(); ++i) |
195 toReturn->addKeyframe(m_keyframes[i]->clone()); | 195 toReturn->addKeyframe(m_keyframes[i]->clone()); |
196 return toReturn.PassAs<AnimationCurve>(); | 196 return toReturn.PassAs<AnimationCurve>(); |
197 } | 197 } |
198 | 198 |
199 WebTransformationMatrix KeyframedTransformAnimationCurve::getValue(double t) con
st | 199 WebTransformationMatrix KeyframedTransformAnimationCurve::getValue(double t) con
st |
200 { | 200 { |
201 if (t <= m_keyframes.front()->time()) | 201 if (t <= m_keyframes.front()->time()) |
202 return m_keyframes.front()->value().apply(); | 202 return m_keyframes.front()->value().Apply(); |
203 | 203 |
204 if (t >= m_keyframes.back()->time()) | 204 if (t >= m_keyframes.back()->time()) |
205 return m_keyframes.back()->value().apply(); | 205 return m_keyframes.back()->value().Apply(); |
206 | 206 |
207 size_t i = 0; | 207 size_t i = 0; |
208 for (; i < m_keyframes.size() - 1; ++i) { | 208 for (; i < m_keyframes.size() - 1; ++i) { |
209 if (t < m_keyframes[i+1]->time()) | 209 if (t < m_keyframes[i+1]->time()) |
210 break; | 210 break; |
211 } | 211 } |
212 | 212 |
213 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() -
m_keyframes[i]->time()); | 213 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() -
m_keyframes[i]->time()); |
214 | 214 |
215 if (m_keyframes[i]->timingFunction()) | 215 if (m_keyframes[i]->timingFunction()) |
216 progress = m_keyframes[i]->timingFunction()->getValue(progress); | 216 progress = m_keyframes[i]->timingFunction()->getValue(progress); |
217 | 217 |
218 return m_keyframes[i+1]->value().blend(m_keyframes[i]->value(), progress); | 218 return m_keyframes[i+1]->value().Blend(m_keyframes[i]->value(), progress); |
219 } | 219 } |
220 | 220 |
221 } // namespace cc | 221 } // namespace cc |
OLD | NEW |