[CoordinatedGraphics] support bounds origin
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2019 10:34:31 +0000 (10:34 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2019 10:34:31 +0000 (10:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198998

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Add bounds-origin support to the CoordinatedGraphics stack. Currently we
take the short-cut implementation of just combining the bounds origin
and the position value and incorporating them into the layer transform
we calculate in TextureMapperLayer.

Additional boilerplate code is added, as required, to relay the
WebCore::GraphicsLayer change of bounds origin to the rendering system.

* platform/graphics/nicosia/NicosiaPlatformLayer.h:
(Nicosia::CompositionLayer::flushState):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computeTransformsRecursive):
(WebCore::TextureMapperLayer::setBoundsOrigin):
* platform/graphics/texmap/TextureMapperLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setBoundsOrigin):
(WebCore::CoordinatedGraphicsLayer::computePositionRelativeToBase):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

Source/WebKit:

* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::updateSceneState):
Apply bounds origin value to the TextureMapperLayer object.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250418 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp

index e62362b..9b8a66d 100644 (file)
@@ -1,3 +1,29 @@
+2019-09-27  Zan Dobersek  <zdobersek@igalia.com>
+
+        [CoordinatedGraphics] support bounds origin
+        https://bugs.webkit.org/show_bug.cgi?id=198998
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add bounds-origin support to the CoordinatedGraphics stack. Currently we
+        take the short-cut implementation of just combining the bounds origin
+        and the position value and incorporating them into the layer transform
+        we calculate in TextureMapperLayer.
+
+        Additional boilerplate code is added, as required, to relay the
+        WebCore::GraphicsLayer change of bounds origin to the rendering system.
+
+        * platform/graphics/nicosia/NicosiaPlatformLayer.h:
+        (Nicosia::CompositionLayer::flushState):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::computeTransformsRecursive):
+        (WebCore::TextureMapperLayer::setBoundsOrigin):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::setBoundsOrigin):
+        (WebCore::CoordinatedGraphicsLayer::computePositionRelativeToBase):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+
 2019-09-26  Zan Dobersek  <zdobersek@igalia.com>
 
         ScrollingTreeScrollingNode: use LayerRepresentation for scroll container, scrolled contents layers
index 8c7f661..a0e4068 100644 (file)
@@ -112,6 +112,7 @@ public:
                     bool positionChanged : 1;
                     bool anchorPointChanged : 1;
                     bool sizeChanged : 1;
+                    bool boundsOriginChanged : 1;
                     bool transformChanged : 1;
                     bool childrenTransformChanged : 1;
                     bool contentsRectChanged : 1;
@@ -157,6 +158,7 @@ public:
         WebCore::FloatPoint position;
         WebCore::FloatPoint3D anchorPoint;
         WebCore::FloatSize size;
+        WebCore::FloatPoint boundsOrigin;
 
         WebCore::TransformationMatrix transform;
         WebCore::TransformationMatrix childrenTransform;
@@ -215,6 +217,8 @@ public:
             staging.anchorPoint = pending.anchorPoint;
         if (pending.delta.sizeChanged)
             staging.size = pending.size;
+        if (pending.delta.boundsOriginChanged)
+            staging.boundsOrigin = pending.boundsOrigin;
 
         if (pending.delta.transformChanged)
             staging.transform = pending.transform;
index b6632c0..06f322d 100644 (file)
@@ -68,7 +68,7 @@ void TextureMapperLayer::computeTransformsRecursive()
 
         m_layerTransforms.combined = parentTransform;
         m_layerTransforms.combined
-            .translate3d(originX + m_state.pos.x(), originY + m_state.pos.y(), m_state.anchorPoint.z())
+            .translate3d(originX + (m_state.pos.x() - m_state.boundsOrigin.x()), originY + (m_state.pos.y() - m_state.boundsOrigin.y()), m_state.anchorPoint.z())
             .multiply(m_layerTransforms.localTransform);
 
         m_layerTransforms.combinedForChildren = m_layerTransforms.combined;
@@ -89,7 +89,7 @@ void TextureMapperLayer::computeTransformsRecursive()
 
         m_layerTransforms.futureCombined = futureParentTransform;
         m_layerTransforms.futureCombined
