<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[170864] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/170864">170864</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2014-07-07 16:44:58 -0700 (Mon, 07 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[UI-side compositing] Support reflections on custom layers like video
https://bugs.webkit.org/show_bug.cgi?id=134701

Reviewed by Tim Horton.

Source/WebCore:

Add a LayerTypeWebGLLayer layer type, and support casting to PlatformCALayerRemoteCustom.

* WebCore.exp.in: Export PlatformCALayerMac::layerTypeForPlatformLayer(CALayer*), and sort.
* platform/graphics/ca/PlatformCALayer.h:
(WebCore::PlatformCALayer::isPlatformCALayerRemoteCustom):
* platform/graphics/ca/mac/PlatformCALayerMac.h:
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayerMac::layerTypeForPlatformLayer):
(PlatformCALayerMac::PlatformCALayerMac):
(PlatformCALayerMac::commonInit):

Source/WebKit2:

For video reflections, we have to support cloning of PlatformCALayerRemoteCustom
in the web process. Do so by implementing PlatformCALayerRemoteCustom::clone(),
which does the right gyrations to get AVPlayerLayers cloned, then makes a
new PlatformCALayerRemoteCustom to wrap the new layer. This ends up getting
its own context hosting ID, allowing the clone to show in the UI process.

Attempt to do the same for WebGL, but turn it off because it breaks.

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::drawInContext):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::encode): Unconditionally encode/decode
the hostingContextID. It will be 0 for most layers.
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
(WebKit::RemoteLayerTreeTransaction::description):
* UIProcess/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::createLayer):
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::createLayer):
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::create): Creation with a custom PlatformLayer* always
creates a PlatformCALayerRemoteCustom.
(WebKit::PlatformCALayerRemote::clone): Factor some code.
(WebKit::PlatformCALayerRemote::updateClonedLayerProperties):
(WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h:
* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
(WebKit::PlatformCALayerRemoteCustom::create):
(WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
(WebKit::PlatformCALayerRemoteCustom::clone): Clone by making an instance of the
correct type of platform layer when possible, then wrapping a PlatformCALayerRemoteCustom
around it.
(WebKit::PlatformCALayerRemoteCustom::contents):
(WebKit::PlatformCALayerRemoteCustom::setContents):
* WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::layerWasCreated):
(WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaPlatformCALayerh">trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMach">trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMacmm">trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm">trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosRemoteLayerTreeHostIOSmm">trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacRemoteLayerTreeHostmm">trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemotecpp">trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteh">trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteCustomh">trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteCustommm">trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeContextmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebCore/ChangeLog        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2014-07-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [UI-side compositing] Support reflections on custom layers like video
+        https://bugs.webkit.org/show_bug.cgi?id=134701
+
+        Reviewed by Tim Horton.
+
+        Add a LayerTypeWebGLLayer layer type, and support casting to PlatformCALayerRemoteCustom.
+
+        * WebCore.exp.in: Export PlatformCALayerMac::layerTypeForPlatformLayer(CALayer*), and sort.
+        * platform/graphics/ca/PlatformCALayer.h:
+        (WebCore::PlatformCALayer::isPlatformCALayerRemoteCustom):
+        * platform/graphics/ca/mac/PlatformCALayerMac.h:
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayerMac::layerTypeForPlatformLayer):
+        (PlatformCALayerMac::PlatformCALayerMac):
+        (PlatformCALayerMac::commonInit):
+
+2014-07-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
</ins><span class="cx">         [UI-side compositing] Crash when starting a filter transition on a reflected layer
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=134694
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -158,14 +158,18 @@
</span><span class="cx"> __ZN7WebCore11HistoryItem12setViewStateEP11objc_object
</span><span class="cx"> __ZN7WebCore11HistoryItem14addRedirectURLERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore11HistoryItem14setScrollPointERKNS_8IntPointE
</span><ins>+__ZN7WebCore11HistoryItem14setStateObjectEN3WTF10PassRefPtrINS_21SerializedScriptValueEEE
</ins><span class="cx"> __ZN7WebCore11HistoryItem15setIsTargetItemEb
</span><span class="cx"> __ZN7WebCore11HistoryItem15setRedirectURLsENSt3__110unique_ptrIN3WTF6VectorINS3_6StringELm0ENS3_15CrashOnOverflowEEENS1_14default_deleteIS7_EEEE
</span><span class="cx"> __ZN7WebCore11HistoryItem16setDocumentStateERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
</span><span class="cx"> __ZN7WebCore11HistoryItem17setAlternateTitleERKN3WTF6StringE
</span><ins>+__ZN7WebCore11HistoryItem18setFormContentTypeERKN3WTF6StringE
+__ZN7WebCore11HistoryItem18setPageScaleFactorEf
</ins><span class="cx"> __ZN7WebCore11HistoryItem20setOriginalURLStringERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore11HistoryItem20setTransientPropertyERKN3WTF6StringEP11objc_object
</span><span class="cx"> __ZN7WebCore11HistoryItem8formDataEv
</span><span class="cx"> __ZN7WebCore11HistoryItem8setTitleERKN3WTF6StringE
</span><ins>+__ZN7WebCore11HistoryItem9setTargetERKN3WTF6StringE
</ins><span class="cx"> __ZN7WebCore11HistoryItemC1ERKN3WTF6StringES4_
</span><span class="cx"> __ZN7WebCore11HistoryItemC1ERKN3WTF6StringES4_S4_
</span><span class="cx"> __ZN7WebCore11HistoryItemC1ERKNS_3URLERKN3WTF6StringES7_S7_
</span><span class="lines">@@ -595,10 +599,6 @@
</span><span class="cx"> __ZN7WebCore15GraphicsLayerCA8addChildEPNS_13GraphicsLayerE
</span><span class="cx"> __ZN7WebCore15GraphicsLayerCAC2ERNS_19GraphicsLayerClientE
</span><span class="cx"> __ZN7WebCore15GraphicsLayerCAD2Ev
</span><del>-__ZN7WebCore11HistoryItem14setStateObjectEN3WTF10PassRefPtrINS_21SerializedScriptValueEEE
-__ZN7WebCore11HistoryItem18setFormContentTypeERKN3WTF6StringE
-__ZN7WebCore11HistoryItem18setPageScaleFactorEf
-__ZN7WebCore11HistoryItem9setTargetERKN3WTF6StringE
</del><span class="cx"> __ZN7WebCore15HitTestLocation12rectForPointERKNS_11LayoutPointEjjjj
</span><span class="cx"> __ZN7WebCore15HitTestLocationC1ERKNS_10FloatPointE
</span><span class="cx"> __ZN7WebCore15HitTestLocationD1Ev
</span><span class="lines">@@ -774,6 +774,7 @@
</span><span class="cx"> __ZN7WebCore18DOMWindowExtensionC1EPNS_5FrameERNS_15DOMWrapperWorldE
</span><span class="cx"> __ZN7WebCore18PlatformCALayerMac18setGeometryFlippedEb
</span><span class="cx"> __ZN7WebCore18PlatformCALayerMac22filtersCanBeCompositedERKNS_16FilterOperationsE
</span><ins>+__ZN7WebCore18PlatformCALayerMac25layerTypeForPlatformLayerEP7CALayer
</ins><span class="cx"> __ZN7WebCore18PlatformPasteboard10uniqueNameEv
</span><span class="cx"> __ZN7WebCore18PlatformPasteboard13bufferForTypeERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore18PlatformPasteboard13stringForTypeERKN3WTF6StringE
</span><span class="lines">@@ -1300,8 +1301,8 @@
</span><span class="cx"> __ZN7WebCore8FormData10appendBlobERKNS_3URLE
</span><span class="cx"> __ZN7WebCore8FormData10appendDataEPKvm
</span><span class="cx"> __ZN7WebCore8FormData15appendFileRangeERKN3WTF6StringExxdb
</span><ins>+__ZN7WebCore8FormData6createEPKvm
</ins><span class="cx"> __ZN7WebCore8FormData6createEv
</span><del>-__ZN7WebCore8FormData6createEPKvm
</del><span class="cx"> __ZN7WebCore8FormDataD1Ev
</span><span class="cx"> __ZN7WebCore8Gradient12addColorStopEfRKNS_5ColorE
</span><span class="cx"> __ZN7WebCore8GradientC1ERKNS_10FloatPointES3_
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaPlatformCALayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx">         LayerTypeTiledBackingTileLayer,
</span><span class="cx">         LayerTypeRootLayer,
</span><span class="cx">         LayerTypeAVPlayerLayer,
</span><ins>+        LayerTypeWebGLLayer,
</ins><span class="cx">         LayerTypeCustom
</span><span class="cx">     };
</span><span class="cx">     enum FilterType { Linear, Nearest, Trilinear };
</span><span class="lines">@@ -87,6 +88,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool isPlatformCALayerMac() const { return false; }
</span><span class="cx">     virtual bool isPlatformCALayerRemote() const { return false; }
</span><ins>+    virtual bool isPlatformCALayerRemoteCustom() const { return false; }
</ins><span class="cx"> 
</span><span class="cx">     // This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer
</span><span class="cx">     // is defined differently for Obj C and C++. This allows callers from both languages.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -40,6 +40,8 @@
</span><span class="cx">     // is defined differently for Obj C and C++. This allows callers from both languages.
</span><span class="cx">     static PassRefPtr&lt;PlatformCALayer&gt; create(void* platformLayer, PlatformCALayerClient*);
</span><span class="cx"> 
</span><ins>+    static LayerType layerTypeForPlatformLayer(PlatformLayer*);
+
</ins><span class="cx">     ~PlatformCALayerMac();
</span><span class="cx"> 
</span><span class="cx">     virtual void setOwner(PlatformCALayerClient*) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> #import &quot;WebActionDisablingCALayerDelegate.h&quot;
</span><span class="cx"> #import &quot;WebCoreCALayerExtras.h&quot;
</span><span class="cx"> #import &quot;WebLayer.h&quot;
</span><ins>+#import &quot;WebGLLayer.h&quot;
</ins><span class="cx"> #import &quot;WebTiledBackingLayer.h&quot;
</span><span class="cx"> #import &lt;objc/objc-auto.h&gt;
</span><span class="cx"> #import &lt;objc/runtime.h&gt;
</span><span class="lines">@@ -175,6 +176,17 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PlatformCALayer::LayerType PlatformCALayerMac::layerTypeForPlatformLayer(PlatformLayer* layer)
+{
+    if ([layer isKindOfClass:getAVPlayerLayerClass()])
+        return LayerTypeAVPlayerLayer;
+
+    if ([layer isKindOfClass:[WebGLLayer class]])
+        return LayerTypeWebGLLayer;
+
+    return LayerTypeCustom;
+}
+
</ins><span class="cx"> PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformCALayerClient* owner)
</span><span class="cx">     : PlatformCALayer(layerType, owner)
</span><span class="cx">     , m_customAppearance(GraphicsLayer::NoCustomAppearance)
</span><span class="lines">@@ -206,6 +218,10 @@
</span><span class="cx">     case LayerTypeAVPlayerLayer:
</span><span class="cx">         layerClass = getAVPlayerLayerClass();
</span><span class="cx">         break;
</span><ins>+    case LayerTypeWebGLLayer:
+        // We don't create PlatformCALayerMacs wrapped around WebGLLayers.
+        ASSERT_NOT_REACHED();
+        break;
</ins><span class="cx">     case LayerTypeCustom:
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -217,7 +233,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PlatformCALayerMac::PlatformCALayerMac(PlatformLayer* layer, PlatformCALayerClient* owner)
</span><del>-    : PlatformCALayer([layer isKindOfClass:getAVPlayerLayerClass()] ? LayerTypeAVPlayerLayer : LayerTypeCustom, owner)
</del><ins>+    : PlatformCALayer(layerTypeForPlatformLayer(layer), owner)
</ins><span class="cx">     , m_customAppearance(GraphicsLayer::NoCustomAppearance)
</span><span class="cx">     , m_customBehavior(GraphicsLayer::NoCustomBehavior)
</span><span class="cx"> {
</span><span class="lines">@@ -232,7 +248,7 @@
</span><span class="cx">     [m_layer setValue:[NSValue valueWithPointer:this] forKey:platformCALayerPointer];
</span><span class="cx">     
</span><span class="cx">     // Clear all the implicit animations on the CALayer
</span><del>-    if (m_layerType == LayerTypeAVPlayerLayer || m_layerType == LayerTypeCustom)
</del><ins>+    if (m_layerType == LayerTypeAVPlayerLayer || m_layerType == LayerTypeWebGLLayer || m_layerType == LayerTypeCustom)
</ins><span class="cx">         [m_layer web_disableAllActions];
</span><span class="cx">     else
</span><span class="cx">         [m_layer setDelegate:[WebActionDisablingCALayerDelegate shared]];
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -1,5 +1,51 @@
</span><span class="cx"> 2014-07-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [UI-side compositing] Support reflections on custom layers like video
+        https://bugs.webkit.org/show_bug.cgi?id=134701
+
+        Reviewed by Tim Horton.
+        
+        For video reflections, we have to support cloning of PlatformCALayerRemoteCustom
+        in the web process. Do so by implementing PlatformCALayerRemoteCustom::clone(),
+        which does the right gyrations to get AVPlayerLayers cloned, then makes a
+        new PlatformCALayerRemoteCustom to wrap the new layer. This ends up getting
+        its own context hosting ID, allowing the clone to show in the UI process.
+        
+        Attempt to do the same for WebGL, but turn it off because it breaks.
+
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::drawInContext):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::encode): Unconditionally encode/decode
+        the hostingContextID. It will be 0 for most layers.
+        (WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
+        (WebKit::RemoteLayerTreeTransaction::description):
+        * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
+        (WebKit::RemoteLayerTreeHost::createLayer):
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::createLayer):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::create): Creation with a custom PlatformLayer* always
+        creates a PlatformCALayerRemoteCustom.
+        (WebKit::PlatformCALayerRemote::clone): Factor some code.
+        (WebKit::PlatformCALayerRemote::updateClonedLayerProperties):
+        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h:
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
+        (WebKit::PlatformCALayerRemoteCustom::create):
+        (WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
+        (WebKit::PlatformCALayerRemoteCustom::clone): Clone by making an instance of the 
+        correct type of platform layer when possible, then wrapping a PlatformCALayerRemoteCustom
+        around it.
+        (WebKit::PlatformCALayerRemoteCustom::contents):
+        (WebKit::PlatformCALayerRemoteCustom::setContents):
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::layerWasCreated):
+        (WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):
+
+2014-07-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
</ins><span class="cx">         [UI-side compositing] Crash when starting a filter transition on a reflected layer
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=134694
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -337,6 +337,7 @@
</span><span class="cx">     case PlatformCALayer::LayerTypePageTiledBackingLayer:
</span><span class="cx">     case PlatformCALayer::LayerTypeRootLayer:
</span><span class="cx">     case PlatformCALayer::LayerTypeAVPlayerLayer:
</span><ins>+    case PlatformCALayer::LayerTypeWebGLLayer:
</ins><span class="cx">     case PlatformCALayer::LayerTypeCustom:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         break;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -54,9 +54,7 @@
</span><span class="cx"> {
</span><span class="cx">     encoder &lt;&lt; layerID;
</span><span class="cx">     encoder.encodeEnum(type);
</span><del>-
-    if (type == PlatformCALayer::LayerTypeCustom)
-        encoder &lt;&lt; hostingContextID;
</del><ins>+    encoder &lt;&lt; hostingContextID;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(IPC::ArgumentDecoder&amp; decoder, LayerCreationProperties&amp; result)
</span><span class="lines">@@ -67,10 +65,8 @@
</span><span class="cx">     if (!decoder.decodeEnum(result.type))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (result.type == PlatformCALayer::LayerTypeCustom) {
-        if (!decoder.decode(result.hostingContextID))
-            return false;
-    }
</del><ins>+    if (!decoder.decode(result.hostingContextID))
+        return false;
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -1180,8 +1176,11 @@
</span><span class="cx">                 ts &lt;&lt; &quot;root-layer&quot;;
</span><span class="cx">                 break;
</span><span class="cx">             case PlatformCALayer::LayerTypeAVPlayerLayer:
</span><del>-                ts &lt;&lt; &quot;av-player-layer&quot;;
</del><ins>+                ts &lt;&lt; &quot;av-player-layer (context-id &quot; &lt;&lt; createdLayer.hostingContextID &lt;&lt; &quot;)&quot;;
</ins><span class="cx">                 break;
</span><ins>+            case PlatformCALayer::LayerTypeWebGLLayer:
+                ts &lt;&lt; &quot;web-gl-layer (context-id &quot; &lt;&lt; createdLayer.hostingContextID &lt;&lt; &quot;)&quot;;
+                break;
</ins><span class="cx">             case PlatformCALayer::LayerTypeCustom:
</span><span class="cx">                 ts &lt;&lt; &quot;custom-layer (context-id &quot; &lt;&lt; createdLayer.hostingContextID &lt;&lt; &quot;)&quot;;
</span><span class="cx">                 break;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosRemoteLayerTreeHostIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -152,6 +152,8 @@
</span><span class="cx">         view = adoptNS([[WKTransformView alloc] init]);
</span><span class="cx">         break;
</span><span class="cx">     case PlatformCALayer::LayerTypeCustom:
</span><ins>+    case PlatformCALayer::LayerTypeAVPlayerLayer:
+    case PlatformCALayer::LayerTypeWebGLLayer:
</ins><span class="cx">         if (!m_isDebugLayerTreeHost)
</span><span class="cx">             view = adoptNS([[WKRemoteView alloc] initWithFrame:CGRectZero contextID:properties.hostingContextID]);
</span><span class="cx">         else
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacRemoteLayerTreeHostmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -202,6 +202,8 @@
</span><span class="cx">         layer = adoptNS([[CATransformLayer alloc] init]);
</span><span class="cx">         break;
</span><span class="cx">     case PlatformCALayer::LayerTypeCustom:
</span><ins>+    case PlatformCALayer::LayerTypeAVPlayerLayer:
+    case PlatformCALayer::LayerTypeWebGLLayer:
</ins><span class="cx">         if (!m_isDebugLayerTreeHost)
</span><span class="cx">             layer = WKMakeRenderLayer(properties.hostingContextID);
</span><span class="cx">         else
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemotecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -61,11 +61,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;PlatformCALayerRemote&gt; PlatformCALayerRemote::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext&amp; context)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;PlatformCALayerRemote&gt; layer = adoptRef(new PlatformCALayerRemoteCustom(static_cast&lt;PlatformLayer*&gt;(platformLayer), owner, context));
-
-    context.layerWasCreated(*layer, LayerTypeCustom);
-
-    return layer.release();
</del><ins>+    return PlatformCALayerRemoteCustom::create(platformLayer, owner, context);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;PlatformCALayerRemote&gt; PlatformCALayerRemote::create(const PlatformCALayerRemote&amp; other, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext&amp; context)
</span><span class="lines">@@ -97,32 +93,12 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;PlatformCALayer&gt; PlatformCALayerRemote::clone(PlatformCALayerClient* client) const
</del><ins>+PassRefPtr&lt;PlatformCALayer&gt; PlatformCALayerRemote::clone(PlatformCALayerClient* owner) const
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;PlatformCALayerRemote&gt; clone = PlatformCALayerRemote::create(*this, client, *m_context);
</del><ins>+    RefPtr&lt;PlatformCALayerRemote&gt; clone = PlatformCALayerRemote::create(*this, owner, *m_context);
</ins><span class="cx"> 
</span><del>-    clone-&gt;setPosition(position());
-    clone-&gt;setBounds(bounds());
-    clone-&gt;setAnchorPoint(anchorPoint());
</del><ins>+    updateClonedLayerProperties(*clone);
</ins><span class="cx"> 
</span><del>-    if (m_properties.transform)
-        clone-&gt;setTransform(*m_properties.transform);
-
-    if (m_properties.sublayerTransform)
-        clone-&gt;setSublayerTransform(*m_properties.sublayerTransform);
-
-    clone-&gt;setContents(contents());
-    clone-&gt;setMasksToBounds(masksToBounds());
-    clone-&gt;setDoubleSided(isDoubleSided());
-    clone-&gt;setOpaque(isOpaque());
-    clone-&gt;setBackgroundColor(backgroundColor());
-    clone-&gt;setContentsScale(contentsScale());
-#if ENABLE(CSS_FILTERS)
-    if (m_properties.filters)
-        clone-&gt;copyFiltersFrom(this);
-#endif
-    clone-&gt;updateCustomAppearance(customAppearance());
-
</del><span class="cx">     clone-&gt;setClonedLayer(this);
</span><span class="cx">     return clone.release();
</span><span class="cx"> }
</span><span class="lines">@@ -136,6 +112,33 @@
</span><span class="cx">         m_context-&gt;layerWillBeDestroyed(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PlatformCALayerRemote::updateClonedLayerProperties(PlatformCALayerRemote&amp; clone, bool copyContents) const
+{
+    clone.setPosition(position());
+    clone.setBounds(bounds());
+    clone.setAnchorPoint(anchorPoint());
+
+    if (m_properties.transform)
+        clone.setTransform(*m_properties.transform);
+
+    if (m_properties.sublayerTransform)
+        clone.setSublayerTransform(*m_properties.sublayerTransform);
+
+    if (copyContents)
+        clone.setContents(contents());
+
+    clone.setMasksToBounds(masksToBounds());
+    clone.setDoubleSided(isDoubleSided());
+    clone.setOpaque(isOpaque());
+    clone.setBackgroundColor(backgroundColor());
+    clone.setContentsScale(contentsScale());
+#if ENABLE(CSS_FILTERS)
+    if (m_properties.filters)
+        clone.copyFiltersFrom(this);
+#endif
+    clone.updateCustomAppearance(customAppearance());
+}
+
</ins><span class="cx"> void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeContext&amp; context, RemoteLayerTreeTransaction&amp; transaction)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!m_properties.backingStore || owner());
</span><span class="lines">@@ -156,7 +159,7 @@
</span><span class="cx">                 m_properties.children.append(layer-&gt;layerID());
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (m_layerType == LayerTypeCustom) {
</del><ins>+        if (isPlatformCALayerRemoteCustom()) {
</ins><span class="cx">             RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
</span><span class="cx">             didCommit();
</span><span class="cx">             return;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -171,6 +171,8 @@
</span><span class="cx">     PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext&amp; context);
</span><span class="cx">     PlatformCALayerRemote(const PlatformCALayerRemote&amp;, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&amp;);
</span><span class="cx"> 
</span><ins>+    void updateClonedLayerProperties(PlatformCALayerRemote&amp; clone, bool copyContents = true) const;
+
</ins><span class="cx"> private:
</span><span class="cx">     virtual bool isPlatformCALayerRemote() const override { return true; }
</span><span class="cx">     void ensureBackingStore();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteCustomh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -32,9 +32,12 @@
</span><span class="cx"> 
</span><span class="cx"> class LayerHostingContext;
</span><span class="cx"> 
</span><ins>+// PlatformCALayerRemoteCustom is used for CALayers that live in the web process and are hosted into the UI process via remote context.
</ins><span class="cx"> class PlatformCALayerRemoteCustom final : public PlatformCALayerRemote {
</span><span class="cx">     friend class PlatformCALayerRemote;
</span><span class="cx"> public:
</span><ins>+    static PassRefPtr&lt;PlatformCALayerRemote&gt; create(PlatformLayer *, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&amp;);
+
</ins><span class="cx">     virtual ~PlatformCALayerRemoteCustom();
</span><span class="cx"> 
</span><span class="cx">     virtual PlatformLayer* platformLayer() const override { return m_platformLayer.get(); }
</span><span class="lines">@@ -44,13 +47,22 @@
</span><span class="cx">     virtual void setNeedsDisplay(const WebCore::FloatRect* dirtyRect = 0) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    PlatformCALayerRemoteCustom(PlatformLayer*, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext&amp;);
</del><ins>+    PlatformCALayerRemoteCustom(WebCore::PlatformCALayer::LayerType, PlatformLayer *, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext&amp;);
</ins><span class="cx"> 
</span><ins>+    virtual PassRefPtr&lt;WebCore::PlatformCALayer&gt; clone(WebCore::PlatformCALayerClient* owner) const override;
+
+    virtual bool isPlatformCALayerRemoteCustom() const { return true; }
+
+    virtual CFTypeRef contents() const override;
+    virtual void setContents(CFTypeRef) override;
+
</ins><span class="cx">     std::unique_ptr&lt;LayerHostingContext&gt; m_layerHostingContext;
</span><span class="cx">     RetainPtr&lt;PlatformLayer&gt; m_platformLayer;
</span><span class="cx">     bool m_providesContents;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+PLATFORM_CALAYER_TYPE_CASTS(PlatformCALayerRemoteCustom, isPlatformCALayerRemote())
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PlatformCALayerRemoteCustom_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteCustommm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -30,20 +30,33 @@
</span><span class="cx"> #import &quot;RemoteLayerTreeContext.h&quot;
</span><span class="cx"> #import &quot;RemoteLayerTreePropertyApplier.h&quot;
</span><span class="cx"> #import &quot;WebProcess.h&quot;
</span><ins>+#import &lt;AVFoundation/AVFoundation.h&gt;
</ins><span class="cx"> #import &lt;WebCore/GraphicsLayerCA.h&gt;
</span><span class="cx"> #import &lt;WebCore/PlatformCALayerMac.h&gt;
</span><span class="cx"> #import &lt;WebCore/SoftLinking.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreCALayerExtras.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><ins>+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> static NSString * const platformCALayerPointer = @&quot;WKPlatformCALayer&quot;;
</span><del>-PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom(PlatformLayer* customLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext&amp; context)
-    : PlatformCALayerRemote(LayerTypeCustom, owner, context)
</del><ins>+
+PassRefPtr&lt;PlatformCALayerRemote&gt; PlatformCALayerRemoteCustom::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext&amp; context)
</ins><span class="cx"> {
</span><ins>+    RefPtr&lt;PlatformCALayerRemote&gt; layer = adoptRef(new PlatformCALayerRemoteCustom(PlatformCALayerMac::layerTypeForPlatformLayer(platformLayer), platformLayer, owner, context));
+    context.layerWasCreated(*layer, layer-&gt;layerType());
+
+    return layer.release();
+}
+
+PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom(LayerType layerType, PlatformLayer * customLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext&amp; context)
+    : PlatformCALayerRemote(layerType, owner, context)
+{
</ins><span class="cx">     switch (context.layerHostingMode()) {
</span><span class="cx">     case LayerHostingMode::InProcess:
</span><span class="cx">         m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
</span><span class="lines">@@ -61,7 +74,7 @@
</span><span class="cx">     m_platformLayer = customLayer;
</span><span class="cx">     [customLayer web_disableAllActions];
</span><span class="cx"> 
</span><del>-    m_providesContents = [customLayer isKindOfClass:NSClassFromString(@&quot;WebGLLayer&quot;)];
</del><ins>+    m_providesContents = layerType == LayerTypeWebGLLayer;
</ins><span class="cx"> 
</span><span class="cx">     properties().position = FloatPoint3D(customLayer.position.x, customLayer.position.y, customLayer.zPosition);
</span><span class="cx">     properties().anchorPoint = FloatPoint3D(customLayer.anchorPoint.x, customLayer.anchorPoint.y, customLayer.anchorPointZ);
</span><span class="lines">@@ -79,6 +92,45 @@
</span><span class="cx">     return m_layerHostingContext-&gt;contextID();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;WebCore::PlatformCALayer&gt; PlatformCALayerRemoteCustom::clone(PlatformCALayerClient* owner) const
+{
+    RetainPtr&lt;CALayer *&gt; clonedLayer;
+    bool copyContents = true;
+
+    if (layerType() == LayerTypeAVPlayerLayer) {
+        clonedLayer = adoptNS([[getAVPlayerLayerClass() alloc] init]);
+
+        AVPlayerLayer* destinationPlayerLayer = static_cast&lt;AVPlayerLayer *&gt;(clonedLayer.get());
+        AVPlayerLayer* sourcePlayerLayer = static_cast&lt;AVPlayerLayer *&gt;(platformLayer());
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [destinationPlayerLayer setPlayer:[sourcePlayerLayer player]];
+        });
+        copyContents = false;
+    } else if (layerType() == LayerTypeWebGLLayer) {
+        clonedLayer = adoptNS([[CALayer alloc] init]);
+        // FIXME: currently copying WebGL contents breaks the original layer.
+        copyContents = false;
+    }
+
+    RefPtr&lt;PlatformCALayerRemote&gt; clone = adoptRef(new PlatformCALayerRemoteCustom(layerType(), clonedLayer.get(), owner, *context()));
+    context()-&gt;layerWasCreated(*clone, clone-&gt;layerType());
+
+    updateClonedLayerProperties(*clone, copyContents);
+
+    clone-&gt;setClonedLayer(this);
+    return clone.release();
+}
+
+CFTypeRef PlatformCALayerRemoteCustom::contents() const
+{
+    return [m_platformLayer contents];
+}
+
+void PlatformCALayerRemoteCustom::setContents(CFTypeRef contents)
+{
+    [m_platformLayer setContents:(id)contents];
+}
+
</ins><span class="cx"> void PlatformCALayerRemoteCustom::setNeedsDisplay(const FloatRect* rect)
</span><span class="cx"> {
</span><span class="cx">     if (m_providesContents) {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeContextmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm (170863 => 170864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm        2014-07-07 23:44:58 UTC (rev 170863)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm        2014-07-07 23:44:58 UTC (rev 170864)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">     creationProperties.layerID = layerID;
</span><span class="cx">     creationProperties.type = type;
</span><span class="cx"> 
</span><del>-    if (type == PlatformCALayer::LayerTypeCustom)
</del><ins>+    if (layer.isPlatformCALayerRemoteCustom())
</ins><span class="cx">         creationProperties.hostingContextID = layer.hostingContextID();
</span><span class="cx"> 
</span><span class="cx">     m_createdLayers.append(creationProperties);
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeContext::layerWillBeDestroyed(PlatformCALayerRemote&amp; layer)
</span><span class="cx"> {
</span><ins>+    ASSERT(layer.layerID());
</ins><span class="cx">     GraphicsLayer::PlatformLayerID layerID = layer.layerID();
</span><span class="cx"> 
</span><span class="cx">     m_liveLayers.remove(layerID);
</span></span></pre>
</div>
</div>

</body>
</html>