Index: cc/keyframed_animation_curve.cc |
diff --git a/cc/keyframed_animation_curve.cc b/cc/keyframed_animation_curve.cc |
index e913c9aa340b302ee9acc94018142f8716a24759..5473f4ed6b061799fd9868c52f6fb121d4a1cbc3 100644 |
--- a/cc/keyframed_animation_curve.cc |
+++ b/cc/keyframed_animation_curve.cc |
@@ -9,211 +9,192 @@ namespace cc { |
namespace { |
template <class Keyframe> |
-void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& keyframes) |
-{ |
- // Usually, the keyframes will be added in order, so this loop would be unnecessary and |
- // we should skip it if possible. |
- if (!keyframes.empty() && keyframe->time() < keyframes.back()->time()) { |
- for (size_t i = 0; i < keyframes.size(); ++i) { |
- if (keyframe->time() < keyframes[i]->time()) { |
- keyframes.insert(keyframes.begin() + i, keyframe.Pass()); |
- return; |
- } |
- } |
+void InsertKeyframe(scoped_ptr<Keyframe> keyframe, |
+ ScopedPtrVector<Keyframe>& keyframes) { |
+ // Usually, the keyframes will be added in order, so this loop would be |
+ // unnecessary and we should skip it if possible. |
+ if (!keyframes.empty() && keyframe->Time() < keyframes.back()->Time()) { |
+ for (size_t i = 0; i < keyframes.size(); ++i) { |
+ if (keyframe->Time() < keyframes[i]->Time()) { |
+ keyframes.insert(keyframes.begin() + i, keyframe.Pass()); |
+ return; |
+ } |
} |
+ } |
- keyframes.push_back(keyframe.Pass()); |
+ keyframes.push_back(keyframe.Pass()); |
} |
-scoped_ptr<TimingFunction> cloneTimingFunction(const TimingFunction* timingFunction) |
-{ |
- DCHECK(timingFunction); |
- scoped_ptr<AnimationCurve> curve(timingFunction->clone()); |
- return scoped_ptr<TimingFunction>(static_cast<TimingFunction*>(curve.release())); |
+scoped_ptr<TimingFunction> CloneTimingFunction( |
+ const TimingFunction* timing_function) { |
+ DCHECK(timing_function); |
+ scoped_ptr<AnimationCurve> curve(timing_function->Clone()); |
+ return scoped_ptr<TimingFunction>( |
+ static_cast<TimingFunction*>(curve.release())); |
} |
-} // namespace |
+} // namespace |
-Keyframe::Keyframe(double time, scoped_ptr<TimingFunction> timingFunction) |
- : m_time(time) |
- , m_timingFunction(timingFunction.Pass()) |
-{ |
-} |
+Keyframe::Keyframe(double time, scoped_ptr<TimingFunction> timing_function) |
+ : time_(time), |
+ timing_function_(timing_function.Pass()) {} |
-Keyframe::~Keyframe() |
-{ |
-} |
+Keyframe::~Keyframe() {} |
-double Keyframe::time() const |
-{ |
- return m_time; |
+double Keyframe::Time() const { |
+ return time_; |
} |
-const TimingFunction* Keyframe::timingFunction() const |
-{ |
- return m_timingFunction.get(); |
+scoped_ptr<FloatKeyframe> FloatKeyframe::Create( |
+ double time, |
+ float value, |
+ scoped_ptr<TimingFunction> timing_function) { |
+ return make_scoped_ptr( |
+ new FloatKeyframe(time, value, timing_function.Pass())); |
} |
-scoped_ptr<FloatKeyframe> FloatKeyframe::create(double time, float value, scoped_ptr<TimingFunction> timingFunction) |
-{ |
- return make_scoped_ptr(new FloatKeyframe(time, value, timingFunction.Pass())); |
-} |
+FloatKeyframe::FloatKeyframe(double time, |
+ float value, |
+ scoped_ptr<TimingFunction> timing_function) |
+ : Keyframe(time, timing_function.Pass()), |
+ value_(value) {} |
-FloatKeyframe::FloatKeyframe(double time, float value, scoped_ptr<TimingFunction> timingFunction) |
- : Keyframe(time, timingFunction.Pass()) |
- , m_value(value) |
-{ |
-} |
+FloatKeyframe::~FloatKeyframe() {} |
-FloatKeyframe::~FloatKeyframe() |
-{ |
+float FloatKeyframe::Value() const { |
+ return value_; |
} |
-float FloatKeyframe::value() const |
-{ |
- return m_value; |
+scoped_ptr<FloatKeyframe> FloatKeyframe::Clone() const { |
+ scoped_ptr<TimingFunction> func; |
+ if (timing_function()) |
+ func = CloneTimingFunction(timing_function()); |
+ return FloatKeyframe::Create(Time(), Value(), func.Pass()); |
} |
-scoped_ptr<FloatKeyframe> FloatKeyframe::clone() const |
-{ |
- scoped_ptr<TimingFunction> func; |
- if (timingFunction()) |
- func = cloneTimingFunction(timingFunction()); |
- return FloatKeyframe::create(time(), value(), func.Pass()); |
+scoped_ptr<TransformKeyframe> TransformKeyframe::Create( |
+ double time, |
+ const TransformOperations& value, |
+ scoped_ptr<TimingFunction> timing_function) { |
+ return make_scoped_ptr( |
+ new TransformKeyframe(time, value, timing_function.Pass())); |
} |
-scoped_ptr<TransformKeyframe> TransformKeyframe::create(double time, const TransformOperations& value, scoped_ptr<TimingFunction> timingFunction) |
-{ |
- return make_scoped_ptr(new TransformKeyframe(time, value, timingFunction.Pass())); |
-} |
- |
-TransformKeyframe::TransformKeyframe(double time, const TransformOperations& value, scoped_ptr<TimingFunction> timingFunction) |
- : Keyframe(time, timingFunction.Pass()) |
- , m_value(value) |
-{ |
-} |
+TransformKeyframe::TransformKeyframe(double time, |
+ const TransformOperations& value, |
+ scoped_ptr<TimingFunction> timing_function) |
+ : Keyframe(time, timing_function.Pass()), |
+ value_(value) {} |
-TransformKeyframe::~TransformKeyframe() |
-{ |
-} |
+TransformKeyframe::~TransformKeyframe() {} |
-const TransformOperations& TransformKeyframe::value() const |
-{ |
- return m_value; |
+const TransformOperations& TransformKeyframe::Value() const { |
+ return value_; |
} |
-scoped_ptr<TransformKeyframe> TransformKeyframe::clone() const |
-{ |
- scoped_ptr<TimingFunction> func; |
- if (timingFunction()) |
- func = cloneTimingFunction(timingFunction()); |
- return TransformKeyframe::create(time(), value(), func.Pass()); |
+scoped_ptr<TransformKeyframe> TransformKeyframe::Clone() const { |
+ scoped_ptr<TimingFunction> func; |
+ if (timing_function()) |
+ func = CloneTimingFunction(timing_function()); |
+ return TransformKeyframe::Create(Time(), Value(), func.Pass()); |
} |
-scoped_ptr<KeyframedFloatAnimationCurve> KeyframedFloatAnimationCurve::create() |
-{ |
- return make_scoped_ptr(new KeyframedFloatAnimationCurve); |
+scoped_ptr<KeyframedFloatAnimationCurve> KeyframedFloatAnimationCurve:: |
+ Create() { |
+ return make_scoped_ptr(new KeyframedFloatAnimationCurve); |
} |
-KeyframedFloatAnimationCurve::KeyframedFloatAnimationCurve() |
-{ |
-} |
+KeyframedFloatAnimationCurve::KeyframedFloatAnimationCurve() {} |
-KeyframedFloatAnimationCurve::~KeyframedFloatAnimationCurve() |
-{ |
-} |
+KeyframedFloatAnimationCurve::~KeyframedFloatAnimationCurve() {} |
-void KeyframedFloatAnimationCurve::addKeyframe(scoped_ptr<FloatKeyframe> keyframe) |
-{ |
- insertKeyframe(keyframe.Pass(), m_keyframes); |
+void KeyframedFloatAnimationCurve::AddKeyframe( |
+ scoped_ptr<FloatKeyframe> keyframe) { |
+ InsertKeyframe(keyframe.Pass(), keyframes_); |
} |
-double KeyframedFloatAnimationCurve::duration() const |
-{ |
- return m_keyframes.back()->time() - m_keyframes.front()->time(); |
+double KeyframedFloatAnimationCurve::Duration() const { |
+ return keyframes_.back()->Time() - keyframes_.front()->Time(); |
} |
-scoped_ptr<AnimationCurve> KeyframedFloatAnimationCurve::clone() const |
-{ |
- scoped_ptr<KeyframedFloatAnimationCurve> toReturn(KeyframedFloatAnimationCurve::create()); |
- for (size_t i = 0; i < m_keyframes.size(); ++i) |
- toReturn->addKeyframe(m_keyframes[i]->clone()); |
- return toReturn.PassAs<AnimationCurve>(); |
+scoped_ptr<AnimationCurve> KeyframedFloatAnimationCurve::Clone() const { |
+ scoped_ptr<KeyframedFloatAnimationCurve> to_return( |
+ KeyframedFloatAnimationCurve::Create()); |
+ for (size_t i = 0; i < keyframes_.size(); ++i) |
+ to_return->AddKeyframe(keyframes_[i]->Clone()); |
+ return to_return.PassAs<AnimationCurve>(); |
} |
-float KeyframedFloatAnimationCurve::getValue(double t) const |
-{ |
- if (t <= m_keyframes.front()->time()) |
- return m_keyframes.front()->value(); |
+float KeyframedFloatAnimationCurve::GetValue(double t) const { |
+ if (t <= keyframes_.front()->Time()) |
+ return keyframes_.front()->Value(); |
- if (t >= m_keyframes.back()->time()) |
- return m_keyframes.back()->value(); |
+ if (t >= keyframes_.back()->Time()) |
+ return keyframes_.back()->Value(); |
- size_t i = 0; |
- for (; i < m_keyframes.size() - 1; ++i) { |
- if (t < m_keyframes[i+1]->time()) |
- break; |
- } |
+ size_t i = 0; |
+ for (; i < keyframes_.size() - 1; ++i) { |
+ if (t < keyframes_[i+1]->Time()) |
+ break; |
+ } |
- float progress = static_cast<float>((t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() - m_keyframes[i]->time())); |
+ float progress = |
+ static_cast<float>((t - keyframes_[i]->Time()) / |
+ (keyframes_[i+1]->Time() - keyframes_[i]->Time())); |
- if (m_keyframes[i]->timingFunction()) |
- progress = m_keyframes[i]->timingFunction()->getValue(progress); |
+ if (keyframes_[i]->timing_function()) |
+ progress = keyframes_[i]->timing_function()->GetValue(progress); |
- return m_keyframes[i]->value() + (m_keyframes[i+1]->value() - m_keyframes[i]->value()) * progress; |
+ return keyframes_[i]->Value() + |
+ (keyframes_[i+1]->Value() - keyframes_[i]->Value()) * progress; |
} |
-scoped_ptr<KeyframedTransformAnimationCurve> KeyframedTransformAnimationCurve::create() |
-{ |
- return make_scoped_ptr(new KeyframedTransformAnimationCurve); |
+scoped_ptr<KeyframedTransformAnimationCurve> KeyframedTransformAnimationCurve:: |
+ Create() { |
+ return make_scoped_ptr(new KeyframedTransformAnimationCurve); |
} |
-KeyframedTransformAnimationCurve::KeyframedTransformAnimationCurve() |
-{ |
-} |
+KeyframedTransformAnimationCurve::KeyframedTransformAnimationCurve() {} |
-KeyframedTransformAnimationCurve::~KeyframedTransformAnimationCurve() |
-{ |
-} |
+KeyframedTransformAnimationCurve::~KeyframedTransformAnimationCurve() {} |
-void KeyframedTransformAnimationCurve::addKeyframe(scoped_ptr<TransformKeyframe> keyframe) |
-{ |
- insertKeyframe(keyframe.Pass(), m_keyframes); |
+void KeyframedTransformAnimationCurve::AddKeyframe( |
+ scoped_ptr<TransformKeyframe> keyframe) { |
+ InsertKeyframe(keyframe.Pass(), keyframes_); |
} |
-double KeyframedTransformAnimationCurve::duration() const |
-{ |
- return m_keyframes.back()->time() - m_keyframes.front()->time(); |
+double KeyframedTransformAnimationCurve::Duration() const { |
+ return keyframes_.back()->Time() - keyframes_.front()->Time(); |
} |
-scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const |
-{ |
- scoped_ptr<KeyframedTransformAnimationCurve> toReturn(KeyframedTransformAnimationCurve::create()); |
- for (size_t i = 0; i < m_keyframes.size(); ++i) |
- toReturn->addKeyframe(m_keyframes[i]->clone()); |
- return toReturn.PassAs<AnimationCurve>(); |
+scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::Clone() const { |
+ scoped_ptr<KeyframedTransformAnimationCurve> to_return( |
+ KeyframedTransformAnimationCurve::Create()); |
+ for (size_t i = 0; i < keyframes_.size(); ++i) |
+ to_return->AddKeyframe(keyframes_[i]->Clone()); |
+ return to_return.PassAs<AnimationCurve>(); |
} |
-gfx::Transform KeyframedTransformAnimationCurve::getValue(double t) const |
-{ |
- if (t <= m_keyframes.front()->time()) |
- return m_keyframes.front()->value().Apply(); |
+gfx::Transform KeyframedTransformAnimationCurve::GetValue(double t) const { |
+ if (t <= keyframes_.front()->Time()) |
+ return keyframes_.front()->Value().Apply(); |
- if (t >= m_keyframes.back()->time()) |
- return m_keyframes.back()->value().Apply(); |
+ if (t >= keyframes_.back()->Time()) |
+ return keyframes_.back()->Value().Apply(); |
- size_t i = 0; |
- for (; i < m_keyframes.size() - 1; ++i) { |
- if (t < m_keyframes[i+1]->time()) |
- break; |
- } |
+ size_t i = 0; |
+ for (; i < keyframes_.size() - 1; ++i) { |
+ if (t < keyframes_[i+1]->Time()) |
+ break; |
+ } |
- double progress = (t - m_keyframes[i]->time()) / (m_keyframes[i+1]->time() - m_keyframes[i]->time()); |
+ double progress = (t - keyframes_[i]->Time()) / |
+ (keyframes_[i+1]->Time() - keyframes_[i]->Time()); |
- if (m_keyframes[i]->timingFunction()) |
- progress = m_keyframes[i]->timingFunction()->getValue(progress); |
+ if (keyframes_[i]->timing_function()) |
+ progress = keyframes_[i]->timing_function()->GetValue(progress); |
- return m_keyframes[i+1]->value().Blend(m_keyframes[i]->value(), progress); |
+ return keyframes_[i+1]->Value().Blend(keyframes_[i]->Value(), progress); |
} |
} // namespace cc |