-            .translate3d(originX + m_state.pos.x(), originY + m_state.pos.y(), m_state.anchorPoint.z())
+            .translate3d(originX + (m_state.pos.x() - m_state.boundsOrigin.x()), originY + (m_state.pos.y() - m_state.boundsOrigin.y()), m_state.anchorPoint.z())
             .multiply(m_layerTransforms.futureLocalTransform);
 
         m_layerTransforms.futureCombinedForChildren = m_layerTransforms.futureCombined;
@@ -542,6 +542,11 @@ void TextureMapperLayer::setPosition(const FloatPoint& position)
     m_state.pos = position;
 }
 
+void TextureMapperLayer::setBoundsOrigin(const FloatPoint& boundsOrigin)
+{
+    m_state.boundsOrigin = boundsOrigin;
+}
+
 void TextureMapperLayer::setSize(const FloatSize& size)
 {
     m_state.size = size;
index f3c286c..be0ed19 100644 (file)
@@ -60,6 +60,7 @@ public:
     void setMaskLayer(TextureMapperLayer*);
     void setReplicaLayer(TextureMapperLayer*);
     void setPosition(const FloatPoint&);
+    void setBoundsOrigin(const FloatPoint&);
     void setSize(const FloatSize&);
     void setAnchorPoint(const FloatPoint3D&);
     void setPreserves3D(bool);
@@ -157,6 +158,7 @@ private:
     struct State {
         FloatPoint pos;
         FloatPoint3D anchorPoint;
+        FloatPoint boundsOrigin;
         FloatSize size;
         TransformationMatrix transform;
         TransformationMatrix childrenTransform;
index 633773a..1b7da85 100644 (file)
@@ -261,6 +261,16 @@ void CoordinatedGraphicsLayer::setSize(const FloatSize& size)
     didChangeGeometry();
 }
 
+void CoordinatedGraphicsLayer::setBoundsOrigin(const FloatPoint& boundsOrigin)
+{
+    if (this->boundsOrigin() == boundsOrigin)
+        return;
+
+    GraphicsLayer::setBoundsOrigin(boundsOrigin);
+    m_nicosia.delta.boundsOriginChanged = true;
+    didChangeGeometry();
+}
+
 void CoordinatedGraphicsLayer::setTransform(const TransformationMatrix& t)
 {
     if (transform() == t)
@@ -1132,7 +1142,7 @@ FloatPoint CoordinatedGraphicsLayer::computePositionRelativeToBase()
 {
     FloatPoint offset;
     for (const GraphicsLayer* currLayer = this; currLayer; currLayer = currLayer->parent())
-        offset += currLayer->position();
+        offset += (currLayer->position() - currLayer->boundsOrigin());
 
     return offset;
 }
index 9af5a4e..da8e766 100644 (file)
@@ -75,6 +75,7 @@ public:
     void setPosition(const FloatPoint&) override;
     void setAnchorPoint(const FloatPoint3D&) override;
     void setSize(const FloatSize&) override;
+    void setBoundsOrigin(const FloatPoint&) override;
     void setTransform(const TransformationMatrix&) override;
     void setChildrenTransform(const TransformationMatrix&) override;
     void setPreserves3D(bool) override;
index 87d33b8..403636d 100644 (file)
@@ -1,3 +1,14 @@
+2019-09-27  Zan Dobersek  <zdobersek@igalia.com>
+
+        [CoordinatedGraphics] support bounds origin
+        https://bugs.webkit.org/show_bug.cgi?id=198998
+
+        Reviewed by Carlos Garcia Campos.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+        (WebKit::CoordinatedGraphicsScene::updateSceneState):
+        Apply bounds origin value to the TextureMapperLayer object.
+
 2019-09-27  Youenn Fablet  <youenn@apple.com>
 
         Make IsNSURLSessionWebSocketEnabled an experimental flag
index 70430f4..61af2c0 100644 (file)
@@ -291,6 +291,8 @@ void CoordinatedGraphicsScene::updateSceneState()
                             layer.setAnchorPoint(layerState.anchorPoint);
                         if (layerState.delta.sizeChanged)
                             layer.setSize(layerState.size);
+                        if (layerState.delta.boundsOriginChanged)
+                            layer.setBoundsOrigin(layerState.boundsOrigin);
 
                         if (layerState.delta.transformChanged)
                             layer.setTransform(layerState.transform);