Add support for hosting layers in the window server in WebKit2
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 22:53:43 +0000 (22:53 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 22:53:43 +0000 (22:53 +0000)
<rdar://problem/10400246>
https://bugs.webkit.org/show_bug.cgi?id=80310

Reviewed by Anders Carlsson.

Source/JavaScriptCore:

* wtf/Platform.h:
Add HAVE_LAYER_HOSTING_IN_WINDOW_SERVER.

Source/WebKit2:

This currently only works if you are using TiledCoreAnimation drawing model.

* Platform/mac/LayerHostingContext.h: Renamed from Source/WebKit2/Platform/mac/RemoteLayerClient.h.
* Platform/mac/LayerHostingContext.mm: Renamed from Source/WebKit2/Platform/mac/RemoteLayerClient.mm.
(WebKit::LayerHostingContext::createForPort):
(WebKit::LayerHostingContext::LayerHostingContext):
(WebKit::LayerHostingContext::createForWindowServer):
(WebKit::LayerHostingContext::~LayerHostingContext):
(WebKit::LayerHostingContext::setRootLayer):
(WebKit::LayerHostingContext::rootLayer):
(WebKit::LayerHostingContext::contextID):
(WebKit::LayerHostingContext::invalidate):
Renamed RemoteLayerClient to LayerHostingContext and add ability to use the window server
as the remote context.

* PluginProcess/PluginControllerProxy.cpp:
* PluginProcess/PluginControllerProxy.h:
* PluginProcess/mac/PluginControllerProxyMac.mm:
Update for new names.

* Shared/LayerTreeContext.h:
Add LayerHostingMode enum.

* UIProcess/PageClient.h:
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::layerHostingMode):
(WebKit::PageClientImpl::updateAcceleratedCompositingMode):
Add PageClient access points to get the current layer hosting mode,
and a hook to tell the underlying view that the layer hosting context
has changed.

* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView _updateAcceleratedCompositingMode:WebKit::]):
Implement responding to a new layer hosting context as a simple
exit and re-entrance of compositing.

* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::layerHostingModeDidChange):
(WebKit::DrawingAreaProxy::updateAcceleratedCompositingMode):
* UIProcess/DrawingAreaProxy.messages.in:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
(TiledCoreAnimationDrawingAreaProxy):
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::layerHostingModeDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::updateAcceleratedCompositingMode):
Pipe layer hosting changes around.

* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::layerHostingMode):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::viewStateDidChange):
Cache the current layer hosting mode so we don't overzealously
tell the WebProcess to reset its context. Re-check layer hosting
mode each time we are added/removed from a window.

* WebProcess/FullScreen/mac/WebFullScreenManagerMac.h:
* WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm:
Update for new names.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::setDeviceScaleFactor):
(WebKit::DrawingArea::setLayerHostingMode):
* WebProcess/WebPage/DrawingArea.messages.in:
Pipe layer hosting changes around.

* WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h:
* WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm:
(WebKit::LayerTreeHostCAMac::~LayerTreeHostCAMac):
(WebKit::LayerTreeHostCAMac::platformInitialize):
(WebKit::LayerTreeHostCAMac::invalidate):
Update for new names.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::setLayerHostingMode):
Respond to a change in the layer hosting mode by invalidating our old context,
making a new one of the right type, and informing the UIProcess of our new context.

* WebKit2.xcodeproj/project.pbxproj:
Add new files.

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

37 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wtf/Platform.h
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/mac/LayerHostingContext.h [moved from Source/WebKit2/Platform/mac/RemoteLayerClient.h with 64% similarity]
Source/WebKit2/Platform/mac/LayerHostingContext.mm [moved from Source/WebKit2/Platform/mac/RemoteLayerClient.mm with 56% similarity]
Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
Source/WebKit2/PluginProcess/PluginControllerProxy.h
Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm
Source/WebKit2/Shared/LayerTreeContext.h
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
Source/WebKit2/UIProcess/qt/QtPageClient.cpp
Source/WebKit2/UIProcess/qt/QtPageClient.h
Source/WebKit2/UIProcess/win/WebView.cpp
Source/WebKit2/UIProcess/win/WebView.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.h
Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in
Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h
Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index bc4ef9f..57438ea 100644 (file)
@@ -1,3 +1,14 @@
+2012-03-05  Sam Weinig  <sam@webkit.org>
+
+        Add support for hosting layers in the window server in WebKit2
+        <rdar://problem/10400246>
+        https://bugs.webkit.org/show_bug.cgi?id=80310
+
+        Reviewed by Anders Carlsson.
+
+        * wtf/Platform.h:
+        Add HAVE_LAYER_HOSTING_IN_WINDOW_SERVER.
+
 2012-03-05  Filip Pizlo  <fpizlo@apple.com>
 
         Unreviewed, attempted build fix for !ENABLE(JIT) after r109705.
index 32d46b4..1118398 100644 (file)
 #if defined(ENABLE_VIDEO)
 #define ENABLE_VIDEO_TRACK 1
 #endif
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION)
+#define HAVE_LAYER_HOSTING_IN_WINDOW_SERVER 1
+#endif
 #endif /* PLATFORM(MAC) && !PLATFORM(IOS) */
 
 #if PLATFORM(CHROMIUM) && OS(DARWIN)
