| 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 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL |
| 88 scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const Trans
formOperations& value, scoped_ptr<TimingFunction> timingFunction) |
| 89 { |
| 90 return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pas
s())); |
| 91 } |
| 92 |
| 93 TransformKeyframe::TransformKeyframe(double time, const TransformOperations& val
ue, scoped_ptr<TimingFunction> timingFunction) |
| 94 : Keyframe(time, timingFunction.Pass()) |
| 95 , m_value(value) |
| 96 { |
| 97 } |
| 98 #else |
| 87 scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const WebKi
t::WebTransformOperations& value, scoped_ptr<TimingFunction> timingFunction) | 99 scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const WebKi
t::WebTransformOperations& value, scoped_ptr<TimingFunction> timingFunction) |
| 88 { | 100 { |
| 89 return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pas
s())); | 101 return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pas
s())); |
| 90 } | 102 } |
| 91 | 103 |
| 92 TransformKeyframe::TransformKeyframe(double time, const WebKit::WebTransformOper
ations& value, scoped_ptr<TimingFunction> timingFunction) | 104 TransformKeyframe::TransformKeyframe(double time, const WebKit::WebTransformOper
ations& value, scoped_ptr<TimingFunction> timingFunction) |
| 93 : Keyframe(time, timingFunction.Pass()) | 105 : Keyframe(time, timingFunction.Pass()) |
| 94 , m_value(value) | 106 , m_value(value) |
| 95 { | 107 { |
| 96 } | 108 } |
| 109 #endif |
| 97 | 110 |
| 98 TransformKeyframe::~TransformKeyframe() | 111 TransformKeyframe::~TransformKeyframe() |
| 99 { | 112 { |
| 100 } | 113 } |
| 101 | 114 |
| 115 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL |
| 116 const TransformOperations& TransformKeyframe::value() const |
| 117 { |
| 118 return m_value; |
| 119 } |
| 120 #else |
| 102 const WebKit::WebTransformOperations& TransformKeyframe::value() const | 121 const WebKit::WebTransformOperations& TransformKeyframe::value() const |
| 103 { | 122 { |
| 104 return m_value; | 123 return m_value; |
| 105 } | 124 } |
| 125 #endif |
| 106 | 126 |
| 107 scoped_ptr<TransformKeyframe> TransformKeyframe::clone() const | 127 scoped_ptr<TransformKeyframe> TransformKeyframe::clone() const |
| 108 { | 128 { |
| 109 scoped_ptr<TimingFunction> func; | 129 scoped_ptr<TimingFunction> func; |
| 110 if (timingFunction()) | 130 if (timingFunction()) |
| 111 func = cloneTimingFunction(timingFunction()); | 131 func = cloneTimingFunction(timingFunction()); |
| 112 return TransformKeyframe::create(time(), value(), func.Pass()); | 132 return TransformKeyframe::create(time(), value(), func.Pass()); |
| 113 } | 133 } |
| 114 | 134 |
| 115 scoped_ptr<KeyframedFloatAnimationCurve> KeyframedFloatAnimationCurve::create() | 135 scoped_ptr<KeyframedFloatAnimationCurve> KeyframedFloatAnimationCurve::create() |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const | 211 scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const |
| 192 { | 212 { |
| 193 scoped_ptr<KeyframedTransformAnimationCurve> toReturn(KeyframedTransformAnim
ationCurve::create()); | 213 scoped_ptr<KeyframedTransformAnimationCurve> toReturn(KeyframedTransformAnim
ationCurve::create()); |
| 194 for (size_t i = 0; i < m_keyframes.size(); ++i) | 214 for (size_t i = 0; i < m_keyframes.size(); ++i) |
| 195 toReturn->addKeyframe(m_keyframes[i]->clone()); | 215 toReturn->addKeyframe(m_keyframes[i]->clone()); |
| 196 return toReturn.PassAs<AnimationCurve>(); | 216 return toReturn.PassAs<AnimationCurve>(); |
| 197 } | 217 } |
| 198 | 218 |
| 199 WebTransformationMatrix KeyframedTransformAnimationCurve::getValue(double t) con
st | 219 WebTransformationMatrix KeyframedTransformAnimationCurve::getValue(double t) con
st |
| 200 { | 220 { |
| 221 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL |
| 222 if (t <= m_keyframes.front()->time()) |
| 223 return m_keyframes.front()->value().Apply(); |
| 224 |
| 225 if (t >= m_keyframes.back()->time()) |
| 226 return m_keyframes.back()->value().Apply(); |
| 227 #else |
| 201 if (t <= m_keyframes.front()->time()) | 228 if (t <= m_keyframes.front()->time()) |
| 202 return m_keyframes.front()->value().apply(); | 229 return m_keyframes.front()->value().apply(); |
| 203 | 230 |
| 204 if (t >= m_keyframes.back()->time()) | 231 if (t >= m_keyframes.back()->time()) |
| 205 return m_keyframes.back()->value().apply(); | 232 return m_keyframes.back()->value().apply(); |
| 206 | 233 |
| 234 #endif |
| 235 |
| 207 size_t i = 0; | 236 size_t i = 0; |
| 208 for (; i < m_keyframes.size() - 1; ++i) { | 237 for (; i < m_keyframes.size() - 1; ++i) { |
| 209 if (t < m_keyframes[i+1]->time()) | 238 if (t < m_keyframes[i+1]->time()) |
| 210 break; | 239 break; |
| 211 } | 240 } |
| 212 | 241 |
| 213 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() -
m_keyframes[i]->time()); | 242 double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() -
m_keyframes[i]->time()); |
| 214 | 243 |
| 215 if (m_keyframes[i]->timingFunction()) | 244 if (m_keyframes[i]->timingFunction()) |
| 216 progress = m_keyframes[i]->timingFunction()->getValue(progress); | 245 progress = m_keyframes[i]->timingFunction()->getValue(progress); |
| 217 | 246 |
| 247 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL |
| 248 return m_keyframes[i+1]->value().Blend(m_keyframes[i]->value(), progress); |
| 249 #else |
| 218 return m_keyframes[i+1]->value().blend(m_keyframes[i]->value(), progress); | 250 return m_keyframes[i+1]->value().blend(m_keyframes[i]->value(), progress); |
| 251 #endif |
| 219 } | 252 } |
| 220 | 253 |
| 221 } // namespace cc | 254 } // namespace cc |
| OLD | NEW |