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 gfx::Transform; |
danakj
2012/11/24 02:34:54
erase this line, or undo both changes in this file
| |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 template <class Keyframe> | 13 template <class Keyframe> |
14 void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& ke yframes) | 14 void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& ke yframes) |
15 { | 15 { |
16 // Usually, the keyframes will be added in order, so this loop would be unne cessary and | 16 // Usually, the keyframes will be added in order, so this loop would be unne cessary and |
17 // we should skip it if possible. | 17 // we should skip it if possible. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 } | 189 } |
190 | 190 |
191 scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const | 191 scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const |
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 WebKit::WebTransformationMatrix KeyframedTransformAnimationCurve::getValue(doubl e t) const |
200 { | 200 { |
201 if (t <= m_keyframes.first()->time()) | 201 if (t <= m_keyframes.first()->time()) |
202 return m_keyframes.first()->value().apply(); | 202 return m_keyframes.first()->value().apply(); |
203 | 203 |
204 if (t >= m_keyframes.last()->time()) | 204 if (t >= m_keyframes.last()->time()) |
205 return m_keyframes.last()->value().apply(); | 205 return m_keyframes.last()->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 |