index 5d63204..d88bf9f 100644 (file)
@@ -1,3 +1,96 @@
+2012-03-05  Sam Weinig  <sam@webkit.org>
+
+        Add support for hosting layers in the window server in WebKit2
+        <rdar://problem/10400246>
+        https://bugs.webkit.org/show_bug.cgi?id=80310
+
+        Reviewed by Anders Carlsson.
+
+        This currently only works if you are using TiledCoreAnimation drawing model.
+
+        * Platform/mac/LayerHostingContext.h: Renamed from Source/WebKit2/Platform/mac/RemoteLayerClient.h.
+        * Platform/mac/LayerHostingContext.mm: Renamed from Source/WebKit2/Platform/mac/RemoteLayerClient.mm.
+        (WebKit::LayerHostingContext::createForPort):
+        (WebKit::LayerHostingContext::LayerHostingContext):
+        (WebKit::LayerHostingContext::createForWindowServer):
+        (WebKit::LayerHostingContext::~LayerHostingContext):
+        (WebKit::LayerHostingContext::setRootLayer):
+        (WebKit::LayerHostingContext::rootLayer):
+        (WebKit::LayerHostingContext::contextID):
+        (WebKit::LayerHostingContext::invalidate):
+        Renamed RemoteLayerClient to LayerHostingContext and add ability to use the window server
+        as the remote context.
+
+        * PluginProcess/PluginControllerProxy.cpp:
+        * PluginProcess/PluginControllerProxy.h:
+        * PluginProcess/mac/PluginControllerProxyMac.mm:
+        Update for new names.
+
+        * Shared/LayerTreeContext.h:
+        Add LayerHostingMode enum.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::layerHostingMode):
+        (WebKit::PageClientImpl::updateAcceleratedCompositingMode):
+        Add PageClient access points to get the current layer hosting mode,
+        and a hook to tell the underlying view that the layer hosting context
+        has changed.
+
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _updateAcceleratedCompositingMode:WebKit::]):
+        Implement responding to a new layer hosting context as a simple
+        exit and re-entrance of compositing.
+
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::layerHostingModeDidChange):
+        (WebKit::DrawingAreaProxy::updateAcceleratedCompositingMode):
+        * UIProcess/DrawingAreaProxy.messages.in:
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+        (TiledCoreAnimationDrawingAreaProxy):
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::layerHostingModeDidChange):
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::updateAcceleratedCompositingMode):
+        Pipe layer hosting changes around.
+
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::layerHostingMode):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::viewStateDidChange):
+        Cache the current layer hosting mode so we don't overzealously
+        tell the WebProcess to reset its context. Re-check layer hosting
+        mode each time we are added/removed from a window.
+
+        * WebProcess/FullScreen/mac/WebFullScreenManagerMac.h:
+        * WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm:
+        Update for new names.
+
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::setDeviceScaleFactor):
+        (WebKit::DrawingArea::setLayerHostingMode):
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        Pipe layer hosting changes around.
+
+        * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h:
+        * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm:
+        (WebKit::LayerTreeHostCAMac::~LayerTreeHostCAMac):
+        (WebKit::LayerTreeHostCAMac::platformInitialize):
+        (WebKit::LayerTreeHostCAMac::invalidate):
+        Update for new names.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+        (WebKit::TiledCoreAnimationDrawingArea::setLayerHostingMode):
+        Respond to a change in the layer hosting mode by invalidating our old context,
+        making a new one of the right type, and informing the UIProcess of our new context.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add new files.
+
 2012-03-05  Anders Carlsson  <andersca@apple.com>
 
         Always update the scroll layer position on the main thread when we have an overlay
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef RemoteLayerClient_h
-#define RemoteLayerClient_h
+#ifndef LayerHostingContext_h
+#define LayerHostingContext_h
 
