summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rwxr-xr-xSource/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp109
1 files changed, 21 insertions, 88 deletions
diff --git a/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp b/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp
index 2bf0f1f..aca2322 100755
--- a/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp
+++ b/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp
@@ -48,109 +48,42 @@ using namespace std;
namespace WebCore {
-// Copied from AnimationBase.cpp
-static inline double solveEpsilon(double duration)
-{
- return 1.0 / (200.0 * duration);
-}
-
-static inline double solveCubicBezier(ClutterAlpha* alpha, double x1, double y1, double x2, double y2)
-{
- ClutterTimeline* timeline = clutter_alpha_get_timeline(alpha);
- double duration = clutter_timeline_get_duration(timeline);
- double progress = clutter_timeline_get_progress(timeline);
-
- UnitBezier bezier(x1, y1, x2, y2);
- return bezier.solve(progress, solveEpsilon(duration));
-}
-
-static double easeInCubicBezierFunction(ClutterAlpha* alpha, gpointer data)
-{
- return solveCubicBezier(alpha, 0.42, 0.0, 1.0, 1.0);
-}
-
-static double easeOutCubicBezierFunction(ClutterAlpha* alpha, gpointer data)
-{
- return solveCubicBezier(alpha, 0.0, 0.0, 0.58, 1.0);
-}
-
-static double easeInOutCubicBezierFunction(ClutterAlpha* alpha, gpointer data)
+static void timelineStartedCallback(ClutterTimeline*, PlatformClutterAnimation* animation)
{
- return solveCubicBezier(alpha, 0.42, 0.0, 0.58, 1.0);
+ animation->animationDidStart();
}
-static double easeCubicBezierFunction(ClutterAlpha* alpha, gpointer data)
+static String toClutterActorPropertyString(const PlatformClutterAnimation::ValueFunctionType valueFunctionType)
{
- return solveCubicBezier(alpha, 0.25, 0.1, 0.25, 1.0);
-}
-
-static ClutterAnimationMode easeInCubicBezierMode = CLUTTER_CUSTOM_MODE;
-static ClutterAnimationMode easeOutCubicBezierMode = CLUTTER_CUSTOM_MODE;
-static ClutterAnimationMode easeInOutCubicBezierMode = CLUTTER_CUSTOM_MODE;
-static ClutterAnimationMode easeCubicBezierMode = CLUTTER_CUSTOM_MODE;
-
-static bool areNear(double x, double y) {
- return fabs(x - y) < 0.0001;
+ // ClutterActor doesn't have 'scale' and 'translate' properties. So we should support
+ // 'scale' and 'translate' ValueFunctionType by combination of existing property animations.
+ const char* clutterActorProperty[] = { "NoProperty", "rotation-angle-x", "rotation-angle-y", "rotation-angle-z", "scale-x", "scale-y", "scale-z", "scale", "translation-x", "translation-y", "translation-z", "translate", "transform" };
+ return clutterActorProperty[valueFunctionType];
}
-// FIXME: we don't support more complex cubic bezier values.
static ClutterAnimationMode toClutterAnimationMode(const TimingFunction* timingFunction)
{
- if (!timingFunction)
- return CLUTTER_EASE_IN_OUT_CUBIC;
-
- if (timingFunction->isStepsTimingFunction())
- ASSERT_NOT_REACHED();
+ ASSERT(timingFunction);
if (timingFunction->isLinearTimingFunction())
return CLUTTER_LINEAR;
-
if (timingFunction->isCubicBezierTimingFunction()) {
- const CubicBezierTimingFunction* function = static_cast<const CubicBezierTimingFunction*>(timingFunction);
-
- if (areNear(function->x1(), 0.42) && areNear(function->y1(), 0.0) && areNear(function->x2(), 1.0) && areNear(function->y2(), 1.0)) {
- if (!easeInCubicBezierMode)
- easeInCubicBezierMode = static_cast<ClutterAnimationMode>(clutter_alpha_register_func(easeInCubicBezierFunction, 0));
-
- return easeInCubicBezierMode;
- } else if (areNear(function->x1(), 0.0) && areNear(function->y1(), 0.0) && areNear(function->x2(), 0.58) && areNear(function->y2(), 1.0)) {
- if (!easeOutCubicBezierMode)
- easeOutCubicBezierMode = static_cast<ClutterAnimationMode>(clutter_alpha_register_func(easeOutCubicBezierFunction, 0));
-
- return easeOutCubicBezierMode;
- } else if (areNear(function->x1(), 0.42) && areNear(function->y1(), 0.0) && areNear(function->x2(), 0.58) && areNear(function->y2(), 1.0)) {
- if (!easeInOutCubicBezierMode)
- easeInOutCubicBezierMode = static_cast<ClutterAnimationMode>(clutter_alpha_register_func(easeInOutCubicBezierFunction, 0));
-
- return easeInOutCubicBezierMode;
+ CubicBezierTimingFunction::TimingFunctionPreset timingFunctionPreset = static_cast<const CubicBezierTimingFunction*>(timingFunction)->timingFunctionPreset();
+ switch (timingFunctionPreset) {
+ case CubicBezierTimingFunction::Ease:
+ return CLUTTER_EASE;
+ case CubicBezierTimingFunction::EaseIn:
+ return CLUTTER_EASE_IN;
+ case CubicBezierTimingFunction::EaseOut:
+ return CLUTTER_EASE_OUT;
+ case CubicBezierTimingFunction::EaseInOut:
+ return CLUTTER_EASE_IN_OUT;
+ default:
+ ASSERT_NOT_REACHED();
}
-
- return CLUTTER_EASE_IN_OUT_CUBIC;
-
- LOG(AcceleratedAnimation, "Unknown cubic bezier function, falling back to ease (%f,%f,%f,%f)",
- function->x1(), function->y1(), function->x2(), function->y2());
-
- if (!easeCubicBezierMode)
- easeCubicBezierMode = static_cast<ClutterAnimationMode>(clutter_alpha_register_func(easeCubicBezierFunction, 0));
-
- return easeCubicBezierMode;
}
- LOG(AcceleratedAnimation, "No timing function");
- return CLUTTER_EASE_IN_OUT_CUBIC;
-}
-
-static void timelineStartedCallback(ClutterTimeline*, PlatformClutterAnimation* animation)
-{
- animation->animationDidStart();
-}
-
-static String toClutterActorPropertyString(const PlatformClutterAnimation::ValueFunctionType valueFunctionType)
-{
- // ClutterActor doesn't have 'scale' and 'translate' properties. So we should support
- // 'scale' and 'translate' ValueFunctionType by combination of existing property animations.
- const char* clutterActorProperty[] = { "NoProperty", "rotation-angle-x", "rotation-angle-y", "rotation-angle-z", "scale-x", "scale-y", "scale-z", "scale", "translation-x", "translation-y", "translation-z", "translate" };
- return clutterActorProperty[valueFunctionType];
+ return CLUTTER_EASE;
}
PlatformClutterAnimation::AnimatedPropertyType PlatformClutterAnimation::stringToAnimatedPropertyType(const String& keyPath) const