Title: [147443] trunk/Source/WebCore
Revision
147443
Author
[email protected]
Date
2013-04-02 10:16:14 -0700 (Tue, 02 Apr 2013)

Log Message

[GTK][AC] Support preserves3D css property for clutter ac backend.
https://bugs.webkit.org/show_bug.cgi?id=113318

Patch by ChangSeok Oh <[email protected]> on 2013-04-02
Reviewed by Gustavo Noronha Silva.

This patch brings preserve-3D css property support to WebKitGtk+ with clutter ac backed.
Most of the code is based on Mac port's implementation. The core concept is that
if a layer has preserve-3d property false, we mark itself and its immediate children
to make them flatten. And then we remove 3D factor in a modelView matrix
when applying it to each actor.

No new tests as this is covered with existing AC tests.

* platform/graphics/clutter/GraphicsLayerActor.cpp:
(_GraphicsLayerActorPrivate):
(graphics_layer_actor_init):
(graphicsLayerActorApplyTransform):
(graphicsLayerActorNew):
(graphicsLayerActorRemoveFromSuperLayer):
(graphicsLayerActorSetDrawsContent):
(graphicsLayerActorSetFlatten):
* platform/graphics/clutter/GraphicsLayerActor.h:
* platform/graphics/clutter/GraphicsLayerClutter.cpp:
(WebCore::GraphicsLayerClutter::~GraphicsLayerClutter):
(WebCore::GraphicsLayerClutter::platformLayer):
(WebCore::GraphicsLayerClutter::moveOrCopyAnimations):
(WebCore):
(WebCore::GraphicsLayerClutter::setPreserves3D):
(WebCore::GraphicsLayerClutter::flushCompositingState):
(WebCore::GraphicsLayerClutter::recursiveCommitChanges):
(WebCore::GraphicsLayerClutter::commitLayerChangesAfterSublayers):
(WebCore::GraphicsLayerClutter::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerClutter::updateGeometry):
(WebCore::GraphicsLayerClutter::updateSublayerList):
(WebCore::GraphicsLayerClutter::updateStructuralLayer):
(WebCore::GraphicsLayerClutter::ensureStructuralLayer):
(WebCore::GraphicsLayerClutter::structuralLayerPurpose):
(WebCore::GraphicsLayerClutter::layerForSuperlayer):
* platform/graphics/clutter/GraphicsLayerClutter.h:
(CommitState):
(WebCore::GraphicsLayerClutter::CommitState::CommitState):
(GraphicsLayerClutter):
(WebCore::GraphicsLayerClutter::primaryLayer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147442 => 147443)