+#include "LayerTreeContext.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS CALayer;
-
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
-OBJC_CLASS CARemoteLayerClient;
-typedef CARemoteLayerClient *PlatformRemoteLayerClient;
-#else
-typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef;
-typedef WKCARemoteLayerClientRef PlatformRemoteLayerClient;
-#endif
+typedef struct __WKCAContextRef *WKCAContextRef;
 
 namespace WebKit {
 
-class RemoteLayerClient {
-    WTF_MAKE_NONCOPYABLE(RemoteLayerClient);
+class LayerHostingContext {
+    WTF_MAKE_NONCOPYABLE(LayerHostingContext);
 public:
-    static PassOwnPtr<RemoteLayerClient> create(mach_port_t serverPort, CALayer *rootLayer);
-    ~RemoteLayerClient();
+    static PassOwnPtr<LayerHostingContext> createForPort(mach_port_t serverPort);
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+    static PassOwnPtr<LayerHostingContext> createForWindowServer();
+#endif
+    ~LayerHostingContext();
 
-    uint32_t clientID() const;
+    void setRootLayer(CALayer *);
+    CALayer *rootLayer() const;
+
+    uint32_t contextID() const;
     void invalidate();
 
+    LayerHostingMode layerHostingMode() { return m_layerHostingMode; }
+
 private:
-    RemoteLayerClient(mach_port_t serverPort, CALayer *rootLayer);
+    LayerHostingContext(mach_port_t serverPort);
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+    LayerHostingContext();
+#endif
 
-    RetainPtr<PlatformRemoteLayerClient> m_platformClient;
+    LayerHostingMode m_layerHostingMode;
+    RetainPtr<WKCAContextRef> m_context;
 };
 
 } // namespace WebKit
 
-#endif // RemoteLayerClient_h
+#endif // LayerHostingContext_h
  */
 
 #import "config.h"
-#import "RemoteLayerClient.h"
+#import "LayerHostingContext.h"
 
 #import <wtf/PassOwnPtr.h>
-
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
-#import <QuartzCore/CARemoteLayerClient.h>
-#else
 #import <WebKitSystemInterface.h>
-#endif
 
 namespace WebKit {
 
-PassOwnPtr<RemoteLayerClient> RemoteLayerClient::create(mach_port_t serverPort, CALayer *rootLayer)
+PassOwnPtr<LayerHostingContext> LayerHostingContext::createForPort(mach_port_t serverPort)
 {
-    return adoptPtr(new RemoteLayerClient(serverPort, rootLayer));
+    return adoptPtr(new LayerHostingContext(serverPort));
 }
 
-RemoteLayerClient::RemoteLayerClient(mach_port_t serverPort, CALayer *rootLayer)
+LayerHostingContext::LayerHostingContext(mach_port_t serverPort)
 {
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
-    m_platformClient = adoptNS([[CARemoteLayerClient alloc] initWithServerPort:serverPort]);
-    m_platformClient.get().layer = rootLayer;
-#else
-    m_platformClient = WKCARemoteLayerClientMakeWithServerPort(serverPort);
-    WKCARemoteLayerClientSetLayer(m_platformClient.get(), rootLayer);
-#endif
+    m_layerHostingMode = LayerHostingModeDefault;
+    m_context = WKCAContextMakeRemoteWithServerPort(serverPort);
 }
 
-RemoteLayerClient::~RemoteLayerClient()
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+PassOwnPtr<LayerHostingContext> LayerHostingContext::createForWindowServer()
 {
+    return adoptPtr(new LayerHostingContext);
 }
 
-uint32_t RemoteLayerClient::clientID() const
+LayerHostingContext::LayerHostingContext()
 {
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
-    return m_platformClient.get().clientId;
-#else
-    return WKCARemoteLayerClientGetClientId(m_platformClient.get());
+    m_layerHostingMode = LayerHostingModeInWindowServer;
+    m_context = WKCAContextMakeRemoteForWindowServer();
+}
 #endif
+
+LayerHostingContext::~LayerHostingContext()
+{
 }
 
-void RemoteLayerClient::invalidate()
+void LayerHostingContext::setRootLayer(CALayer *rootLayer)
 {
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
-    [m_platformClient.get() invalidate];
-#else
-    WKCARemoteLayerClientInvalidate(m_platformClient.get());
-#endif
+    WKCAContextSetLayer(m_context.get(), rootLayer);
+}
+
+CALayer *LayerHostingContext::rootLayer() const
+{
+    return WKCAContextGetLayer(m_context.get());
+}
+
+uint32_t LayerHostingContext::contextID() const
+{
+    return WKCAContextGetContextId(m_context.get());
+}
+
+void LayerHostingContext::invalidate()
+{
+    WKCAContextInvalidate(m_context.get());
 }
 
 } // namespace WebKit
index 427509b..1fd1b11 100644 (file)
@@ -46,7 +46,7 @@
 #include <wtf/text/WTFString.h>
 
 #if PLATFORM(MAC)
-#include "RemoteLayerClient.h"
+#include "LayerHostingContext.h"
 #endif
 
 using namespace WebCore;
index 2e12464..e860925 100644 (file)
@@ -42,7 +42,7 @@ namespace CoreIPC {
 
 namespace WebKit {
 
-class RemoteLayerClient;
+class LayerHostingContext;
 class ShareableBitmap;
 class WebProcessConnection;
 struct PluginCreationParameters;
@@ -186,7 +186,7 @@ private:
     bool m_isComplexTextInputEnabled;
 
     // For CA plug-ins, this holds the information needed to export the layer hierarchy to the UI process.
-    OwnPtr<RemoteLayerClient> m_remoteLayerClient;
+    OwnPtr<LayerHostingContext> m_layerHostingContext;
 #endif
 
     // The contents scale factor of this plug-in.
index 7bac66a..aa2ea49 100644 (file)
@@ -28,9 +28,9 @@
 
 #if ENABLE(PLUGIN_PROCESS)
 
+#import "LayerHostingContext.h"
 #import "PluginProcess.h"
 #import "PluginProxyMessages.h"
-#import "RemoteLayerClient.h"
 #import "WebProcessConnection.h"
 #import <QuartzCore/QuartzCore.h>
 
@@ -59,25 +59,26 @@ void PluginControllerProxy::platformInitialize()
     if (!platformLayer)
         return;
 
-    ASSERT(!m_remoteLayerClient);
-    m_remoteLayerClient = RemoteLayerClient::create(PluginProcess::shared().compositingRenderServerPort(), platformLayer);
+    ASSERT(!m_layerHostingContext);
+    m_layerHostingContext = LayerHostingContext::createForPort(PluginProcess::shared().compositingRenderServerPort());
+    m_layerHostingContext->setRootLayer(platformLayer);
 }
 
 void PluginControllerProxy::platformDestroy()
 {
-    if (!m_remoteLayerClient)
+    if (!m_layerHostingContext)
         return;
 
-    m_remoteLayerClient->invalidate();
-    m_remoteLayerClient = nullptr;
+    m_layerHostingContext->invalidate();
+    m_layerHostingContext = nullptr;
 }
 
 uint32_t PluginControllerProxy::remoteLayerClientID() const
 {
-    if (!m_remoteLayerClient)
+    if (!m_layerHostingContext)
         return 0;
 
-    return m_remoteLayerClient->clientID();
+    return m_layerHostingContext->contextID();
 }
 
 void PluginControllerProxy::platformGeometryDidChange()
index 2db584e..f33fa97 100644 (file)
@@ -33,6 +33,13 @@ namespace CoreIPC {
 
 namespace WebKit {
 
+enum LayerHostingMode {
+    LayerHostingModeDefault,
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+    LayerHostingModeInWindowServer
+#endif
+};
+
 class LayerTreeContext {
 public:
     LayerTreeContext();
index a56265a..c211629 100644 (file)
@@ -213,6 +213,11 @@ void PageClientImpl::exitAcceleratedCompositingMode()
 {
     notImplemented();
 }
+
+void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
+{
+    notImplemented();
+}
 #endif // USE(ACCELERATED_COMPOSITING)
 
 void PageClientImpl::didChangeScrollbarsForMainFrame() const
index 2522153..40af3b2 100644 (file)
@@ -85,6 +85,7 @@ private:
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     virtual void exitAcceleratedCompositingMode();
+    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
 #endif
 
     virtual void didChangeScrollbarsForMainFrame() const;
index c3ad3f7..9fadbea 100644 (file)
@@ -242,6 +242,11 @@ void PageClientImpl::exitAcceleratedCompositingMode()
 {
     notImplemented();
 }
+
+void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
+{
+    notImplemented();
+}
 #endif // USE(ACCELERATED_COMPOSITING)
 
 void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
index 291ba21..6a1cb24 100644 (file)
@@ -92,6 +92,7 @@ private:
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     virtual void exitAcceleratedCompositingMode();
+    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
 #endif
 
     virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
index dd5a752..dbe947a 100644 (file)
@@ -55,7 +55,8 @@ private:
     virtual bool isViewFocused();
     virtual bool isViewVisible();
     virtual bool isViewInWindow();
-    
+    virtual LayerHostingMode layerHostingMode();
+
     virtual void processDidCrash();
     virtual void pageClosed();
     virtual void didRelaunchProcess();
@@ -91,6 +92,7 @@ private:
 
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     virtual void exitAcceleratedCompositingMode();
+    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
 
     virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&);
 
index b63ec44..71a1a50 100644 (file)
 - (NSCursor *)_cursorRectCursor;
 @end
 
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+@interface NSWindow (WebNSWindowDetails)
+- (BOOL)_hostsLayersInWindowServer;
+@end
+#endif
+
 using namespace WebCore;
 using namespace WebKit;
 
@@ -184,6 +190,18 @@ bool PageClientImpl::isViewInWindow()
     return [m_wkView window];
 }
 
+LayerHostingMode PageClientImpl::layerHostingMode()
+{
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+    if (![m_wkView window])
+        return LayerHostingModeDefault;
+
+    return [[m_wkView window] _hostsLayersInWindowServer] ? LayerHostingModeInWindowServer : LayerHostingModeDefault;
+#else
+    return LayerHostingModeDefault;
+#endif
+}
+
 void PageClientImpl::processDidCrash()
 {
     [m_wkView _processDidCrash];
@@ -337,6 +355,11 @@ void PageClientImpl::exitAcceleratedCompositingMode()
 {
     [m_wkView _exitAcceleratedCompositingMode];
 }
+
+void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+{
+    [m_wkView _updateAcceleratedCompositingMode:layerTreeContext];
+}
 #endif // USE(ACCELERATED_COMPOSITING)
 
 void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
index d5b4a88..b50ce36 100644 (file)
@@ -2459,6 +2459,12 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     _data->_layerHostingView = nullptr;
 }
 
+- (void)_updateAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext
+{
+    [self _exitAcceleratedCompositingMode];
+    [self _enterAcceleratedCompositingMode:layerTreeContext];
+}
+
 - (void)_setAccessibilityWebProcessToken:(NSData *)data
 {
     _data->_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
index fd3e152..83346d3 100644 (file)
@@ -64,6 +64,7 @@ namespace WebKit {
 
 - (void)_enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext;
 - (void)_exitAcceleratedCompositingMode;
+- (void)_updateAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext;
 
 - (void)_setAccessibilityWebProcessToken:(NSData *)data;
 
index 9001acb..8b8dc2b 100644 (file)
@@ -74,6 +74,8 @@ public:
 
     // FIXME: These should be pure virtual.
     virtual void visibilityDidChange() { }
+    virtual void layerHostingModeDidChange() { }
+
     virtual void setBackingStoreIsDiscardable(bool) { }
 
     virtual void waitForBackingStoreUpdateOnNextPaint() { }
@@ -123,6 +125,7 @@ private:
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) { }
     virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) { }
+    virtual void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) { }
 #endif
 #if PLATFORM(MAC)
     virtual void didUpdateGeometry() { }
index e27b5bf..7dbdceb 100644 (file)
@@ -26,6 +26,7 @@ messages -> DrawingAreaProxy {
 #if USE(ACCELERATED_COMPOSITING)
     EnterAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
     ExitAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo)
+    UpdateAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
 #endif
 
 #if PLATFORM(MAC)
index 70ddf07..f06d827 100644 (file)
@@ -93,7 +93,10 @@ public:
 
     // Return whether the view is in a window.
     virtual bool isViewInWindow() = 0;
-    
+
+    // Return the layer hosting mode for the view.
+    virtual LayerHostingMode viewLayerHostingMode() { return LayerHostingModeDefault; }
+
     virtual void processDidCrash() = 0;
     virtual void didRelaunchProcess() = 0;
     virtual void pageClosed() = 0;
@@ -165,6 +168,7 @@ public:
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) = 0;
     virtual void exitAcceleratedCompositingMode() = 0;
+    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) = 0;
 #endif
 
 #if PLATFORM(WIN)
