Include child layers in the remote layer tree transaction
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2012 02:10:09 +0000 (02:10 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2012 02:10:09 +0000 (02:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102026

Reviewed by Andreas Kling.

* Shared/mac/RemoteLayerTreeTransaction.h:
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
Encode and decode child layer IDs.

(WebKit::RemoteLayerTreeTransaction::layerPropertiesChanged):
Grab all child layer IDs and stick them in a vector.

(WebKit::dumpChangedLayers):
Dump child layer IDs as well.

* WebProcess/WebPage/mac/RemoteGraphicsLayer.h:
* WebProcess/WebPage/mac/RemoteGraphicsLayer.mm:
(WebKit::RemoteGraphicsLayer::setChildren):
(WebKit::RemoteGraphicsLayer::addChild):
(WebKit::RemoteGraphicsLayer::addChildAtIndex):
(WebKit::RemoteGraphicsLayer::addChildAbove):
(WebKit::RemoteGraphicsLayer::addChildBelow):
(WebKit::RemoteGraphicsLayer::replaceChild):
Call noteSublayersChanged.

(WebKit::RemoteGraphicsLayer::noteSublayersChanged):
Note that the Children property changed.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteGraphicsLayer.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteGraphicsLayer.mm

index fc39157..4954a47 100644 (file)
@@ -1,5 +1,37 @@
 2012-11-12  Anders Carlsson  <andersca@apple.com>
 
+        Include child layers in the remote layer tree transaction
+        https://bugs.webkit.org/show_bug.cgi?id=102026
+
+        Reviewed by Andreas Kling.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+        Encode and decode child layer IDs.
+
+        (WebKit::RemoteLayerTreeTransaction::layerPropertiesChanged):
+        Grab all child layer IDs and stick them in a vector.
+
+        (WebKit::dumpChangedLayers):
+        Dump child layer IDs as well.
+
+        * WebProcess/WebPage/mac/RemoteGraphicsLayer.h:
+        * WebProcess/WebPage/mac/RemoteGraphicsLayer.mm:
+        (WebKit::RemoteGraphicsLayer::setChildren):
+        (WebKit::RemoteGraphicsLayer::addChild):
+        (WebKit::RemoteGraphicsLayer::addChildAtIndex):
+        (WebKit::RemoteGraphicsLayer::addChildAbove):
+        (WebKit::RemoteGraphicsLayer::addChildBelow):
+        (WebKit::RemoteGraphicsLayer::replaceChild):
+        Call noteSublayersChanged.
+
+        (WebKit::RemoteGraphicsLayer::noteSublayersChanged):
+        Note that the Children property changed.
+
+2012-11-12  Anders Carlsson  <andersca@apple.com>
+
         Send along the current remote layer tree transaction with the commit message
         https://bugs.webkit.org/show_bug.cgi?id=102014
 
index f567466..e3bc85f 100644 (file)
@@ -43,6 +43,7 @@ public:
     enum LayerChange {
         NoChange = 0,
         NameChanged = 1 << 1,
+        ChildrenChanged = 1 << 2,
     };
 
     struct LayerProperties {
@@ -54,6 +55,7 @@ public:
         unsigned changedProperties;
 
         String name;
+        Vector<uint64_t> children;
     };
 
     RemoteLayerTreeTransaction();
index bd20f29..dba5b19 100644 (file)
@@ -33,6 +33,8 @@
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 
+using namespace WebCore;
+
 namespace WebKit {
 
 RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
@@ -46,6 +48,9 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(CoreIPC::ArgumentEncode
 
     if (changedProperties & NameChanged)
         encoder << name;
+
+    if (changedProperties & ChildrenChanged)
+        encoder << children;
 }
 
 bool RemoteLayerTreeTransaction::LayerProperties::decode(CoreIPC::ArgumentDecoder* decoder, LayerProperties& result)
@@ -58,6 +63,16 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(CoreIPC::ArgumentDecode
             return false;
     }
 
+    if (result.changedProperties & ChildrenChanged) {
+        if (!decoder->decode(result.children))
+            return false;
+
+        for (auto layerID: result.children) {
+            if (!layerID)
+                return false;
+        }
+    }
+
     return true;
 }
 
@@ -90,6 +105,17 @@ void RemoteLayerTreeTransaction::layerPropertiesChanged(const RemoteGraphicsLaye
 
     if (changedProperties & NameChanged)
         layerProperties.name = graphicsLayer->name();
+
+    if (changedProperties & ChildrenChanged) {
+        const Vector<GraphicsLayer*>& children = graphicsLayer->children();
+
+        ASSERT(layerProperties.children.isEmpty());
+        layerProperties.children.reserveCapacity(children.size());
+        for (size_t i = 0; i < children.size(); ++i) {
+            RemoteGraphicsLayer* childLayer = static_cast<RemoteGraphicsLayer*>(children[i]);
+            layerProperties.children.uncheckedAppend(childLayer->layerID());
+        }
+    }
 }
 
 #ifndef NDEBUG
@@ -128,6 +154,19 @@ static void dumpChangedLayers(StringBuilder& builder, const HashMap<uint64_t, Re
             builder.append("\")");
         }
 
+        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
+            builder.append('\n');
+            writeIndent(builder, 3);
+            builder.append("(children (");
+            for (size_t i = 0; i < layerProperties.children.size(); ++i) {
+                if (i != 0)
+                    builder.append(' ');
+                builder.appendNumber(layerProperties.children[i]);
+            }
+
+            builder.append(")");
+        }
+
         builder.append(")\n");
     }
 }
