Remote Layer Tree: Make LayerTypeCustom remote-host CALayers from the Web process
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2013 05:52:45 +0000 (05:52 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2013 05:52:45 +0000 (05:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123766

Reviewed by Anders Carlsson.

Put each LayerTypeCustom layer into a CAContext, so that we can
host small CALayer trees (for video, plugins, etc.) from the Web process
to the UI process without proxying their (more complex) content.

* Shared/mac/RemoteLayerTreeTransaction.h:
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
(WebKit::RemoteLayerTreeTransaction::dump):
Store, encode, and dump the CAContext ID of custom layers.

* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::createLayer):
Create a CALayerHost with the CAContext ID from the Web process.

* WebKit2.xcodeproj/project.pbxproj:
Add PlatformCALayerRemoteCustom.

* WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
(WebKit::GraphicsLayerCARemote::createPlatformCALayer):
Call the newly-added custom-layer constructor.

* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(PlatformCALayerRemote::create):
(PlatformCALayerRemote::PlatformCALayerRemote):
Move the call to layerWasCreated() out to ::create(), so that all of
the constructors for this class and all subclasses have completed
before we call it (so that layerWasCreated() can store the context ID
in the created layer properties object).

(WebKit::PlatformCALayerRemote::hostingContextID):
Should never be reached on the base class, only PlatformCALayerRemoteCustom.

* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.cpp: Added.
(PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
(PlatformCALayerRemoteCustom::~PlatformCALayerRemoteCustom):
(PlatformCALayerRemoteCustom::hostingContextID):
* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h: Added.
Add PlatformCALayerRemoteCustom, which owns a LayerHostingContext
which it will use to share a custom CALayer tree with the UI process.

* WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
Drive-by remove an unnecessary include.

* WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::layerWasCreated):
Store the CAContext ID with the layer creation properties so it can
be used to create a CALayerHost upon commit in the UI process.

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

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm

index deaa522..a9a2b62 100644 (file)
@@ -1,5 +1,62 @@
 2013-11-04  Tim Horton  <timothy_horton@apple.com>
 
+        Remote Layer Tree: Make LayerTypeCustom remote-host CALayers from the Web process
+        https://bugs.webkit.org/show_bug.cgi?id=123766
+
+        Reviewed by Anders Carlsson.
+
+        Put each LayerTypeCustom layer into a CAContext, so that we can
+        host small CALayer trees (for video, plugins, etc.) from the Web process
+        to the UI process without proxying their (more complex) content.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::encode):
+        (WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
+        (WebKit::RemoteLayerTreeTransaction::dump):
+        Store, encode, and dump the CAContext ID of custom layers.
+
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::createLayer):
+        Create a CALayerHost with the CAContext ID from the Web process.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add PlatformCALayerRemoteCustom.
+
+        * WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
+        (WebKit::GraphicsLayerCARemote::createPlatformCALayer):
+        Call the newly-added custom-layer constructor.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (PlatformCALayerRemote::create):
+        (PlatformCALayerRemote::PlatformCALayerRemote):
+        Move the call to layerWasCreated() out to ::create(), so that all of
+        the constructors for this class and all subclasses have completed
+        before we call it (so that layerWasCreated() can store the context ID
+        in the created layer properties object).
+
+        (WebKit::PlatformCALayerRemote::hostingContextID):
+        Should never be reached on the base class, only PlatformCALayerRemoteCustom.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.cpp: Added.
+        (PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
+        (PlatformCALayerRemoteCustom::~PlatformCALayerRemoteCustom):
+        (PlatformCALayerRemoteCustom::hostingContextID):
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h: Added.
+        Add PlatformCALayerRemoteCustom, which owns a LayerHostingContext
+        which it will use to share a custom CALayer tree with the UI process.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
+        Drive-by remove an unnecessary include.
+
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::layerWasCreated):
+        Store the CAContext ID with the layer creation properties so it can
+        be used to create a CALayerHost upon commit in the UI process.
+
+2013-11-04  Tim Horton  <timothy_horton@apple.com>
+
         Remove PlatformCALayer::playerLayer
         https://bugs.webkit.org/show_bug.cgi?id=123764
 
