Title: [147549] trunk/Source/WebCore
Revision
147549
Author
commit-qu...@webkit.org
Date
2013-04-03 06:23:26 -0700 (Wed, 03 Apr 2013)

Log Message

[GTK][AC] Implement matrix keyframe animations with clutter ac backend
https://bugs.webkit.org/show_bug.cgi?id=110314

Patch by ChangSeok Oh <changseok...@collabora.com> on 2013-04-03
Reviewed by Gustavo Noronha Silva.

Clutter 1.12 doesn't support additive transform animations yet, So clutter ac backend
uses matrix animations for the case. This patch follows changeset 143369, 143343
to support matrix keyframe animations. I believe this change is easy if you understand
above two changesets.

Covered by existing animation tests.

* platform/graphics/clutter/PlatformClutterAnimation.cpp:
(WebCore::PlatformClutterAnimation::setValues):
(WebCore::PlatformClutterAnimation::addClutterKeyframeTransitionForProperty):
(WebCore):
(WebCore::PlatformClutterAnimation::addTransformTransition):
* platform/graphics/clutter/PlatformClutterAnimation.h:
(PlatformClutterAnimation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147548 => 147549)


--- trunk/Source/WebCore/ChangeLog	2013-04-03 13:20:29 UTC (rev 147548)
+++ trunk/Source/WebCore/ChangeLog	2013-04-03 13:23:26 UTC (rev 147549)
@@ -1,3 +1,25 @@
+2013-04-03  ChangSeok Oh  <changseok...@collabora.com>
+
+        [GTK][AC] Implement matrix keyframe animations with clutter ac backend
+        https://bugs.webkit.org/show_bug.cgi?id=110314
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Clutter 1.12 doesn't support additive transform animations yet, So clutter ac backend
+        uses matrix animations for the case. This patch follows changeset 143369, 143343
+        to support matrix keyframe animations. I believe this change is easy if you understand
+        above two changesets.
+
+        Covered by existing animation tests.
+
+        * platform/graphics/clutter/PlatformClutterAnimation.cpp:
+        (WebCore::PlatformClutterAnimation::setValues):
+        (WebCore::PlatformClutterAnimation::addClutterKeyframeTransitionForProperty):
+        (WebCore):
+        (WebCore::PlatformClutterAnimation::addTransformTransition):
+        * platform/graphics/clutter/PlatformClutterAnimation.h:
+        (PlatformClutterAnimation):
+
 2013-04-03  Gustavo Noronha Silva  <gustavo.noro...@collabora.com>
 
         Should close select popup when the element loses focus

Modified: trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp (147548 => 147549)


--- trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp	2013-04-03 13:20:29 UTC (rev 147548)
+++ trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp	2013-04-03 13:23:26 UTC (rev 147549)
@@ -368,7 +368,9 @@
 
 void PlatformClutterAnimation::setValues(const Vector<WebCore::TransformationMatrix>& value)
 {
-    notImplemented();
+    ASSERT(animationType() == Keyframe);
+
+    m_valuesMatrix = value;
 }
 
 void PlatformClutterAnimation::setValues(const Vector<FloatPoint3D>& value)
@@ -527,6 +529,43 @@
         g_value_unset(&keyValues.get()[i]);
 }
 
+void PlatformClutterAnimation::addClutterKeyframeTransitionForProperty(const String& property, const Vector<WebCore::TransformationMatrix>& values)
+{
+    ASSERT(property != "NoProperty");
+
+    Vector<CoglMatrix> coglMatrices;
+    for (unsigned i = 0; i < values.size(); ++i)
+        coglMatrices.append(values[i]);
+
+    GRefPtr<ClutterTransition> transition = adoptGRef(clutter_keyframe_transition_new(property.utf8().data()));
+    clutter_transition_set_from(transition.get(), CLUTTER_TYPE_MATRIX, coglMatrices.first());
+    clutter_transition_set_to(transition.get(), CLUTTER_TYPE_MATRIX, coglMatrices.last());
+
+    // Ignore the first keyframe, since it's a '0' frame, meaningless.
+    const unsigned nKeyframes = values.size() - 1;
+    OwnArrayPtr<ClutterAnimationMode> animationModes = adoptArrayPtr(new ClutterAnimationMode[nKeyframes]);
+    OwnArrayPtr<double> keyTimes = adoptArrayPtr(new double[nKeyframes]);
+    GOwnPtr<GValue> keyValues(g_new0(GValue, nKeyframes));
+
+    for (unsigned i = 0; i < nKeyframes; ++i) {
+        keyTimes[i] = static_cast<double>(m_keyTimes[i + 1]);
+        animationModes[i] = toClutterAnimationMode(m_timingFunctions[i]);
+        g_value_init(&keyValues.get()[i], CLUTTER_TYPE_MATRIX);
+        g_value_set_boxed(&keyValues.get()[i], &coglMatrices[i + 1]);
+    }
+
+    clutter_keyframe_transition_set_key_frames(CLUTTER_KEYFRAME_TRANSITION(transition.get()), nKeyframes, keyTimes.get());
+    clutter_keyframe_transition_set_values(CLUTTER_KEYFRAME_TRANSITION(transition.get()), nKeyframes, keyValues.get());
+    clutter_keyframe_transition_set_modes(CLUTTER_KEYFRAME_TRANSITION(transition.get()), nKeyframes, animationModes.get());
+
+    clutter_transition_group_add_transition(CLUTTER_TRANSITION_GROUP(m_animation.get()), transition.get());
+
+    clutter_interval_register_progress_func(CLUTTER_TYPE_MATRIX, clutterMatrixProgress);
+
+    for (unsigned i = 0; i < nKeyframes; ++i)
+        g_value_unset(&keyValues.get()[i]);
+}
+
 void PlatformClutterAnimation::addClutterKeyframeTransitionForProperty(const String& property, const Vector<FloatPoint3D>& values)
 {
     ASSERT(property != "NoProperty");
@@ -605,7 +644,10 @@
             addClutterTransitionForProperty(toClutterActorPropertyString(m_valueFunctionType), m_fromValue3D, m_toValue3D);
         break;
     case Matrix:
-        addClutterTransitionForProperty(toClutterActorPropertyString(m_valueFunctionType), m_fromValueMatrix, m_toValueMatrix);
+        if (isKeyframe)
+            addClutterKeyframeTransitionForProperty(toClutterActorPropertyString(m_valueFunctionType), m_valuesMatrix); 
+        else
+            addClutterTransitionForProperty(toClutterActorPropertyString(m_valueFunctionType), m_fromValueMatrix, m_toValueMatrix);
         break;
     default:
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.h (147548 => 147549)


--- trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.h	2013-04-03 13:20:29 UTC (rev 147548)
+++ trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.h	2013-04-03 13:23:26 UTC (rev 147549)
@@ -144,6 +144,7 @@
     void addClutterTransitionForProperty(const String& property, const FloatPoint3D& fromValue, const FloatPoint3D& toValue);
 
     void addClutterKeyframeTransitionForProperty(const String& property, const Vector<float>& values);
+    void addClutterKeyframeTransitionForProperty(const String& property, const Vector<WebCore::TransformationMatrix>& values);
     void addClutterKeyframeTransitionForProperty(const String& property, const Vector<FloatPoint3D>& values);
 
     void addOpacityTransition();
@@ -176,6 +177,7 @@
 
     Vector<float> m_values;
     Vector<FloatPoint3D> m_values3D;
+    Vector<WebCore::TransformationMatrix> m_valuesMatrix;
 };
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to