index c3d4122..299ac1c 100644 (file)
@@ -161,6 +161,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p
     , m_pageScaleFactor(1)
     , m_intrinsicDeviceScaleFactor(1)
     , m_customDeviceScaleFactor(0)
+    , m_layerHostingMode(LayerHostingModeDefault)
     , m_drawsBackground(true)
     , m_drawsTransparentBackground(false)
     , m_areMemoryCacheClientCallsEnabled(true)
@@ -760,6 +761,12 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
             m_isInWindow = isInWindow;
             process()->send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID);
         }
+
+        LayerHostingMode layerHostingMode = m_pageClient->viewLayerHostingMode();
+        if (m_layerHostingMode != layerHostingMode) {
+            m_layerHostingMode = layerHostingMode;
+            m_drawingArea->layerHostingModeDidChange();
+        }
     }
 
     updateBackingStoreDiscardableState();
@@ -3357,6 +3364,11 @@ void WebPageProxy::exitAcceleratedCompositingMode()
 {
     m_pageClient->exitAcceleratedCompositingMode();
 }
+
+void WebPageProxy::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+{
+    m_pageClient->updateAcceleratedCompositingMode(layerTreeContext);
+}
 #endif // USE(ACCELERATED_COMPOSITING)
 
 void WebPageProxy::backForwardClear()