index 750f8a5..8e09938 100644 (file)
@@ -87,6 +87,8 @@ public:
 
         LayerID layerID;
         WebCore::PlatformCALayer::LayerType type;
+
+        uint32_t hostingContextID;
     };
 
     struct LayerProperties {
index 5db63cd..7ef4d15 100644 (file)
@@ -47,6 +47,9 @@ void RemoteLayerTreeTransaction::LayerCreationProperties::encode(CoreIPC::Argume
 {
     encoder << layerID;
     encoder.encodeEnum(type);
+
+    if (type == PlatformCALayer::LayerTypeCustom)
+        encoder << hostingContextID;
 }
 
 bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(CoreIPC::ArgumentDecoder& decoder, LayerCreationProperties& result)
@@ -57,6 +60,11 @@ bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(CoreIPC::Argume
     if (!decoder.decodeEnum(result.type))
         return false;
 
+    if (result.type == PlatformCALayer::LayerTypeCustom) {
+        if (!decoder.decode(result.hostingContextID))
+            return false;
+    }
+
     return true;
 }
 
@@ -684,7 +692,7 @@ void RemoteLayerTreeTransaction::dump() const
                 ts << "av-player-layer";
                 break;
             case PlatformCALayer::LayerTypeCustom:
-                ts << "custom-layer";
+                ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
                 break;
             }
             ts << " " << createdLayer.layerID << ")";
index 494f059..a1cba05 100644 (file)
@@ -33,6 +33,7 @@
 #import "WebProcessProxy.h"
 #import <WebCore/PlatformCAFilters.h>
 #import <WebCore/PlatformLayer.h>
+#import <WebKitSystemInterface.h>
 
 #import <QuartzCore/QuartzCore.h>
 
@@ -241,6 +242,9 @@ CALayer *RemoteLayerTreeHost::createLayer(RemoteLayerTreeTransaction::LayerCreat
     case PlatformCALayer::LayerTypeTransformLayer:
         layer = adoptNS([[CATransformLayer alloc] init]);
         break;
+    case PlatformCALayer::LayerTypeCustom:
+        layer = WKMakeRenderLayer(properties.hostingContextID);
+        break;
     default:
         ASSERT_NOT_REACHED();
     }
index d261e74..13b6ebe 100644 (file)
                2D47B56C1810714E003A3AEE /* RemoteLayerBackingStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */; };
                2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */; };
                2D870D1016234FFE000A3F20 /* PDFPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */; };
+               2D8710161828415D0018FA01 /* PlatformCALayerRemoteCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8710141828415D0018FA01 /* PlatformCALayerRemoteCustom.cpp */; };
+               2D8710171828415D0018FA01 /* PlatformCALayerRemoteCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */; };
                2D8949F0182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8949EE182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp */; };
                2D8949F1182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8949EF182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h */; };
                2DA049B3180CCCD300AAFA9E /* PlatformCALayerRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */; };
                2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerBackingStore.h; sourceTree = "<group>"; };
                2D870D0D1622B7F9000A3F20 /* PDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPlugin.h; path = PDF/PDFPlugin.h; sourceTree = "<group>"; };
                2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPlugin.mm; path = PDF/PDFPlugin.mm; sourceTree = "<group>"; };
+               2D8710141828415D0018FA01 /* PlatformCALayerRemoteCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemoteCustom.cpp; sourceTree = "<group>"; };
+               2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteCustom.h; sourceTree = "<group>"; };
                2D8949EE182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemoteTiledBacking.cpp; sourceTree = "<group>"; };
                2D8949EF182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteTiledBacking.h; sourceTree = "<group>"; };
                2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemote.cpp; sourceTree = "<group>"; };
                                2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */,
                                2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */,
                                2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */,
+                               2D8710141828415D0018FA01 /* PlatformCALayerRemoteCustom.cpp */,
+                               2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */,
                                2D8949EE182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp */,
                                2D8949EF182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h */,
                                1AB16AE8164B3A8800290D62 /* RemoteLayerTreeContext.h */,
                                BC032DB910F4380F0058C15A /* WebEvent.h in Headers */,
                                BC032DBB10F4380F0058C15A /* WebEventConversion.h in Headers */,
                                BC111B5D112F629800337BAB /* WebEventFactory.h in Headers */,