--- trunk/Source/WebCore/ChangeLog	2013-04-02 17:10:51 UTC (rev 147442)
+++ trunk/Source/WebCore/ChangeLog	2013-04-02 17:16:14 UTC (rev 147443)
@@ -1,3 +1,49 @@
+2013-04-02  ChangSeok Oh  <[email protected]>
+
+        [GTK][AC] Support preserves3D css property for clutter ac backend.
+        https://bugs.webkit.org/show_bug.cgi?id=113318
+
+        Reviewed by Gustavo Noronha Silva.
+
+        This patch brings preserve-3D css property support to WebKitGtk+ with clutter ac backed.
+        Most of the code is based on Mac port's implementation. The core concept is that
+        if a layer has preserve-3d property false, we mark itself and its immediate children
+        to make them flatten. And then we remove 3D factor in a modelView matrix
+        when applying it to each actor.
+
+        No new tests as this is covered with existing AC tests.
+
+        * platform/graphics/clutter/GraphicsLayerActor.cpp:
+        (_GraphicsLayerActorPrivate):
+        (graphics_layer_actor_init):
+        (graphicsLayerActorApplyTransform):
+        (graphicsLayerActorNew):
+        (graphicsLayerActorRemoveFromSuperLayer):
+        (graphicsLayerActorSetDrawsContent):
+        (graphicsLayerActorSetFlatten):
+        * platform/graphics/clutter/GraphicsLayerActor.h:
+        * platform/graphics/clutter/GraphicsLayerClutter.cpp:
+        (WebCore::GraphicsLayerClutter::~GraphicsLayerClutter):
+        (WebCore::GraphicsLayerClutter::platformLayer):
+        (WebCore::GraphicsLayerClutter::moveOrCopyAnimations):
+        (WebCore):
+        (WebCore::GraphicsLayerClutter::setPreserves3D):
+        (WebCore::GraphicsLayerClutter::flushCompositingState):
+        (WebCore::GraphicsLayerClutter::recursiveCommitChanges):
+        (WebCore::GraphicsLayerClutter::commitLayerChangesAfterSublayers):
+        (WebCore::GraphicsLayerClutter::commitLayerChangesBeforeSublayers):
+        (WebCore::GraphicsLayerClutter::updateGeometry):
+        (WebCore::GraphicsLayerClutter::updateSublayerList):
+        (WebCore::GraphicsLayerClutter::updateStructuralLayer):
+        (WebCore::GraphicsLayerClutter::ensureStructuralLayer):
+        (WebCore::GraphicsLayerClutter::structuralLayerPurpose):
+        (WebCore::GraphicsLayerClutter::layerForSuperlayer):
+        * platform/graphics/clutter/GraphicsLayerClutter.h:
+        (CommitState):
+        (WebCore::GraphicsLayerClutter::CommitState::CommitState):
+        (GraphicsLayerClutter):
+        (WebCore::GraphicsLayerClutter::primaryLayer):
+
 2013-04-02  Adam Klein  <[email protected]>
 
         HTML parser should consistently inspect the namespace of elements on the stack of open elements

Modified: trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.cpp (147442 => 147443)


--- trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.cpp	2013-04-02 17:10:51 UTC (rev 147442)
+++ trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.cpp	2013-04-02 17:16:14 UTC (rev 147443)
@@ -28,6 +28,7 @@
 #include "PlatformClutterLayerClient.h"
 #include "PlatformContextCairo.h"
 #include "RefPtrCairo.h"
+#include "TransformationMatrix.h"
 #include <wtf/text/CString.h>
 
 using namespace WebCore;
@@ -44,7 +45,8 @@
 
     PlatformClutterLayerClient* layerClient;
 
-    gboolean drawsContent;
+    bool flatten;
+    bool drawsContent;
 
     float scrollX;
     float scrollY;
@@ -102,6 +104,8 @@
 
     clutter_actor_set_reactive(CLUTTER_ACTOR(self), FALSE);
 
+    self->priv->flatten = true;
+
     // Default used by GraphicsLayer.
     graphicsLayerActorSetAnchorPoint(self, 0.5, 0.5, 0.0);
 
@@ -202,7 +206,12 @@
     if (translateX || translateY)
         cogl_matrix_translate(matrix, translateX, translateY, 0);
 
-    CLUTTER_ACTOR_CLASS(graphics_layer_actor_parent_class)->apply_transform(actor, matrix);
+    CoglMatrix modelViewTransform = TransformationMatrix();
+    CLUTTER_ACTOR_CLASS(graphics_layer_actor_parent_class)->apply_transform(actor, &modelViewTransform);
+
+    if (priv->flatten)
+        modelViewTransform = TransformationMatrix(&modelViewTransform).to2dTransform();
+    cogl_matrix_multiply(matrix, matrix, &modelViewTransform);
 }
 
 static void graphicsLayerActorPaint(ClutterActor* actor)
@@ -299,8 +308,12 @@
 GraphicsLayerActor* graphicsLayerActorNew(GraphicsLayerClutter::LayerType type)
 {
     GraphicsLayerActor* layer = GRAPHICS_LAYER_ACTOR(g_object_new(GRAPHICS_LAYER_TYPE_ACTOR, 0));
-    layer->priv->layerType = type;
+    GraphicsLayerActorPrivate* priv = layer->priv;
 
+    priv->layerType = type;
+    if (priv->layerType == GraphicsLayerClutter::LayerTypeTransformLayer)
+        priv->flatten = false;
+
     return layer;
 }
 
