Changeset 143369 in webkit


Ignore:
Timestamp:
Feb 19, 2013 12:10:11 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK][AC] Implement matrix transform animation with clutter ac backend
https://bugs.webkit.org/show_bug.cgi?id=109848

Patch by ChangSeok Oh <ChangSeok Oh> on 2013-02-19
Reviewed by Gustavo Noronha Silva.

Clutter 1.12 doesn't support additive transform animations yet, so the combination
of two or more transformations(such as rotation after translation) runs unexpectedly.
So we use a matrix transformation instead for the case.

Covered by existing animation tests.

  • platform/graphics/clutter/GraphicsLayerClutter.cpp:

(WebCore::getValueFunctionNameForTransformOperation):
(WebCore::GraphicsLayerClutter::createTransformAnimationsFromKeyframes):

  • platform/graphics/clutter/PlatformClutterAnimation.cpp:

(WebCore::toClutterActorPropertyString): Add actor property "transform"
(WebCore::clutterMatrixProgress): Handle interpolation between two matrices instead of default clutter_matrix_progress.
(WebCore):
(WebCore::PlatformClutterAnimation::supportsAdditiveValueFunction):
(WebCore::PlatformClutterAnimation::setFromValue): for TransformationMatrix.
(WebCore::PlatformClutterAnimation::setToValue): ditto.
(WebCore::PlatformClutterAnimation::addClutterTransitionForProperty):
(WebCore::PlatformClutterAnimation::addTransformTransition):

  • platform/graphics/clutter/PlatformClutterAnimation.h:

(PlatformClutterAnimation):

  • platform/graphics/clutter/TransformationMatrixClutter.cpp: Add copy constructor for CoglMatrix.

(WebCore::TransformationMatrix::TransformationMatrix):
(WebCore):

  • platform/graphics/transforms/TransformationMatrix.h:

(TransformationMatrix):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143363 r143369  
     12013-02-19  ChangSeok Oh  <changseok.oh@collabora.com>
     2
     3        [GTK][AC] Implement matrix transform animation with clutter ac backend
     4        https://bugs.webkit.org/show_bug.cgi?id=109848
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Clutter 1.12 doesn't support additive transform animations yet, so the combination
     9        of two or more transformations(such as rotation after translation) runs unexpectedly.
     10        So we use a matrix transformation instead for the case.
     11
     12        Covered by existing animation tests.
     13
     14        * platform/graphics/clutter/GraphicsLayerClutter.cpp:
     15        (WebCore::getValueFunctionNameForTransformOperation):
     16        (WebCore::GraphicsLayerClutter::createTransformAnimationsFromKeyframes):
     17        * platform/graphics/clutter/PlatformClutterAnimation.cpp:
     18        (WebCore::toClutterActorPropertyString): Add actor property "transform"
     19        (WebCore::clutterMatrixProgress): Handle interpolation between two matrices instead of default clutter_matrix_progress.
     20        (WebCore):
     21        (WebCore::PlatformClutterAnimation::supportsAdditiveValueFunction):
     22        (WebCore::PlatformClutterAnimation::setFromValue): for TransformationMatrix.
     23        (WebCore::PlatformClutterAnimation::setToValue): ditto.
     24        (WebCore::PlatformClutterAnimation::addClutterTransitionForProperty):
     25        (WebCore::PlatformClutterAnimation::addTransformTransition):
     26        * platform/graphics/clutter/PlatformClutterAnimation.h:
     27        (PlatformClutterAnimation):
     28        * platform/graphics/clutter/TransformationMatrixClutter.cpp: Add copy constructor for CoglMatrix.
     29        (WebCore::TransformationMatrix::TransformationMatrix):
     30        (WebCore):
     31        * platform/graphics/transforms/TransformationMatrix.h:
     32        (TransformationMatrix):
     33
    1342013-02-19  Kassy Coan  <kassycoan@chromium.org>
    235
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp

    r143343 r143369  
    191191    case TransformOperation::TRANSLATE_3D:
    192192        return PlatformClutterAnimation::Translate;
     193    case TransformOperation::MATRIX_3D:
     194        return PlatformClutterAnimation::Matrix;
    193195    default:
    194196        return PlatformClutterAnimation::NoValueFunction;
     
    926928    // Also, we can't do component animation unless we have valueFunction, so we need to do matrix animation
    927929    // if that's not true as well.
    928     bool isMatrixAnimation = listIndex < 0 || !PlatformClutterAnimation::supportsValueFunction();
     930    bool isMatrixAnimation = listIndex < 0 || !PlatformClutterAnimation::supportsValueFunction() || (operations->size() >= 2 && !PlatformClutterAnimation::supportsAdditiveValueFunction());
    929931    int numAnimations = isMatrixAnimation ? 1 : operations->size();
    930932
  • trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.cpp

    r143343 r143369  
    5757    // ClutterActor doesn't have 'scale' and 'translate' properties. So we should support
    5858    // 'scale' and 'translate' ValueFunctionType by combination of existing property animations.
    59     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" };
     59    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" };
    6060    return clutterActorProperty[valueFunctionType];
    6161}
     
    8686}
    8787
     88static gboolean clutterMatrixProgress(const GValue* fromValue, const GValue* toValue, gdouble progress, GValue* returnValue)
     89{
     90    const CoglMatrix* fromCoglMatrix = static_cast<CoglMatrix*>(g_value_get_boxed(fromValue));
     91    const CoglMatrix* toCoglMatrix = static_cast<CoglMatrix*>(g_value_get_boxed(toValue));
     92
     93    ASSERT(fromCoglMatrix && toCoglMatrix);
     94
     95    TransformationMatrix fromMatrix(fromCoglMatrix);
     96    TransformationMatrix toMatrix(toCoglMatrix);
     97    toMatrix.blend(fromMatrix, progress);
     98
     99    CoglMatrix resultCoglMatrix = toMatrix;
     100    g_value_set_boxed(returnValue, &resultCoglMatrix);
     101
     102    return true;
     103}
     104
    88105PlatformClutterAnimation::AnimatedPropertyType PlatformClutterAnimation::stringToAnimatedPropertyType(const String& keyPath) const
    89106{
     
    136153}
    137154
     155bool PlatformClutterAnimation::supportsAdditiveValueFunction()
     156{
     157    // FIXME: Clutter 1.12 doesn't support additive valueFunction type animations.
     158    // So, we use matrix animation instead until clutter supports it.
     159    return false;
     160}
     161
    138162double PlatformClutterAnimation::beginTime() const
    139163{
     
    278302void PlatformClutterAnimation::setFromValue(const WebCore::TransformationMatrix& value)
    279303{
    280     notImplemented();
     304    if (animationType() != Basic || m_fromValueMatrix == value)
     305        return;
     306
     307    m_fromValueMatrix = value;
    281308}
    282309
     
    309336void PlatformClutterAnimation::setToValue(const WebCore::TransformationMatrix& value)
    310337{
    311     notImplemented();
     338    if (animationType() != Basic || m_toValueMatrix == value)
     339        return;
     340
     341    m_toValueMatrix = value;
    312342}
    313343
     
    413443
    414444    clutter_transition_group_add_transition(CLUTTER_TRANSITION_GROUP(m_animation.get()), transition.get());
     445}
     446
     447void PlatformClutterAnimation::addClutterTransitionForProperty(const String& property, const WebCore::TransformationMatrix& fromValue, const WebCore::TransformationMatrix& toValue)
     448{
     449    ASSERT(property != "NoProperty");
     450
     451    const CoglMatrix fromCoglMatrix = fromValue;
     452    const CoglMatrix toCoglMatrix = toValue;
     453
     454    GRefPtr<ClutterTransition> transition = adoptGRef(clutter_property_transition_new(property.utf8().data()));
     455    clutter_transition_set_from(transition.get(), CLUTTER_TYPE_MATRIX, &fromCoglMatrix);
     456    clutter_transition_set_to(transition.get(), CLUTTER_TYPE_MATRIX, &toCoglMatrix);
     457
     458    clutter_timeline_set_progress_mode(timeline(), toClutterAnimationMode(m_timingFunction));
     459
     460    clutter_transition_group_add_transition(CLUTTER_TRANSITION_GROUP(m_animation.get()), transition.get());
     461
     462    // FIXME: The matrix interpolation api, clutter_matrix_progress of Clutter 1.12 works unexpectedly.
     463    // So we overwrite it and handle the interpolation of two matrices with TransformationMatrix.
     464    // See https://bugzilla.gnome.org/show_bug.cgi?id=694197
     465    clutter_interval_register_progress_func(CLUTTER_TYPE_MATRIX, clutterMatrixProgress);
    415466}
    416467
     
    546597            addClutterTransitionForProperty(toClutterActorPropertyString(m_valueFunctionType), m_fromValue3D, m_toValue3D);
    547598        break;
     599    case Matrix:
     600        addClutterTransitionForProperty(toClutterActorPropertyString(m_valueFunctionType), m_fromValueMatrix, m_toValueMatrix);
     601        break;
    548602    default:
    549603        ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.h

    r143343 r143369  
    5656    enum AnimatedPropertyType { NoAnimatedPropertyType, Transform, Opacity, BackgroundColor };
    5757    enum FillModeType { NoFillMode, Forwards, Backwards, Both };
    58     enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX, ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate };
     58    enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX, ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate, Matrix };
    5959
    6060    static PassRefPtr<PlatformClutterAnimation> create(AnimationType, const String& keyPath);
     
    6464
    6565    static bool supportsValueFunction();
     66    static bool supportsAdditiveValueFunction();
    6667
    6768    AnimationType animationType() const { return m_type; }
     
    140141
    141142    void addClutterTransitionForProperty(const String& property, const float fromValue, const float toValue);
     143    void addClutterTransitionForProperty(const String& property, const WebCore::TransformationMatrix&, const WebCore::TransformationMatrix&);
    142144    void addClutterTransitionForProperty(const String& property, const FloatPoint3D& fromValue, const FloatPoint3D& toValue);
    143145
     
    162164    FloatPoint3D m_toValue3D;
    163165
     166    WebCore::TransformationMatrix m_fromValueMatrix;
     167    WebCore::TransformationMatrix m_toValueMatrix;
     168
    164169    float m_repeatCount;
    165170
  • trunk/Source/WebCore/platform/graphics/clutter/TransformationMatrixClutter.cpp

    r129387 r143369  
    5252}
    5353
     54TransformationMatrix::TransformationMatrix(const CoglMatrix* matrix)
     55{
     56    setMatrix(matrix->xx, matrix->yx, matrix->zx, matrix->wx,
     57        matrix->xy, matrix->yy, matrix->zy, matrix->wy,
     58        matrix->xz, matrix->yz, matrix->zz, matrix->wz,
     59        matrix->xw, matrix->yw, matrix->zw, matrix->ww);
    5460}
     61
     62}
  • trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h

    r140455 r143369  
    342342#endif
    343343#if USE(CLUTTER)
     344    TransformationMatrix(const CoglMatrix*);
    344345    operator CoglMatrix() const;
    345346#endif
Note: See TracChangeset for help on using the changeset viewer.