Remote Layer Tree: Support cloning layers
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Dec 2013 22:42:34 +0000 (22:42 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Dec 2013 22:42:34 +0000 (22:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124874
<rdar://problem/15349468>

Reviewed by Simon Fraser.

We use PlatformCALayer::clone for CSS reflections, so implement it.

Also, since many reflections testcases also use masks,
working on this revealed that masks weren't working, because
we weren't flushing mask layers.

* Shared/mac/RemoteLayerTreePropertyApplier.mm:
(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
Rename maskLayer->maskLayerID since it's a LayerID.

* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::commit):
Don't try to look up the layer if it's null.

* Shared/mac/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::notePropertiesChanged):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
Keep track of all properties that have ever been changed on a layer.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(PlatformCALayerRemote::create):
(PlatformCALayerRemote::PlatformCALayerRemote):
(PlatformCALayerRemote::clone):
Copy all of the layer properties from the original to the clone,
and mark all properties that have ever been modified as
needing to be flushed to the UI process.

(PlatformCALayerRemote::recursiveBuildTransaction):
Flush our mask layer, if we have one.

(PlatformCALayerRemote::setMask):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
Store the mask layer we're given. Our owning GraphicsLayer will
hold on to it for us.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

index 085bc66..b5079db 100644 (file)
@@ -1,3 +1,51 @@
+2013-12-02  Tim Horton  <timothy_horton@apple.com>
+
+        Remote Layer Tree: Support cloning layers
+        https://bugs.webkit.org/show_bug.cgi?id=124874
+        <rdar://problem/15349468>
+
+        Reviewed by Simon Fraser.
+
+        We use PlatformCALayer::clone for CSS reflections, so implement it.
+
+        Also, since many reflections testcases also use masks,
+        working on this revealed that masks weren't working, because
+        we weren't flushing mask layers.
+
+        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+        Rename maskLayer->maskLayerID since it's a LayerID.
+
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::commit):
+        Don't try to look up the layer if it's null.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::notePropertiesChanged):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
+        Keep track of all properties that have ever been changed on a layer.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (PlatformCALayerRemote::create):
+        (PlatformCALayerRemote::PlatformCALayerRemote):
+        (PlatformCALayerRemote::clone):
+        Copy all of the layer properties from the original to the clone,
+        and mark all properties that have ever been modified as
+        needing to be flushed to the UI process.
+
+        (PlatformCALayerRemote::recursiveBuildTransaction):
+        Flush our mask layer, if we have one.
+
+        (PlatformCALayerRemote::setMask):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+        Store the mask layer we're given. Our owning GraphicsLayer will
+        hold on to it for us.
+
 2013-12-02  Anders Carlsson  <andersca@apple.com>
 
         WKPageLoaderClient should be versioned
index d9080d2..7695ea8 100644 (file)
@@ -116,10 +116,14 @@ void RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer *layer, Remo
         layer.opaque = properties.opaque;
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged) {
-        CALayer *maskLayer = relatedLayers.get(properties.maskLayer);
-        ASSERT(!maskLayer.superlayer);
-        if (!maskLayer.superlayer)
-            layer.mask = maskLayer;
+        if (!properties.maskLayerID)
+            layer.mask = nullptr;
+        else {
+            CALayer *maskLayer = relatedLayers.get(properties.maskLayerID);
+            ASSERT(!maskLayer.superlayer);
+            if (!maskLayer.superlayer)
+                layer.mask = maskLayer;
+        }
     }
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
index 4701173..69954e1 100644 (file)
@@ -97,9 +97,14 @@ public:
         void encode(CoreIPC::ArgumentEncoder&) const;
         static bool decode(CoreIPC::ArgumentDecoder&, LayerProperties&);
 
-        void notePropertiesChanged(LayerChange layerChanges) { changedProperties = static_cast<LayerChange>(changedProperties | layerChanges); }
+        void notePropertiesChanged(LayerChange layerChanges)
+        {
+            changedProperties = static_cast<LayerChange>(changedProperties | layerChanges);
+            everChangedProperties = static_cast<LayerChange>(everChangedProperties | layerChanges);
+        }
 
         LayerChange changedProperties;
+        LayerChange everChangedProperties;
 
         String name;
         Vector<LayerID> children;
@@ -117,7 +122,7 @@ public:
         bool doubleSided;
         bool masksToBounds;
         bool opaque;
-        LayerID maskLayer;
+        LayerID maskLayerID;
         WebCore::FloatRect contentsRect;
         float contentsScale;
         WebCore::PlatformCALayer::FilterType minificationFilter;