+                               2D8710171828415D0018FA01 /* PlatformCALayerRemoteCustom.h in Headers */,
                                1A3DD202125E5A1F004515E6 /* WebFindClient.h in Headers */,
                                1A90C1EE1264FD50003E44D4 /* WebFindOptions.h in Headers */,
                                BCE469541214E6CB000B98EB /* WebFormClient.h in Headers */,
                                F036978515F4BE6B00C3A80E /* WKColorPickerResultListener.cpp in Sources */,
                                BCA284D61492F2C7001F9042 /* WKConnection.mm in Sources */,
                                BC4A6296147313A0006C681A /* WKConnectionRef.cpp in Sources */,
+                               2D8710161828415D0018FA01 /* PlatformCALayerRemoteCustom.cpp in Sources */,
                                BCB9E24C1120E15C00A137E0 /* WKContext.cpp in Sources */,
                                51A555F5128C6C47009ABCEC /* WKContextMenuItem.cpp in Sources */,
                                9FB5F394169E6A80002C25BF /* WKContextPrivateMac.mm in Sources */,
index a2c98dd..0d81f17 100644 (file)
@@ -50,11 +50,9 @@ PassRefPtr<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(Platfor
     return PlatformCALayerRemote::create(layerType, owner, m_context);
 }
 
-PassRefPtr<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(PlatformLayer*, PlatformCALayerClient*)
+PassRefPtr<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(PlatformLayer* platformLayer, PlatformCALayerClient* owner)
 {
-    ASSERT_NOT_REACHED();
-
-    return nullptr;
+    return PlatformCALayerRemote::create(platformLayer, owner, m_context);
 }
 
 }
index 3f79eae..80bf288 100644 (file)
@@ -29,6 +29,7 @@
 
 #import "PlatformCALayerRemote.h"
 
+#import "PlatformCALayerRemoteCustom.h"
 #import "PlatformCALayerRemoteTiledBacking.h"
 #import "RemoteLayerBackingStore.h"
 #import "RemoteLayerTreeContext.h"
@@ -59,10 +60,25 @@ static PlatformCALayerRemote* toPlatformCALayerRemote(PlatformCALayer* layer)
 
 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::create(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
 {
+    RefPtr<PlatformCALayerRemote> layer;
+
     if (layerType == LayerTypeTiledBackingLayer ||  layerType == LayerTypePageTiledBackingLayer)
-        return adoptRef(new PlatformCALayerRemoteTiledBacking(layerType, owner, context));
+        layer = adoptRef(new PlatformCALayerRemoteTiledBacking(layerType, owner, context));
+    else
+        layer = adoptRef(new PlatformCALayerRemote(layerType, owner, context));
+
+    context->layerWasCreated(layer.get(), layerType);
+
+    return layer.release();
+}
+
+PassRefPtr<PlatformCALayer> PlatformCALayerRemote::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
+{
+    RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemoteCustom(static_cast<PlatformLayer*>(platformLayer), owner, context));
 
-    return adoptRef(new PlatformCALayerRemote(layerType, owner, context));
+    context->layerWasCreated(layer.get(), LayerTypeCustom);
+
+    return layer.release();
 }
 
 PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
@@ -74,8 +90,6 @@ PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALaye
 {
     // FIXME: match all default values from CA.
     setContentsScale(1);
-
-    m_context->layerWasCreated(this, layerType);
 }
 
 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* owner) const
@@ -481,4 +495,10 @@ PassRefPtr<PlatformCALayer> PlatformCALayerRemote::createCompatibleLayer(Platfor
     return PlatformCALayerRemote::create(layerType, client, m_context);
 }
 
+uint32_t PlatformCALayerRemote::hostingContextID()
+{
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
 #endif // USE(ACCELERATED_COMPOSITING)
index c74e0be..9b1b643 100644 (file)
@@ -40,6 +40,7 @@ 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*);
 
     virtual ~PlatformCALayerRemote();
 
@@ -145,6 +146,8 @@ public:
 
     virtual PassRefPtr<PlatformCALayer> createCompatibleLayer(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient*) const OVERRIDE;
 