index f34de73..5049228 100644 (file)
@@ -38,6 +38,7 @@
 #if PLATFORM(QT)
 #include "QtNetworkRequestData.h"
 #endif
+#include "LayerTreeContext.h"
 #include "NotificationPermissionRequestManagerProxy.h"
 #include "PlatformProcessIdentifier.h"
 #include "SandboxExtension.h"
@@ -432,7 +433,9 @@ public:
     void setIntrinsicDeviceScaleFactor(float);
     void setCustomDeviceScaleFactor(float);
     void windowScreenDidChange(PlatformDisplayID);
-    
+
+    LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
+
     void setUseFixedLayout(bool);
     void setFixedLayoutSize(const WebCore::IntSize&);
     bool useFixedLayout() const { return m_useFixedLayout; };
@@ -531,6 +534,7 @@ public:
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     virtual void exitAcceleratedCompositingMode();
+    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
 #endif
     
     void didDraw();
@@ -945,6 +949,8 @@ private:
     float m_intrinsicDeviceScaleFactor;
     float m_customDeviceScaleFactor;
 
+    LayerHostingMode m_layerHostingMode;
+
     bool m_drawsBackground;
     bool m_drawsTransparentBackground;
 
index 75b95c4..df6c411 100644 (file)
@@ -41,9 +41,12 @@ private:
 
     // DrawingAreaProxy
     virtual void deviceScaleFactorDidChange() OVERRIDE;
+    virtual void layerHostingModeDidChange() OVERRIDE;
     virtual void sizeDidChange() OVERRIDE;
+
     virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) OVERRIDE;
     virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) OVERRIDE;
+    virtual void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) OVERRIDE;
 
     // Message handlers.
     virtual void didUpdateGeometry() OVERRIDE;
index 319bcb4..d8f7d9d 100644 (file)
@@ -56,6 +56,11 @@ void TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange()
     m_webPageProxy->process()->send(Messages::DrawingArea::SetDeviceScaleFactor(m_webPageProxy->deviceScaleFactor()), m_webPageProxy->pageID());
 }
 
+void TiledCoreAnimationDrawingAreaProxy::layerHostingModeDidChange()
+{
+    m_webPageProxy->process()->send(Messages::DrawingArea::SetLayerHostingMode(m_webPageProxy->layerHostingMode()), m_webPageProxy->pageID());
+}
+
 void TiledCoreAnimationDrawingAreaProxy::sizeDidChange()
 {
     if (!m_webPageProxy->isValid())
@@ -87,6 +92,11 @@ void TiledCoreAnimationDrawingAreaProxy::exitAcceleratedCompositingMode(uint64_t
     ASSERT_NOT_REACHED();
 }
 
+void TiledCoreAnimationDrawingAreaProxy::updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
+{
+    m_webPageProxy->updateAcceleratedCompositingMode(layerTreeContext);
+}
+
 void TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry()
 {
     ASSERT(m_isWaitingForDidUpdateGeometry);
index 8d6ebbb..d7049cb 100644 (file)
@@ -289,3 +289,8 @@ void QtPageClient::exitAcceleratedCompositingMode()
     // FIXME: Implement.
 }
 
+void QtPageClient::updateAcceleratedCompositingMode(const LayerTreeContext&)
+{
+    // FIXME: Implement.
+}
+
index f4ffa18..f09db82 100644 (file)
@@ -65,6 +65,7 @@ public:
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     virtual void exitAcceleratedCompositingMode();
+    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
 #endif // USE(ACCELERATED_COMPOSITING)
     virtual void pageClosed() { }
     virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
index c0e9f17..4e4e33f 100644 (file)
@@ -1564,6 +1564,9 @@ void WebView::exitAcceleratedCompositingMode()
 #endif
 }
 
