Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: cc/keyframed_animation_curve.cc

Issue 12035029: Finish migrating cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix nits Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/keyframed_animation_curve.h ('k') | cc/keyframed_animation_curve_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
8
9 namespace cc { 7 namespace cc {
10 8
11 namespace { 9 namespace {
12 10
13 template <class Keyframe> 11 template <class Keyframe>
14 void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& ke yframes) 12 void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& ke yframes)
15 { 13 {
16 // Usually, the keyframes will be added in order, so this loop would be unne cessary and 14 // Usually, the keyframes will be added in order, so this loop would be unne cessary and
17 // we should skip it if possible. 15 // we should skip it if possible.
18 if (!keyframes.empty() && keyframe->time() < keyframes.back()->time()) { 16 if (!keyframes.empty() && keyframe->time() < keyframes.back()->time()) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 187 }
190 188
191 scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const 189 scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const
192 { 190 {
193 scoped_ptr<KeyframedTransformAnimationCurve> toReturn(KeyframedTransformAnim ationCurve::create()); 191 scoped_ptr<KeyframedTransformAnimationCurve> toReturn(KeyframedTransformAnim ationCurve::create());
194 for (size_t i = 0; i < m_keyframes.size(); ++i) 192 for (size_t i = 0; i < m_keyframes.size(); ++i)
195 toReturn->addKeyframe(m_keyframes[i]->clone()); 193 toReturn->addKeyframe(m_keyframes[i]->clone());
196 return toReturn.PassAs<AnimationCurve>(); 194 return toReturn.PassAs<AnimationCurve>();
197 } 195 }
198 196
199 WebTransformationMatrix KeyframedTransformAnimationCurve::getValue(double t) con st 197 gfx::Transform KeyframedTransformAnimationCurve::getValue(double t) const
200 { 198 {
201 if (t <= m_keyframes.front()->time()) 199 if (t <= m_keyframes.front()->time())
202 return m_keyframes.front()->value().Apply(); 200 return m_keyframes.front()->value().Apply();
203 201
204 if (t >= m_keyframes.back()->time()) 202 if (t >= m_keyframes.back()->time())
205 return m_keyframes.back()->value().Apply(); 203 return m_keyframes.back()->value().Apply();
206 204
207 size_t i = 0; 205 size_t i = 0;
208 for (; i < m_keyframes.size() - 1; ++i) { 206 for (; i < m_keyframes.size() - 1; ++i) {
209 if (t < m_keyframes[i+1]->time()) 207 if (t < m_keyframes[i+1]->time())
210 break; 208 break;
211 } 209 }
212 210
213 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() - m_keyframes[i]->time()); 211 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() - m_keyframes[i]->time());
214 212
215 if (m_keyframes[i]->timingFunction()) 213 if (m_keyframes[i]->timingFunction())
216 progress = m_keyframes[i]->timingFunction()->getValue(progress); 214 progress = m_keyframes[i]->timingFunction()->getValue(progress);
217 215
218 return m_keyframes[i+1]->value().Blend(m_keyframes[i]->value(), progress); 216 return m_keyframes[i+1]->value().Blend(m_keyframes[i]->value(), progress);
219 } 217 }
220 218
221 } // namespace cc 219 } // namespace cc
OLDNEW
« no previous file with comments | « cc/keyframed_animation_curve.h ('k') | cc/keyframed_animation_curve_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698