diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp index c9240e31f..36f79818e 100644 --- a/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp +++ b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp @@ -28,14 +28,16 @@ #include "GraphicsLayer.h" #include "LayerChromium.h" +#include "TranslateTransformOperation.h" #include "cc/CCLayerAnimationController.h" +#include "cc/CCLayerImpl.h" using namespace WebCore; namespace { template <class Target> -void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity) +void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity, bool useTimingFunction) { WebCore::KeyframeValueList values(AnimatedPropertyOpacity); if (duration > 0) @@ -45,11 +47,32 @@ void addOpacityTransition(Target& target, double duration, float startOpacity, f RefPtr<Animation> animation = Animation::create(); animation->setDuration(duration); + if (useTimingFunction) + animation->setTimingFunction(LinearTimingFunction::create()); + IntSize boxSize; target.addAnimation(values, boxSize, animation.get(), 0, 0, 0); } +template <class Target> +void addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY) +{ + static int id = 0; + WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform); + + TransformOperations operations; + operations.operations().append(TranslateTransformOperation::create(Length(deltaX, WebCore::Fixed), Length(deltaY, WebCore::Fixed), TransformOperation::TRANSLATE_X)); + values.insert(new TransformAnimationValue(0, &operations)); + + RefPtr<Animation> animation = Animation::create(); + animation->setDuration(duration); + + IntSize boxSize; + + target.addAnimation(values, boxSize, animation.get(), ++id, 0, 0); +} + } // namespace namespace WebKitTests { @@ -106,12 +129,12 @@ float FakeFloatTransition::getValue(double time) const return (1 - time) * m_from + time * m_to; } -FakeLayerAnimationControllerImplClient::FakeLayerAnimationControllerImplClient() +FakeLayerAnimationControllerClient::FakeLayerAnimationControllerClient() : m_opacity(0) { } -FakeLayerAnimationControllerImplClient::~FakeLayerAnimationControllerImplClient() +FakeLayerAnimationControllerClient::~FakeLayerAnimationControllerClient() { } @@ -120,14 +143,34 @@ PassOwnPtr<WebCore::CCAnimationCurve> FakeFloatTransition::clone() const return adoptPtr(new FakeFloatTransition(*this)); } -void addOpacityTransitionToController(WebCore::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity) +void addOpacityTransitionToController(WebCore::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity, bool useTimingFunction) +{ + addOpacityTransition(controller, duration, startOpacity, endOpacity, useTimingFunction); +} + +void addAnimatedTransformToController(WebCore::CCLayerAnimationController& controller, double duration, int deltaX, int deltaY) +{ + addAnimatedTransform(controller, duration, deltaX, deltaY); +} + +void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity, bool useTimingFunction) +{ + addOpacityTransition(layer, duration, startOpacity, endOpacity, useTimingFunction); +} + +void addOpacityTransitionToLayer(WebCore::CCLayerImpl& layer, double duration, float startOpacity, float endOpacity, bool useTimingFunction) +{ + addOpacityTransition(*layer.layerAnimationController(), duration, startOpacity, endOpacity, useTimingFunction); +} + +void addAnimatedTransformToLayer(WebCore::LayerChromium& layer, double duration, int deltaX, int deltaY) { - addOpacityTransition(controller, duration, startOpacity, endOpacity); + addAnimatedTransform(layer, duration, deltaX, deltaY); } -void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity) +void addAnimatedTransformToLayer(WebCore::CCLayerImpl& layer, double duration, int deltaX, int deltaY) { - addOpacityTransition(layer, duration, startOpacity, endOpacity); + addAnimatedTransform(*layer.layerAnimationController(), duration, deltaX, deltaY); } } // namespace WebKitTests |