+void WebView::updateAcceleratedCompositingMode(const LayerTreeContext&)
+{
+}
 #endif // USE(ACCELERATED_COMPOSITING)
 
 HWND WebView::nativeWindow()
index ecd7080..daa13c1 100644 (file)
@@ -204,6 +204,7 @@ private:
 #if USE(ACCELERATED_COMPOSITING)
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     virtual void exitAcceleratedCompositingMode();
+    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
 #endif
 
     void didCommitLoadForMainFrame(bool useCustomRepresentation);
index 94516c1..e3ffc85 100644 (file)
                BCDE093B13272496001259FB /* MainMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA31011E3921E00DB1371 /* MainMac.cpp */; };
                BCDE093D13272496001259FB /* PluginProcessShim.dylib in Copy Plug-in Process Shim */ = {isa = PBXBuildFile; fileRef = 1AC25FB012A48EA700BD2671 /* PluginProcessShim.dylib */; };
                BCDE0ABF13272708001259FB /* PluginProcess.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCDE094213272496001259FB /* PluginProcess.app */; };
-               BCE0937714FB128C001138D9 /* RemoteLayerClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCE0937514FB128B001138D9 /* RemoteLayerClient.mm */; };
-               BCE0937814FB128C001138D9 /* RemoteLayerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE0937614FB128B001138D9 /* RemoteLayerClient.h */; };
+               BCE0937714FB128C001138D9 /* LayerHostingContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCE0937514FB128B001138D9 /* LayerHostingContext.mm */; };
+               BCE0937814FB128C001138D9 /* LayerHostingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE0937614FB128B001138D9 /* LayerHostingContext.h */; };
                BCE17B7D1381F1170012A641 /* WKPagePrivateMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE17B7B1381F1170012A641 /* WKPagePrivateMac.cpp */; };
                BCE17B7E1381F1170012A641 /* WKPagePrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE17B7C1381F1170012A641 /* WKPagePrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BCE2315D122C30CA00D5C35A /* WebURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE2315B122C30CA00D5C35A /* WebURLRequest.h */; };
                BCDE059911CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextInjectedBundleClient.h; sourceTree = "<group>"; };
                BCDE059A11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextInjectedBundleClient.cpp; sourceTree = "<group>"; };
                BCDE094213272496001259FB /* PluginProcess.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PluginProcess.app; sourceTree = BUILT_PRODUCTS_DIR; };
-               BCE0937514FB128B001138D9 /* RemoteLayerClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerClient.mm; sourceTree = "<group>"; };
-               BCE0937614FB128B001138D9 /* RemoteLayerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerClient.h; sourceTree = "<group>"; };
+               BCE0937514FB128B001138D9 /* LayerHostingContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LayerHostingContext.mm; sourceTree = "<group>"; };
+               BCE0937614FB128B001138D9 /* LayerHostingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerHostingContext.h; sourceTree = "<group>"; };
                BCE17B7B1381F1170012A641 /* WKPagePrivateMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WKPagePrivateMac.cpp; path = mac/WKPagePrivateMac.cpp; sourceTree = "<group>"; };
                BCE17B7C1381F1170012A641 /* WKPagePrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKPagePrivateMac.h; path = mac/WKPagePrivateMac.h; sourceTree = "<group>"; };
                BCE2315B122C30CA00D5C35A /* WebURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebURLRequest.h; sourceTree = "<group>"; };
                                1A24B5F011F531E800C38269 /* MachUtilities.cpp */,
                                1A24B5F111F531E800C38269 /* MachUtilities.h */,
                                C0E3AA481209E45000A49D01 /* ModuleMac.mm */,
-                               BCE0937514FB128B001138D9 /* RemoteLayerClient.mm */,
-                               BCE0937614FB128B001138D9 /* RemoteLayerClient.h */,
+                               BCE0937514FB128B001138D9 /* LayerHostingContext.mm */,
+                               BCE0937614FB128B001138D9 /* LayerHostingContext.h */,
                                1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */,
                                296BD85B15019BC30071F424 /* StringUtilities.h */,
                                296BD85C15019BC30071F424 /* StringUtilities.mm */,
                                BC2E6E8E1141971500A63B1E /* WorkQueue.h in Headers */,
                                1AB42E8714BBBBB2004272F7 /* KeychainShimResponseMap.h in Headers */,
                                E17BF99614D0A73E00A5A069 /* NetscapeSandboxFunctions.h in Headers */,
