| Index: cc/test/animation_test_common.cc
|
| diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc
|
| index 99435e878993f7844a3b778511eee4b2feb472d3..47f4ca73cc853f563a0125ba64d7143049dfa01f 100644
|
| --- a/cc/test/animation_test_common.cc
|
| +++ b/cc/test/animation_test_common.cc
|
| @@ -24,185 +24,227 @@ namespace cc {
|
| static int nextAnimationId = 0;
|
|
|
| template <class Target>
|
| -int addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
|
| -{
|
| - scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve::Create());
|
| -
|
| - scoped_ptr<TimingFunction> func;
|
| - if (!useTimingFunction)
|
| - func = EaseTimingFunction::create();
|
| - if (duration > 0)
|
| - curve->AddKeyframe(FloatKeyframe::Create(0, startOpacity, func.Pass()));
|
| - curve->AddKeyframe(FloatKeyframe::Create(duration, endOpacity, scoped_ptr<cc::TimingFunction>()));
|
| -
|
| - int id = nextAnimationId++;
|
| -
|
| - scoped_ptr<Animation> animation(Animation::Create(curve.PassAs<AnimationCurve>(), id, 0, Animation::Opacity));
|
| - animation->set_needs_synchronized_start_time(true);
|
| -
|
| - target.AddAnimation(animation.Pass());
|
| - return id;
|
| +int AddOpacityTransition(Target* target,
|
| + double duration,
|
| + float startOpacity,
|
| + float endOpacity,
|
| + bool useTimingFunction) {
|
| + scoped_ptr<KeyframedFloatAnimationCurve>
|
| + curve(KeyframedFloatAnimationCurve::Create());
|
| +
|
| + scoped_ptr<TimingFunction> func;
|
| + if (!useTimingFunction)
|
| + func = EaseTimingFunction::create();
|
| + if (duration > 0.0)
|
| + curve->AddKeyframe(FloatKeyframe::Create(0.0, startOpacity, func.Pass()));
|
| + curve->AddKeyframe(FloatKeyframe::Create(duration,
|
| + endOpacity,
|
| + scoped_ptr<cc::TimingFunction>()));
|
| +
|
| + int id = nextAnimationId++;
|
| +
|
| + scoped_ptr<Animation> animation(Animation::Create(
|
| + curve.PassAs<AnimationCurve>(),
|
| + id,
|
| + 0,
|
| + Animation::Opacity));
|
| + animation->set_needs_synchronized_start_time(true);
|
| +
|
| + target->AddAnimation(animation.Pass());
|
| + return id;
|
| }
|
|
|
| template <class Target>
|
| -int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY)
|
| -{
|
| - scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimationCurve::Create());
|
| -
|
| - if (duration > 0) {
|
| - TransformOperations startOperations;
|
| - startOperations.AppendTranslate(deltaX, deltaY, 0);
|
| - curve->AddKeyframe(TransformKeyframe::Create(0, startOperations, scoped_ptr<cc::TimingFunction>()));
|
| - }
|
| -
|
| - TransformOperations operations;
|
| - operations.AppendTranslate(deltaX, deltaY, 0);
|
| - curve->AddKeyframe(TransformKeyframe::Create(duration, operations, scoped_ptr<cc::TimingFunction>()));
|
| -
|
| - int id = nextAnimationId++;
|
| -
|
| - scoped_ptr<Animation> animation(Animation::Create(curve.PassAs<AnimationCurve>(), id, 0, Animation::Transform));
|
| - animation->set_needs_synchronized_start_time(true);
|
| -
|
| - target.AddAnimation(animation.Pass());
|
| - return id;
|
| +int AddAnimatedTransform(Target* target,
|
| + double duration,
|
| + int deltaX,
|
| + int deltaY) {
|
| + scoped_ptr<KeyframedTransformAnimationCurve>
|
| + curve(KeyframedTransformAnimationCurve::Create());
|
| +
|
| + if (duration > 0.0) {
|
| + TransformOperations startOperations;
|
| + startOperations.AppendTranslate(deltaX, deltaY, 0.0);
|
| + curve->AddKeyframe(TransformKeyframe::Create(
|
| + 0.0,
|
| + startOperations,
|
| + scoped_ptr<cc::TimingFunction>()));
|
| + }
|
| +
|
| + TransformOperations operations;
|
| + operations.AppendTranslate(deltaX, deltaY, 0.0);
|
| + curve->AddKeyframe(TransformKeyframe::Create(
|
| + duration,
|
| + operations,
|
| + scoped_ptr<cc::TimingFunction>()));
|
| +
|
| + int id = nextAnimationId++;
|
| +
|
| + scoped_ptr<Animation> animation(Animation::Create(
|
| + curve.PassAs<AnimationCurve>(),
|
| + id, 0, Animation::Transform));
|
| + animation->set_needs_synchronized_start_time(true);
|
| +
|
| + target->AddAnimation(animation.Pass());
|
| + return id;
|
| }
|
|
|
| FakeFloatAnimationCurve::FakeFloatAnimationCurve()
|
| - : m_duration(1)
|
| + : duration_(1.0)
|
| {
|
| }
|
|
|
| FakeFloatAnimationCurve::FakeFloatAnimationCurve(double duration)
|
| - : m_duration(duration)
|
| + : duration_(duration)
|
| {
|
| }
|
|
|
| -FakeFloatAnimationCurve::~FakeFloatAnimationCurve()
|
| -{
|
| +FakeFloatAnimationCurve::~FakeFloatAnimationCurve() {
|
| }
|
|
|
| -double FakeFloatAnimationCurve::Duration() const
|
| -{
|
| - return m_duration;
|
| +double FakeFloatAnimationCurve::Duration() const {
|
| + return duration_;
|
| }
|
|
|
| -float FakeFloatAnimationCurve::GetValue(double now) const
|
| -{
|
| - return 0;
|
| +float FakeFloatAnimationCurve::GetValue(double now) const {
|
| + return 0.0f;
|
| }
|
|
|
| -scoped_ptr<cc::AnimationCurve> FakeFloatAnimationCurve::Clone() const
|
| -{
|
| - return make_scoped_ptr(new FakeFloatAnimationCurve).PassAs<cc::AnimationCurve>();
|
| +scoped_ptr<cc::AnimationCurve> FakeFloatAnimationCurve::Clone() const {
|
| + return make_scoped_ptr(
|
| + new FakeFloatAnimationCurve).PassAs<cc::AnimationCurve>();
|
| }
|
|
|
| FakeTransformTransition::FakeTransformTransition(double duration)
|
| - : m_duration(duration)
|
| + : duration_(duration)
|
| {
|
| }
|
|
|
| -FakeTransformTransition::~FakeTransformTransition()
|
| -{
|
| +FakeTransformTransition::~FakeTransformTransition() {
|
| }
|
|
|
| -double FakeTransformTransition::Duration() const
|
| -{
|
| - return m_duration;
|
| +double FakeTransformTransition::Duration() const {
|
| + return duration_;
|
| }
|
|
|
| -gfx::Transform FakeTransformTransition::GetValue(double time) const
|
| -{
|
| - return gfx::Transform();
|
| +gfx::Transform FakeTransformTransition::GetValue(double time) const {
|
| + return gfx::Transform();
|
| }
|
|
|
| -scoped_ptr<cc::AnimationCurve> FakeTransformTransition::Clone() const
|
| -{
|
| - return make_scoped_ptr(new FakeTransformTransition(*this)).PassAs<cc::AnimationCurve>();
|
| +scoped_ptr<cc::AnimationCurve> FakeTransformTransition::Clone() const {
|
| + return make_scoped_ptr(
|
| + new FakeTransformTransition(*this)).PassAs<cc::AnimationCurve>();
|
| }
|
|
|
|
|
| FakeFloatTransition::FakeFloatTransition(double duration, float from, float to)
|
| - : m_duration(duration)
|
| - , m_from(from)
|
| - , m_to(to)
|
| + : duration_(duration)
|
| + , from_(from)
|
| + , to_(to)
|
| {
|
| }
|
|
|
| -FakeFloatTransition::~FakeFloatTransition()
|
| -{
|
| +FakeFloatTransition::~FakeFloatTransition() {
|
| }
|
|
|
| -double FakeFloatTransition::Duration() const
|
| -{
|
| - return m_duration;
|
| +double FakeFloatTransition::Duration() const {
|
| + return duration_;
|
| }
|
|
|
| -float FakeFloatTransition::GetValue(double time) const
|
| -{
|
| - time /= m_duration;
|
| - if (time >= 1)
|
| - time = 1;
|
| - return (1 - time) * m_from + time * m_to;
|
| +float FakeFloatTransition::GetValue(double time) const {
|
| + time /= duration_;
|
| + if (time >= 1.0)
|
| + time = 1.0;
|
| + return (1.0 - time) * from_ + time * to_;
|
| }
|
|
|
| FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver()
|
| - : m_opacity(0)
|
| + : opacity_(0.0f)
|
| {
|
| }
|
|
|
| -FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver()
|
| -{
|
| +FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver() {
|
| }
|
|
|
| -void FakeLayerAnimationValueObserver::OnOpacityAnimated(float opacity)
|
| -{
|
| - m_opacity = opacity;
|
| +void FakeLayerAnimationValueObserver::OnOpacityAnimated(float opacity) {
|
| + opacity_ = opacity;
|
| }
|
|
|
| -void FakeLayerAnimationValueObserver::OnTransformAnimated(const gfx::Transform& transform)
|
| -{
|
| - m_transform = transform;
|
| +void FakeLayerAnimationValueObserver::OnTransformAnimated(
|
| + const gfx::Transform& transform) {
|
| + transform_ = transform;
|
| }
|
|
|
| -bool FakeLayerAnimationValueObserver::IsActive() const
|
| -{
|
| - return true;
|
| +bool FakeLayerAnimationValueObserver::IsActive() const {
|
| + return true;
|
| }
|
|
|
| -scoped_ptr<cc::AnimationCurve> FakeFloatTransition::Clone() const
|
| -{
|
| - return make_scoped_ptr(new FakeFloatTransition(*this)).PassAs<cc::AnimationCurve>();
|
| +scoped_ptr<cc::AnimationCurve> FakeFloatTransition::Clone() const {
|
| + return make_scoped_ptr(
|
| + new FakeFloatTransition(*this)).PassAs<cc::AnimationCurve>();
|
| }
|
|
|
| -int addOpacityTransitionToController(cc::LayerAnimationController& controller, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
|
| -{
|
| - return addOpacityTransition(controller, duration, startOpacity, endOpacity, useTimingFunction);
|
| +int AddOpacityTransitionToController(cc::LayerAnimationController* controller,
|
| + double duration,
|
| + float start_opacity,
|
| + float end_opacity,
|
| + bool use_timing_function) {
|
| + return AddOpacityTransition(controller,
|
| + duration,
|
| + start_opacity,
|
| + end_opacity,
|
| + use_timing_function);
|
| }
|
|
|
| -int addAnimatedTransformToController(cc::LayerAnimationController& controller, double duration, int deltaX, int deltaY)
|
| -{
|
| - return addAnimatedTransform(controller, duration, deltaX, deltaY);
|
| +int AddAnimatedTransformToController(cc::LayerAnimationController* controller,
|
| + double duration,
|
| + int delta_x,
|
| + int delta_y) {
|
| + return AddAnimatedTransform(controller,
|
| + duration,
|
| + delta_x,
|
| + delta_y);
|
| }
|
|
|
| -int addOpacityTransitionToLayer(cc::Layer& layer, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
|
| -{
|
| - return addOpacityTransition(layer, duration, startOpacity, endOpacity, useTimingFunction);
|
| +int AddOpacityTransitionToLayer(cc::Layer* layer,
|
| + double duration,
|
| + float start_opacity,
|
| + float end_opacity,
|
| + bool use_timing_function) {
|
| + return AddOpacityTransition(layer,
|
| + duration,
|
| + start_opacity,
|
| + end_opacity,
|
| + use_timing_function);
|
| }
|
|
|
| -int addOpacityTransitionToLayer(cc::LayerImpl& layer, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
|
| -{
|
| - return addOpacityTransition(*layer.layer_animation_controller(), duration, startOpacity, endOpacity, useTimingFunction);
|
| +int AddOpacityTransitionToLayer(cc::LayerImpl* layer,
|
| + double duration,
|
| + float start_opacity,
|
| + float end_opacity,
|
| + bool use_timing_function) {
|
| + return AddOpacityTransition(layer->layer_animation_controller(),
|
| + duration,
|
| + start_opacity,
|
| + end_opacity,
|
| + use_timing_function);
|
| }
|
|
|
| -int addAnimatedTransformToLayer(cc::Layer& layer, double duration, int deltaX, int deltaY)
|
| -{
|
| - return addAnimatedTransform(layer, duration, deltaX, deltaY);
|
| +int AddAnimatedTransformToLayer(cc::Layer* layer,
|
| + double duration,
|
| + int delta_x,
|
| + int delta_y) {
|
| + return AddAnimatedTransform(layer, duration, delta_x, delta_y);
|
| }
|
|
|
| -int addAnimatedTransformToLayer(cc::LayerImpl& layer, double duration, int deltaX, int deltaY)
|
| -{
|
| - return addAnimatedTransform(*layer.layer_animation_controller(), duration, deltaX, deltaY);
|
| +int AddAnimatedTransformToLayer(cc::LayerImpl* layer,
|
| + double duration,
|
| + int delta_x,
|
| + int delta_y) {
|
| + return AddAnimatedTransform(layer->layer_animation_controller(),
|
| + duration,
|
| + delta_x,
|
| + delta_y);
|
| }
|
|
|
| } // namespace cc
|
|
|