index e894073..7e93935 100644 (file)
@@ -70,6 +70,7 @@ bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(CoreIPC::Argume
 
 RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
     : changedProperties(NoChange)
+    , everChangedProperties(NoChange)
 {
 }
 
@@ -126,7 +127,7 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(CoreIPC::ArgumentEncode
         encoder << opaque;
 
     if (changedProperties & MaskLayerChanged)
-        encoder << maskLayer;
+        encoder << maskLayerID;
 
     if (changedProperties & ContentsRectChanged)
         encoder << contentsRect;
@@ -247,7 +248,7 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(CoreIPC::ArgumentDecode
     }
 
     if (result.changedProperties & MaskLayerChanged) {
-        if (!decoder.decode(result.maskLayer))
+        if (!decoder.decode(result.maskLayerID))
             return false;
     }
 
@@ -609,7 +610,7 @@ static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const HashMap<Remot
             dumpProperty<bool>(ts, "opaque", layerProperties.opaque);
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
-            dumpProperty<RemoteLayerTreeTransaction::LayerID>(ts, "maskLayer", layerProperties.maskLayer);
+            dumpProperty<RemoteLayerTreeTransaction::LayerID>(ts, "maskLayer", layerProperties.maskLayerID);
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
             dumpProperty<FloatRect>(ts, "contentsRect", layerProperties.contentsRect);
index 59a92ae..c4342ab 100644 (file)
@@ -80,8 +80,8 @@ void RemoteLayerTreeHost::commit(const RemoteLayerTreeTransaction& transaction)
                 relatedLayers.set(child, getLayer(child));
         }
 
-        if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
-            relatedLayers.set(properties.maskLayer, getLayer(properties.maskLayer));
+        if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged && properties.maskLayerID)
+            relatedLayers.set(properties.maskLayerID, getLayer(properties.maskLayerID));
 
         RemoteLayerTreePropertyApplier::applyPropertiesToLayer(layer, properties, relatedLayers);
     }
index 8005d07..0295c41 100644 (file)
@@ -59,7 +59,7 @@ static PlatformCALayerRemote* toPlatformCALayerRemote(PlatformCALayer* layer)
     return static_cast<PlatformCALayerRemote*>(layer);
 }
 
-PassRefPtr<PlatformCALayer> PlatformCALayerRemote::create(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
+PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
 {
     RefPtr<PlatformCALayerRemote> layer;
 
@@ -73,7 +73,7 @@ PassRefPtr<PlatformCALayer> PlatformCALayerRemote::create(LayerType layerType, P
     return layer.release();
 }
 
-PassRefPtr<PlatformCALayer> PlatformCALayerRemote::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
+PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
 {
     RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemoteCustom(static_cast<PlatformLayer*>(platformLayer), owner, context));
 
@@ -86,6 +86,7 @@ PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALaye
     : PlatformCALayer(layerType, owner)
     , m_layerID(generateLayerID())
     , m_superlayer(nullptr)
+    , m_maskLayer(nullptr)
     , m_acceleratesDrawing(false)
     , m_context(context)
 {
@@ -93,9 +94,14 @@ PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALaye
     setContentsScale(1);
 }
 
-PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* owner) const
+PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* client) const
 {
-    return nullptr;
+    RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(layerType(), client, m_context);
+
+    clone->m_properties = m_properties;
+    clone->m_properties.notePropertiesChanged(static_cast<RemoteLayerTreeTransaction::LayerChange>(m_properties.everChangedProperties & ~RemoteLayerTreeTransaction::BackingStoreChanged));
+
+    return clone.release();
 }
 
 PlatformCALayerRemote::~PlatformCALayerRemote()
@@ -132,6 +138,9 @@ void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeTransaction
         ASSERT(child->superlayer() == this);
         child->recursiveBuildTransaction(transaction);
     }
+
+    if (m_maskLayer)
+        m_maskLayer->recursiveBuildTransaction(transaction);
 }
 
 void PlatformCALayerRemote::animationStarted(CFTimeInterval beginTime)
@@ -264,7 +273,14 @@ PassRefPtr<PlatformCAAnimation> PlatformCALayerRemote::animationForKey(const Str
 
 void PlatformCALayerRemote::setMask(PlatformCALayer* layer)
 {
-    m_properties.maskLayer = toPlatformCALayerRemote(layer)->layerID();
+    if (layer) {
+        m_maskLayer = toPlatformCALayerRemote(layer);
+        m_properties.maskLayerID = m_maskLayer->layerID();
+    } else {
+        m_maskLayer = nullptr;
+        m_properties.maskLayerID = 0;
+    }
+
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MaskLayerChanged);
 }
 
index 7c7d065..8cb0470 100644 (file)
@@ -39,8 +39,8 @@ class RemoteLayerTreeContext;
 
 class PlatformCALayerRemote : public WebCore::PlatformCALayer {
 public:
-    static PassRefPtr<PlatformCALayer> create(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
-    static PassRefPtr<PlatformCALayer> create(PlatformLayer *, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
+    static PassRefPtr<PlatformCALayerRemote> create(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
+    static PassRefPtr<PlatformCALayerRemote> create(PlatformLayer *, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
 
     virtual ~PlatformCALayerRemote();
 
@@ -161,6 +161,7 @@ private:
     RemoteLayerTreeTransaction::LayerProperties m_properties;
     WebCore::PlatformCALayerList m_children;
     PlatformCALayerRemote* m_superlayer;
+    PlatformCALayerRemote* m_maskLayer;
     bool m_acceleratesDrawing;
 
     RemoteLayerTreeContext* m_context;