@@ -436,6 +449,16 @@
     }
 }
 
+void graphicsLayerActorRemoveFromSuperLayer(GraphicsLayerActor* layer)
+{
+    ClutterActor* actor = CLUTTER_ACTOR(layer);
+    ClutterActor* parentActor = clutter_actor_get_parent(actor);
+    if (!parentActor)
+        return;
+
+    clutter_actor_remove_child(parentActor, actor);
+}
+
 GraphicsLayerClutter::LayerType graphicsLayerActorGetLayerType(GraphicsLayerActor* layer)
 {
     GraphicsLayerActorPrivate* priv = layer->priv;
@@ -474,7 +497,7 @@
     return priv->translateY;
 }
 
-void graphicsLayerActorSetDrawsContent(GraphicsLayerActor* layer, gboolean drawsContent)
+void graphicsLayerActorSetDrawsContent(GraphicsLayerActor* layer, bool drawsContent)
 {
     GraphicsLayerActorPrivate* priv = layer->priv;
 
@@ -491,6 +514,15 @@
     return layer->priv->drawsContent;
 }
 
+void graphicsLayerActorSetFlatten(GraphicsLayerActor* layer, bool flatten)
+{
+    GraphicsLayerActorPrivate* priv = layer->priv;
+    if (flatten == priv->flatten)
+        return;
+
+    priv->flatten = flatten;
+}
+
 WebCore::PlatformClutterAnimation* graphicsLayerActorGetAnimationForKey(GraphicsLayerActor* layer, const String key)
 {
     return static_cast<WebCore::PlatformClutterAnimation*>(g_object_get_data(G_OBJECT(layer), key.utf8().data()));

Modified: trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.h (147442 => 147443)


--- trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.h	2013-04-02 17:10:51 UTC (rev 147442)
+++ trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.h	2013-04-02 17:16:14 UTC (rev 147443)
@@ -89,11 +89,14 @@
 void graphicsLayerActorSetTranslateY(GraphicsLayerActor*, float);
 float graphicsLayerActorGetTranslateY(GraphicsLayerActor*);
 gint graphicsLayerActorGetnChildren(GraphicsLayerActor*);
+void graphicsLayerActorRemoveFromSuperLayer(GraphicsLayerActor*);
 WebCore::GraphicsLayerClutter::LayerType graphicsLayerActorGetLayerType(GraphicsLayerActor*);
 void graphicsLayerActorSetLayerType(GraphicsLayerActor*, WebCore::GraphicsLayerClutter::LayerType);
+void graphicsLayerActorReplaceSublayer(GraphicsLayerActor*, ClutterActor*, ClutterActor*);
 void graphicsLayerActorSetSublayers(GraphicsLayerActor*, WebCore::GraphicsLayerActorList&);
 gboolean graphicsLayerActorGetDrawsContent(GraphicsLayerActor*);
-void graphicsLayerActorSetDrawsContent(GraphicsLayerActor*, gboolean drawsContent);
+void graphicsLayerActorSetDrawsContent(GraphicsLayerActor*, bool drawsContent);
+void graphicsLayerActorSetFlatten(GraphicsLayerActor*, bool flatten);
 
 WebCore::PlatformClutterAnimation* graphicsLayerActorGetAnimationForKey(GraphicsLayerActor*, const String);
 

Modified: trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp (147442 => 147443)


--- trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp	2013-04-02 17:10:51 UTC (rev 147442)
+++ trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp	2013-04-02 17:16:14 UTC (rev 147443)
@@ -40,6 +40,7 @@
 #include "RotateTransformOperation.h"
 #include "ScaleTransformOperation.h"
 #include "TransformState.h"
+#include "TransformationMatrix.h"
 #include "TranslateTransformOperation.h"
 #include <limits.h>
 #include <wtf/text/CString.h>
@@ -297,6 +298,11 @@
         graphicsLayerActorSetClient(m_layer.get(), 0);
         g_idle_add(idleDestroy, m_layer.leakRef());
     }