index 9789ded..2d97f7d 100644 (file)
@@ -51,8 +51,10 @@ void RemoteLayerTreeHost::didReceiveMessage(CoreIPC::Connection* connection, Cor
 
 void RemoteLayerTreeHost::commit(const RemoteLayerTreeTransaction& transaction)
 {
+#ifndef NDEBUG
     // FIXME: Apply the transaction instead of dumping it to stderr.
     transaction.dump();
+#endif
 }
 
 } // namespace WebKit
index 04b5b1b..9bea5c3 100644 (file)
@@ -44,12 +44,22 @@ private:
 
     // WebCore::GraphicsLayer
     virtual void setName(const String&) OVERRIDE;
+
+    virtual bool setChildren(const Vector<WebCore::GraphicsLayer*>&);
+    virtual void addChild(WebCore::GraphicsLayer*);
+    virtual void addChildAtIndex(WebCore::GraphicsLayer*, int index);
+    virtual void addChildAbove(WebCore::GraphicsLayer* childLayer, WebCore::GraphicsLayer* sibling);
+    virtual void addChildBelow(WebCore::GraphicsLayer* childLayer, WebCore::GraphicsLayer* sibling);
+    virtual bool replaceChild(WebCore::GraphicsLayer* oldChild, WebCore::GraphicsLayer* newChild);
+
     virtual void setNeedsDisplay() OVERRIDE;
     virtual void setNeedsDisplayInRect(const WebCore::FloatRect&) OVERRIDE;
     virtual void flushCompositingState(const WebCore::FloatRect&) OVERRIDE;
     virtual void flushCompositingStateForThisLayerOnly() OVERRIDE;
 
     void noteLayerPropertiesChanged(unsigned layerChanges);
+    void noteSublayersChanged();
+
     void recursiveCommitChanges();
 
     uint64_t m_layerID;
index 033d832..bb707c9 100644 (file)
@@ -66,6 +66,50 @@ void RemoteGraphicsLayer::setName(const String& name)
     noteLayerPropertiesChanged(RemoteLayerTreeTransaction::NameChanged);
 }
 
+bool RemoteGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
+{
+    if (GraphicsLayer::setChildren(children)) {
+        noteSublayersChanged();
+        return true;
+    }
+
+    return false;
+}
+
+void RemoteGraphicsLayer::addChild(GraphicsLayer* childLayer)
+{
+    GraphicsLayer::addChild(childLayer);
+    noteSublayersChanged();
+}
+
+void RemoteGraphicsLayer::addChildAtIndex(GraphicsLayer* childLayer, int index)
+{
+    GraphicsLayer::addChildAtIndex(childLayer, index);
+    noteSublayersChanged();
+}
+
+void RemoteGraphicsLayer::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer* sibling)
+{
+    GraphicsLayer::addChildAbove(childLayer, sibling);
+    noteSublayersChanged();
+}
+
+void RemoteGraphicsLayer::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
+{
+    GraphicsLayer::addChildBelow(childLayer, sibling);
+    noteSublayersChanged();
+}
+
+bool RemoteGraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
+{
+    if (GraphicsLayer::replaceChild(oldChild, newChild)) {
+        noteSublayersChanged();
+        return true;
+    }
+
+    return false;
+}
+
 void RemoteGraphicsLayer::setNeedsDisplay()
 {
     FloatRect hugeRect(-std::numeric_limits<float>::max() / 2, -std::numeric_limits<float>::max() / 2,
@@ -100,6 +144,13 @@ void RemoteGraphicsLayer::noteLayerPropertiesChanged(unsigned layerChanges)
     m_uncommittedLayerChanges |= layerChanges;
 }
 
+void RemoteGraphicsLayer::noteSublayersChanged()
+{
+    noteLayerPropertiesChanged(RemoteLayerTreeTransaction::ChildrenChanged);
+
+    // FIXME: Handle replica layers.
+}
+
 void RemoteGraphicsLayer::recursiveCommitChanges()
 {
     flushCompositingStateForThisLayerOnly();