+    virtual uint32_t hostingContextID();
+
 protected:
     PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context);
 
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.cpp b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.cpp
new file mode 100644 (file)
index 0000000..32bc5eb
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#import "PlatformCALayerRemoteCustom.h"
+
+#import "LayerHostingContext.h"
+#import "RemoteLayerTreeContext.h"
+#import "WebProcess.h"
+#import <WebCore/GraphicsLayerCA.h>
+#import <WebCore/PlatformCALayerMac.h>
+#import <WebCore/SoftLinking.h>
+#import <wtf/RetainPtr.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom(PlatformLayer* customLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
+    : PlatformCALayerRemote(LayerTypeCustom, owner, context)
+{
+    switch (context->layerHostingMode()) {
+    case LayerHostingModeDefault:
+        m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
+        break;
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+    case LayerHostingModeInWindowServer:
+        m_layerHostingContext = LayerHostingContext::createForWindowServer();
+        break;
+#endif
+    }
+
+    m_layerHostingContext->setRootLayer(customLayer);
+
+    m_platformLayer = customLayer;
+}
+
+PlatformCALayerRemoteCustom::~PlatformCALayerRemoteCustom()
+{
+}
+
+uint32_t PlatformCALayerRemoteCustom::hostingContextID()
+{
+    return m_layerHostingContext->contextID();
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h
new file mode 100644 (file)
index 0000000..f64aa21
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformCALayerRemoteCustom_h
+#define PlatformCALayerRemoteCustom_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "PlatformCALayerRemote.h"
+
+namespace WebKit {
+
+class LayerHostingContext;
+
+class PlatformCALayerRemoteCustom FINAL : public PlatformCALayerRemote {
+    friend class PlatformCALayerRemote;
+public:
+    virtual ~PlatformCALayerRemoteCustom();
+
+    virtual PlatformLayer* platformLayer() const OVERRIDE { return m_platformLayer.get(); }
+
+    virtual uint32_t hostingContextID() OVERRIDE;
+
+private:
+    PlatformCALayerRemoteCustom(PlatformLayer*, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext*);
+
+    std::unique_ptr<LayerHostingContext> m_layerHostingContext;
+    RetainPtr<PlatformLayer> m_platformLayer;
+};
+
+} // namespace WebKit
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // PlatformCALayerRemoteCustom_h
index 74373e8..cf41c27 100644 (file)
@@ -33,7 +33,6 @@
 #import <WebCore/GraphicsLayerCA.h>
 #import <WebCore/PlatformCALayerMac.h>
 #import <WebCore/TiledBacking.h>
-#import <wtf/CurrentTime.h>
 #import <wtf/RetainPtr.h>
 
 using namespace WebCore;
index 7f19e64..d995b52 100644 (file)
@@ -26,7 +26,9 @@
 #ifndef RemoteLayerTreeContext_h
 #define RemoteLayerTreeContext_h
 
+#include "LayerTreeContext.h"
 #include "RemoteLayerTreeTransaction.h"
+#include "WebPage.h"
 #include <WebCore/GraphicsLayerFactory.h>
 #include <WebCore/PlatformCALayer.h>
 #include <WebCore/Timer.h>
@@ -49,6 +51,8 @@ public:
     void layerWasCreated(PlatformCALayerRemote*, WebCore::PlatformCALayer::LayerType);
     void layerWillBeDestroyed(PlatformCALayerRemote*);
 
+    LayerHostingMode layerHostingMode() const { return m_webPage->layerHostingMode(); }
+
 private:
     // WebCore::GraphicsLayerFactory
     virtual std::unique_ptr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE;
index 6078d77..f57a612 100644 (file)
@@ -65,6 +65,10 @@ void RemoteLayerTreeContext::layerWasCreated(PlatformCALayerRemote* layer, Platf
     RemoteLayerTreeTransaction::LayerCreationProperties creationProperties;
     creationProperties.layerID = layer->layerID();
     creationProperties.type = type;
+
+    if (type == PlatformCALayer::LayerTypeCustom)
+        creationProperties.hostingContextID = layer->hostingContextID();
+
     m_createdLayers.append(creationProperties);
 }