+
+    if (m_structuralLayer) {
+        graphicsLayerActorSetClient(m_structuralLayer.get(), 0);
+        g_idle_add(idleDestroy, m_structuralLayer.leakRef());
+    }
 }
 
 void GraphicsLayerClutter::setName(const String& name)
@@ -308,7 +314,7 @@
 
 ClutterActor* GraphicsLayerClutter::platformLayer() const
 {
-    return CLUTTER_ACTOR(m_layer.get());
+    return CLUTTER_ACTOR(primaryLayer());
 }
 
 void GraphicsLayerClutter::setNeedsDisplay()
@@ -388,6 +394,20 @@
     noteLayerPropertyChanged(TransformChanged);
 }
 
+void GraphicsLayerClutter::moveOrCopyAnimations(MoveOrCopy operation, GraphicsLayerActor* fromLayer, GraphicsLayerActor* toLayer)
+{
+    notImplemented();
+}
+
+void GraphicsLayerClutter::setPreserves3D(bool preserves3D)
+{
+    if (preserves3D == m_preserves3D)
+        return;
+
+    GraphicsLayer::setPreserves3D(preserves3D);
+    noteLayerPropertyChanged(Preserves3DChanged);
+}
+
 void GraphicsLayerClutter::setDrawsContent(bool drawsContent)
 {
     if (drawsContent == m_drawsContent)
@@ -554,14 +574,11 @@
 void GraphicsLayerClutter::flushCompositingState(const FloatRect& clipRect)
 {
     TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(clipRect));
-    recursiveCommitChanges(state);
+    recursiveCommitChanges(CommitState(), state);
 }
 