-                               BCE0937814FB128C001138D9 /* RemoteLayerClient.h in Headers */,
+                               BCE0937814FB128C001138D9 /* LayerHostingContext.h in Headers */,
                                296BD85D15019BC30071F424 /* StringUtilities.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                                BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */,
                                BC0092F8115837A300E0AE2A /* WorkQueueMac.cpp in Sources */,
                                E17BF99814D0AA8300A5A069 /* NetscapeSandboxFunctions.mm in Sources */,
-                               BCE0937714FB128C001138D9 /* RemoteLayerClient.mm in Sources */,
+                               BCE0937714FB128C001138D9 /* LayerHostingContext.mm in Sources */,
                                296BD85E15019BC30071F424 /* StringUtilities.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
index 33cf3f3..489cc9b 100644 (file)
@@ -38,7 +38,7 @@ OBJC_CLASS WebFullScreenManagerAnimationListener;
 
 namespace WebKit {
 
-class RemoteLayerClient;
+class LayerHostingContext;
 
 class WebFullScreenManagerMac : public WebFullScreenManager {
 public:
@@ -59,7 +59,7 @@ private:
 
     OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
     LayerTreeContext m_layerTreeContext;
-    OwnPtr<RemoteLayerClient> m_remoteLayerClient;
+    OwnPtr<LayerHostingContext> m_layerHostingContext;
     RetainPtr<id> m_enterFullScreenListener;
     RetainPtr<id> m_exitFullScreenListener;
 };
index 36fa19d..a095ad4 100644 (file)
@@ -28,9 +28,9 @@
 #if ENABLE(FULLSCREEN_API)
 
 #import "Connection.h"
+#import "LayerHostingContext.h"
 #import "LayerTreeContext.h"
 #import "MessageID.h"
-#import "RemoteLayerClient.h"
 #import "WebFullScreenManagerProxyMessages.h"
 #import "WebPage.h"
 #import "WebProcess.h"
@@ -163,9 +163,10 @@ void WebFullScreenManagerMac::setRootFullScreenLayer(WebCore::GraphicsLayer* lay
 
         [m_rootLayer->platformLayer() setGeometryFlipped:YES];
 
-        m_remoteLayerClient = RemoteLayerClient::create(WebProcess::shared().compositingRenderServerPort(), m_rootLayer->platformLayer());
-        m_layerTreeContext.contextID = m_remoteLayerClient->clientID();
-
+        m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
+        m_layerHostingContext->setRootLayer(m_rootLayer->platformLayer());
+        
+        m_layerTreeContext.contextID = m_layerHostingContext->contextID();
         m_page->send(Messages::WebFullScreenManagerProxy::EnterAcceleratedCompositingMode(m_layerTreeContext));
     }
 
@@ -181,11 +182,11 @@ void WebFullScreenManagerMac::setRootFullScreenLayer(WebCore::GraphicsLayer* lay
 
 void WebFullScreenManagerMac::disposeOfLayerClient()
 {
-    if (!m_remoteLayerClient)
+    if (!m_layerHostingContext)
         return;
     
-    m_remoteLayerClient->invalidate();
-    m_remoteLayerClient = nullptr;
+    m_layerHostingContext->invalidate();
+    m_layerHostingContext = nullptr;
 }
 
 void WebFullScreenManagerMac::beginEnterFullScreenAnimation(float duration)
index 1ab0ef9..2fa3598 100644 (file)
@@ -106,7 +106,8 @@ private:
 #if PLATFORM(MAC)
     // Used by TiledCoreAnimationDrawingArea.
     virtual void updateGeometry(const WebCore::IntSize& viewSize) { }
-    virtual void setDeviceScaleFactor(float deviceScaleFactor) { }
+    virtual void setDeviceScaleFactor(float) { }
+    virtual void setLayerHostingMode(uint32_t) { }
 #endif
 };
 
index 857f872..0d92a49 100644 (file)
@@ -31,5 +31,6 @@ messages -> DrawingArea {
     // Used by TiledCoreAnimationDrawingArea.
     UpdateGeometry(WebCore::IntSize viewSize)
     SetDeviceScaleFactor(float deviceScaleFactor)
+    SetLayerHostingMode(uint32_t layerHostingMode)
 #endif
 }
index 5559bbd..8f41355 100644 (file)
 #define LayerTreeHostCAMac_h
 
 #include "LayerTreeHostCA.h"
-#include "RemoteLayerClient.h"
 #include <WebCore/LayerFlushScheduler.h>
 #include <WebCore/LayerFlushSchedulerClient.h>
 
 namespace WebKit {
 
+class LayerHostingContext;
+
 class LayerTreeHostCAMac : public LayerTreeHostCA, public WebCore::LayerFlushSchedulerClient {
 public:
     static PassRefPtr<LayerTreeHostCAMac> create(WebPage*);
@@ -59,7 +60,7 @@ private:
     // LayerFlushSchedulerClient
     virtual bool flushLayers();
 
-    OwnPtr<RemoteLayerClient> m_remoteLayerClient;
+    OwnPtr<LayerHostingContext> m_layerHostingContext;
     WebCore::LayerFlushScheduler m_layerFlushScheduler;
 };
 
index 78117eb..e72bd22 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "LayerTreeHostCAMac.h"
 
+#import "LayerHostingContext.h"
 #import "WebProcess.h"
 #import <QuartzCore/CATransaction.h>
 #import <WebCore/GraphicsLayer.h>
@@ -53,13 +54,15 @@ LayerTreeHostCAMac::LayerTreeHostCAMac(WebPage* webPage)
 
 LayerTreeHostCAMac::~LayerTreeHostCAMac()
 {
-    ASSERT(!m_remoteLayerClient);
+    ASSERT(!m_layerHostingContext);
 }
 
 void LayerTreeHostCAMac::platformInitialize(LayerTreeContext& layerTreeContext)
 {
-    m_remoteLayerClient = RemoteLayerClient::create(WebProcess::shared().compositingRenderServerPort(), rootLayer()->platformLayer());
-    layerTreeContext.contextID = m_remoteLayerClient->clientID();
+    m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
+    m_layerHostingContext->setRootLayer(rootLayer()->platformLayer());
+
+    layerTreeContext.contextID = m_layerHostingContext->contextID();
 }
 
 void LayerTreeHostCAMac::scheduleLayerFlush()
@@ -79,8 +82,8 @@ void LayerTreeHostCAMac::invalidate()
 {
     m_layerFlushScheduler.invalidate();
 
-    m_remoteLayerClient->invalidate();
-    m_remoteLayerClient = nullptr;
+    m_layerHostingContext->invalidate();
+    m_layerHostingContext = nullptr;
 
     LayerTreeHostCA::invalidate();
 }
index e913a14..1914ddf 100644 (file)
@@ -27,6 +27,7 @@
 #define TiledCoreAnimationDrawingArea_h
 
 #include "DrawingArea.h"
+#include "LayerTreeContext.h"
 #include <WebCore/GraphicsLayerClient.h>
 #include <WebCore/LayerFlushScheduler.h>
 #include <WebCore/LayerFlushSchedulerClient.h>
@@ -37,7 +38,7 @@ OBJC_CLASS WKContentLayer;
 
 namespace WebKit {
 
-class RemoteLayerClient;
+class LayerHostingContext;
 
 class TiledCoreAnimationDrawingArea : public DrawingArea, WebCore::GraphicsLayerClient, WebCore::LayerFlushSchedulerClient {
 public:
@@ -75,6 +76,7 @@ private:
     // Message handlers.
     virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE;
     virtual void setDeviceScaleFactor(float) OVERRIDE;
+    virtual void setLayerHostingMode(uint32_t) OVERRIDE;
 
     void setRootCompositingLayer(CALayer *);
 
@@ -84,7 +86,9 @@ private:
     bool m_layerTreeStateIsFrozen;
     WebCore::LayerFlushScheduler m_layerFlushScheduler;
 
-    OwnPtr<RemoteLayerClient> m_remoteLayerClient;
+    OwnPtr<LayerHostingContext> m_layerHostingContext;
+    LayerHostingMode m_layerHostingMode;
+    
     RetainPtr<CALayer> m_rootLayer;
     RetainPtr<CALayer> m_pendingRootCompositingLayer;
 
index dcceffd..913dd8b 100644 (file)
@@ -28,8 +28,8 @@
 
 #import "DrawingAreaProxyMessages.h"
 #import "EventDispatcher.h"
+#import "LayerHostingContext.h"
 #import "LayerTreeContext.h"
-#import "RemoteLayerClient.h"
 #import "WebPage.h"
 #import "WebProcess.h"
 #import <QuartzCore/QuartzCore.h>
@@ -76,10 +76,11 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, c
     m_rootLayer.get().opaque = YES;
     m_rootLayer.get().geometryFlipped = YES;
 
-    m_remoteLayerClient = RemoteLayerClient::create(WebProcess::shared().compositingRenderServerPort(), m_rootLayer.get());
-
+    m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
+    m_layerHostingContext->setRootLayer(m_rootLayer.get());
+    
     LayerTreeContext layerTreeContext;
-    layerTreeContext.contextID = m_remoteLayerClient->clientID();
+    layerTreeContext.contextID = m_layerHostingContext->contextID();
     m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(0, layerTreeContext));
 }
 
@@ -253,6 +254,37 @@ void TiledCoreAnimationDrawingArea::setDeviceScaleFactor(float deviceScaleFactor
     m_webPage->setDeviceScaleFactor(deviceScaleFactor);
 }
 
+void TiledCoreAnimationDrawingArea::setLayerHostingMode(uint32_t opaqueLayerHostingMode)
+{
+    LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode);
+    if (layerHostingMode != m_layerHostingContext->layerHostingMode()) {
+        // The mode has changed.
+        
+        // First, invalidate the old hosting context.
+        m_layerHostingContext->invalidate();
+        m_layerHostingContext = nullptr;
+
+        // Create a new context and set it up.
+        switch (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(m_rootLayer.get());
+
+        // Finally, inform the UIProcess that the context has changed.
+        LayerTreeContext layerTreeContext;
+        layerTreeContext.contextID = m_layerHostingContext->contextID();
+        m_webPage->send(Messages::DrawingAreaProxy::UpdateAcceleratedCompositingMode(0, layerTreeContext));
+    }
+}
+
 void TiledCoreAnimationDrawingArea::setRootCompositingLayer(CALayer *layer)
 {
     ASSERT(!m_layerTreeStateIsFrozen);