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 #include "cc/transform_operations.h" |
6 | 7 |
7 using WebKit::WebTransformationMatrix; | 8 using WebKit::WebTransformationMatrix; |
8 | 9 |
9 namespace cc { | 10 namespace cc { |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 template <class Keyframe> | 14 template <class Keyframe> |
14 void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& ke
yframes) | 15 void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& ke
yframes) |
15 { | 16 { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return FloatKeyframe::create(time(), value(), func.Pass()); | 85 return FloatKeyframe::create(time(), value(), func.Pass()); |
85 } | 86 } |
86 | 87 |
87 scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const WebKi
t::WebTransformOperations& value, scoped_ptr<TimingFunction> timingFunction) | 88 scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const WebKi
t::WebTransformOperations& value, scoped_ptr<TimingFunction> timingFunction) |
88 { | 89 { |
89 return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pas
s())); | 90 return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pas
s())); |
90 } | 91 } |
91 | 92 |
92 TransformKeyframe::TransformKeyframe(double time, const WebKit::WebTransformOper
ations& value, scoped_ptr<TimingFunction> timingFunction) | 93 TransformKeyframe::TransformKeyframe(double time, const WebKit::WebTransformOper
ations& value, scoped_ptr<TimingFunction> timingFunction) |
93 : Keyframe(time, timingFunction.Pass()) | 94 : Keyframe(time, timingFunction.Pass()) |
94 , m_value(value) | 95 , m_value(TransformOperations::Create(value)) |
95 { | 96 { |
96 } | 97 } |
97 | 98 |
98 TransformKeyframe::~TransformKeyframe() | 99 TransformKeyframe::~TransformKeyframe() |
99 { | 100 { |
100 } | 101 } |
101 | 102 |
102 const WebKit::WebTransformOperations& TransformKeyframe::value() const | 103 const WebKit::WebTransformOperations& TransformKeyframe::value() const |
103 { | 104 { |
104 return m_value; | 105 return *m_value; |
105 } | 106 } |
106 | 107 |
107 scoped_ptr<TransformKeyframe> TransformKeyframe::clone() const | 108 scoped_ptr<TransformKeyframe> TransformKeyframe::clone() const |
108 { | 109 { |
109 scoped_ptr<TimingFunction> func; | 110 scoped_ptr<TimingFunction> func; |
110 if (timingFunction()) | 111 if (timingFunction()) |
111 func = cloneTimingFunction(timingFunction()); | 112 func = cloneTimingFunction(timingFunction()); |
112 return TransformKeyframe::create(time(), value(), func.Pass()); | 113 return TransformKeyframe::create(time(), value(), func.Pass()); |
113 } | 114 } |
114 | 115 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 213 |
213 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() -
m_keyframes[i]->time()); | 214 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() -
m_keyframes[i]->time()); |
214 | 215 |
215 if (m_keyframes[i]->timingFunction()) | 216 if (m_keyframes[i]->timingFunction()) |
216 progress = m_keyframes[i]->timingFunction()->getValue(progress); | 217 progress = m_keyframes[i]->timingFunction()->getValue(progress); |
217 | 218 |
218 return m_keyframes[i+1]->value().blend(m_keyframes[i]->value(), progress); | 219 return m_keyframes[i+1]->value().blend(m_keyframes[i]->value(), progress); |
219 } | 220 } |
220 | 221 |
221 } // namespace cc | 222 } // namespace cc |
OLD | NEW |