-void GraphicsLayerClutter::recursiveCommitChanges(const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)
+void GraphicsLayerClutter::recursiveCommitChanges(const CommitState& commitState, const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)
 {
-    // FIXME: Save the state before sending down to kids and restore it after
-    TransformState localState = state;
-
     if (appliesPageScale()) {
         pageScaleFactor = this->pageScaleFactor();
         affectedByPageScale = true;
@@ -579,7 +596,7 @@
 
     for (size_t i = 0; i < numChildren; ++i) {
         GraphicsLayerClutter* currentChild = static_cast<GraphicsLayerClutter*>(childLayers[i]);
-        currentChild->recursiveCommitChanges(localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
+        currentChild->recursiveCommitChanges(commitState, state, pageScaleFactor, baseRelativePosition, affectedByPageScale);
     }
 
     commitLayerChangesAfterSublayers();
@@ -598,6 +615,9 @@
     if (!m_uncommittedChanges)
         return;
 
+    if (m_uncommittedChanges & ChildrenChanged)
+        updateSublayerList();
+
     m_uncommittedChanges = NoChange;
 }
 void GraphicsLayerClutter::noteSublayersChanged()
@@ -618,34 +638,47 @@
     if (!m_uncommittedChanges)
         return;
 
-    if (m_uncommittedChanges & NameChanged)
-        updateLayerNames();
+    // Need to handle Preserves3DChanged first, because it affects which layers subsequent properties are applied to
+    if (m_uncommittedChanges & Preserves3DChanged)
+        updateStructuralLayer();
 
-    if (m_uncommittedChanges & ChildrenChanged)
-        updateSublayerList();
-
     if (m_uncommittedChanges & GeometryChanged)
         updateGeometry(pageScaleFactor, positionRelativeToBase);
 
-    if (m_uncommittedChanges & TransformChanged)
-        updateTransform();
-
     if (m_uncommittedChanges & DrawsContentChanged)
         updateLayerDrawsContent(pageScaleFactor, positionRelativeToBase);
 
-    if (m_uncommittedChanges & DirtyRectsChanged)
-        repaintLayerDirtyRects();
+    if (m_uncommittedChanges & NameChanged)
+        updateLayerNames();
 
+    if (m_uncommittedChanges & TransformChanged)
+        updateTransform();
+
     if (m_uncommittedChanges & OpacityChanged)
         updateOpacityOnLayer();
 
     if (m_uncommittedChanges & AnimationChanged)
         updateAnimations();
+
+    if (m_uncommittedChanges & DirtyRectsChanged)
+        repaintLayerDirtyRects();
+
+    if (m_uncommittedChanges & ChildrenChanged) {
+        updateSublayerList();
+        // Sublayers may set this flag again, so clear it to avoid always updating sublayers in commitLayerChangesAfterSublayers().
+        m_uncommittedChanges &= ~ChildrenChanged;
+    }
 }
 
 void GraphicsLayerClutter::updateGeometry(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
 {
     // FIXME: Need to support page scaling.
+    if (m_structuralLayer) {
+        clutter_actor_set_position(CLUTTER_ACTOR(m_structuralLayer.get()), m_position.x(), m_position.y());
+        clutter_actor_set_size(CLUTTER_ACTOR(m_structuralLayer.get()), m_size.width(), m_size.height());
+        graphicsLayerActorSetAnchorPoint(m_structuralLayer.get(), m_anchorPoint.x(), m_anchorPoint.y(), m_anchorPoint.z());
+    }
+
     clutter_actor_set_position(CLUTTER_ACTOR(m_layer.get()), m_position.x(), m_position.y());
     clutter_actor_set_size(CLUTTER_ACTOR(m_layer.get()), m_size.width(), m_size.height());
     graphicsLayerActorSetAnchorPoint(m_layer.get(), m_anchorPoint.x(), m_anchorPoint.y(), m_anchorPoint.z());
@@ -655,19 +688,30 @@
 // So whenever the list of child layer changes, the list of GraphicsLayerActor should be updated accordingly.
 void GraphicsLayerClutter::updateSublayerList()
 {
-    GraphicsLayerActorList newSublayers;
+    GraphicsLayerActorList structuralLayerChildren;
+    GraphicsLayerActorList primaryLayerChildren;
+
+    GraphicsLayerActorList& childListForSublayers = m_structuralLayer ? structuralLayerChildren : primaryLayerChildren;
+
+    if (m_structuralLayer)
+        structuralLayerChildren.append(m_layer);
+
     const Vector<GraphicsLayer*>& childLayers = children();
-
     size_t numChildren = childLayers.size();
     for (size_t i = 0; i < numChildren; ++i) {
         GraphicsLayerClutter* currentChild = static_cast<GraphicsLayerClutter*>(childLayers[i]);
         GraphicsLayerActor* childLayer = currentChild->layerForSuperlayer();
         ASSERT(GRAPHICS_LAYER_IS_ACTOR(childLayer));
+        childListForSublayers.append(childLayer);
 
-        newSublayers.append(childLayer);
+        // The child layer only preserves 3D if either itself or its parent has preserves3D set.
+        graphicsLayerActorSetFlatten(childLayer, !(preserves3D() || currentChild->preserves3D()));
     }
 
-    graphicsLayerActorSetSublayers(m_layer.get(), newSublayers);
+    if (m_structuralLayer)
+        graphicsLayerActorSetSublayers(m_structuralLayer.get(), structuralLayerChildren);
+
+    graphicsLayerActorSetSublayers(m_layer.get(), primaryLayerChildren);
 }
 
 void GraphicsLayerClutter::updateLayerNames()
@@ -681,6 +725,92 @@
     clutter_actor_set_transform(CLUTTER_ACTOR(primaryLayer()), &matrix);
 }
 
+void GraphicsLayerClutter::updateStructuralLayer()
+{
+    ensureStructuralLayer(structuralLayerPurpose());
+}
+
+void GraphicsLayerClutter::ensureStructuralLayer(StructuralLayerPurpose purpose)
+{
+    const LayerChangeFlags structuralLayerChangeFlags = NameChanged
+        | GeometryChanged
+        | TransformChanged
+        | ChildrenTransformChanged
+        | ChildrenChanged
+        | BackfaceVisibilityChanged
+        | OpacityChanged;
+
+    if (purpose == NoStructuralLayer) {
+        if (m_structuralLayer) {
+            // Replace the transformLayer in the parent with this layer.
+            graphicsLayerActorRemoveFromSuperLayer(m_layer.get());
+
+            // If m_layer doesn't have a parent, it means it's the root layer and
+            // is likely hosted by something that is not expecting to be changed
+            ClutterActor* parentActor = clutter_actor_get_parent(CLUTTER_ACTOR(m_structuralLayer.get()));
+            ASSERT(parentActor);
+            graphicsLayerActorReplaceSublayer(GRAPHICS_LAYER_ACTOR(parentActor), CLUTTER_ACTOR(m_structuralLayer.get()), CLUTTER_ACTOR(m_layer.get()));
+
+            moveOrCopyAnimations(Move, m_structuralLayer.get(), m_layer.get());
+
+            // Release the structural layer.
+            m_structuralLayer = 0;
+
+            m_uncommittedChanges |= structuralLayerChangeFlags;
+        }
+        return;
+    }
+
+    bool structuralLayerChanged = false;
+    if (purpose == StructuralLayerForPreserves3D) {
+        if (m_structuralLayer && (graphicsLayerActorGetLayerType(m_structuralLayer.get()) != GraphicsLayerClutter::LayerTypeTransformLayer))
+            m_structuralLayer = 0;
+
+        if (!m_structuralLayer) {
+            m_structuralLayer = graphicsLayerActorNewWithClient(GraphicsLayerClutter::LayerTypeTransformLayer, this);
+            structuralLayerChanged = true;
+        }
+    } else {
+        if (m_structuralLayer && (graphicsLayerActorGetLayerType(m_structuralLayer.get()) != GraphicsLayerClutter::LayerTypeLayer))
+            m_structuralLayer = 0;
+
+        if (!m_structuralLayer) {
+            m_structuralLayer = graphicsLayerActorNewWithClient(GraphicsLayerClutter::LayerTypeLayer, this);
+            structuralLayerChanged = true;
+        }
+    }
+
+    if (!structuralLayerChanged)
+        return;
+
+    m_uncommittedChanges |= structuralLayerChangeFlags;
+
+    // We've changed the layer that our parent added to its sublayer list, so tell it to update
+    // sublayers again in its commitLayerChangesAfterSublayers().
+    static_cast<GraphicsLayerClutter*>(parent())->noteSublayersChanged();
+
+    // Set properties of m_layer to their default values, since these are expressed on on the structural layer.
+    FloatPoint point(0, 0);
+    FloatPoint3D anchorPoint(0.5f, 0.5f, 0);
+    clutter_actor_set_position(CLUTTER_ACTOR(m_layer.get()), point.x(), point.y());
+    graphicsLayerActorSetAnchorPoint(m_layer.get(), anchorPoint.x(), anchorPoint.y(), anchorPoint.z());
+
+    CoglMatrix matrix = TransformationMatrix();
+    clutter_actor_set_transform(CLUTTER_ACTOR(m_layer.get()), &matrix);
+
+    clutter_actor_set_opacity(CLUTTER_ACTOR(m_layer.get()), 255);
+
+    moveOrCopyAnimations(Move, m_layer.get(), m_structuralLayer.get());
+}
+
+GraphicsLayerClutter::StructuralLayerPurpose GraphicsLayerClutter::structuralLayerPurpose() const
+{
+    if (preserves3D())
+        return StructuralLayerForPreserves3D;
+
+    return NoStructuralLayer;
+}
+
 void GraphicsLayerClutter::updateLayerDrawsContent(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
 {
     if (m_drawsContent) {
@@ -1099,7 +1229,7 @@
 
 GraphicsLayerActor* GraphicsLayerClutter::layerForSuperlayer() const
 {
-    return m_layer.get();
+    return m_structuralLayer ? m_structuralLayer.get() : m_layer.get();
 }
 
 GraphicsLayerActor* GraphicsLayerClutter::animatedLayer(AnimatedPropertyID property) const

Modified: trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h (147442 => 147443)


--- trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h	2013-04-02 17:10:51 UTC (rev 147442)
+++ trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h	2013-04-02 17:16:14 UTC (rev 147443)
@@ -79,13 +79,21 @@
     virtual void setNeedsDisplay();
     virtual void setNeedsDisplayInRect(const FloatRect&);
 
+    virtual void setPreserves3D(bool);
+
     virtual bool addAnimation(const KeyframeValueList&, const IntSize& boxSize, const Animation*, const String& animationName, double timeOffset);
     virtual void removeAnimation(const String& animationName);
 
     virtual void flushCompositingState(const FloatRect&);
     virtual void flushCompositingStateForThisLayerOnly();
 
-    void recursiveCommitChanges(const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
+    struct CommitState {
+        bool ancestorHasTransformAnimation;
+        CommitState()
+            : ancestorHasTransformAnimation(false)
+        { }
+    };
+    void recursiveCommitChanges(const CommitState&, const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
 
 private:
     FloatPoint computePositionRelativeToBase(float& pageScale) const;
@@ -103,7 +111,7 @@
     virtual void platformClutterLayerAnimationStarted(double beginTime);
     virtual void platformClutterLayerPaintContents(GraphicsContext&, const IntRect& clip);
 
-    GraphicsLayerActor* primaryLayer() const { return m_layer.get(); }
+    GraphicsLayerActor* primaryLayer() const { return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); }
     GraphicsLayerActor* layerForSuperlayer() const;
     GraphicsLayerActor* animatedLayer(AnimatedPropertyID) const;
 
@@ -126,6 +134,9 @@
     bool setTransformAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformClutterAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const IntSize& boxSize);
     bool setTransformAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformClutterAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const IntSize& boxSize);
 
+    enum MoveOrCopy { Move, Copy };
+    void moveOrCopyAnimations(MoveOrCopy, GraphicsLayerActor* fromLayer, GraphicsLayerActor* toLayer);
+
     bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const IntSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation);
 
     enum LayerChange {
@@ -147,12 +158,17 @@
         ContentsImageChanged = 1 << 15,
         ContentsMediaLayerChanged = 1 << 16,
         ContentsCanvasLayerChanged = 1 << 17,
-        ContentsRectChanged = 1 << 18,
-        MaskLayerChanged = 1 << 19,
-        ReplicatedLayerChanged = 1 << 20,
-        ContentsNeedsDisplay = 1 << 21,
-        AcceleratesDrawingChanged = 1 << 22,
-        ContentsScaleChanged = 1 << 23
+        ContentsColorLayerChanged = 1 << 18,
+        ContentsRectChanged = 1 << 19,
+        MaskLayerChanged = 1 << 20,
+        ReplicatedLayerChanged = 1 << 21,
+        ContentsNeedsDisplay = 1 << 22,
+        AcceleratesDrawingChanged = 1 << 23,
+        ContentsScaleChanged = 1 << 24,
+        ContentsVisibilityChanged = 1 << 25,
+        VisibleRectChanged = 1 << 26,
+        FiltersChanged = 1 << 27,
+        DebugIndicatorsChanged = 1 << 28
     };
 
     typedef unsigned LayerChangeFlags;
@@ -160,6 +176,7 @@
     void noteSublayersChanged();
 
     void updateBackfaceVisibility();
+    void updateStructuralLayer();
     void updateLayerNames();
     void updateSublayerList();
     void updateGeometry(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
@@ -168,9 +185,18 @@
 
     void updateAnimations();
 
+    enum StructuralLayerPurpose {
+        NoStructuralLayer = 0,
+        StructuralLayerForPreserves3D,
+        StructuralLayerForReplicaFlattening
+    };
+    void ensureStructuralLayer(StructuralLayerPurpose);
+    StructuralLayerPurpose structuralLayerPurpose() const;
+
     void repaintLayerDirtyRects();
 
     GRefPtr<GraphicsLayerActor> m_layer;
+    GRefPtr<GraphicsLayerActor> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
 
     Vector<FloatRect> m_dirtyRects;
     LayerChangeFlags m_uncommittedChanges;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to