Simplify WKCACFLayerRenderer's API
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 01:46:53 +0000 (01:46 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 01:46:53 +0000 (01:46 +0000)
createRenderer/destroyRenderer are now hidden behind setHostWindow.
WKCACFLayerRendererClient::animationsStarted has been removed, as it
was never called. (The work it was supposed to do was already being
accomplished by WKCACFLayerRenderer::render telling each layer that
animations are starting.)

Fixes <http://webkit.org/b/52587> WKCACFLayerRenderer is hard to use

Reviewed by Chris Marrin.

Source/WebCore:

* platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
(WebCore::MediaPlayerPrivateFullscreenWindow::createWindow): Moved the
call to setHostWindow here from the WM_CREATE handler. The WM_CREATE
handler was causing the Direct3D device to be created, but MSDN says
you shouldn't create a device while handling WM_CREATE. Removed
no-longer-needed call to createRenderer (setHostWindow does this now)
and the never-needed call to setNeedsDisplay (we never draw into the
root layer; this was just creating an unnecessary backing store the
size of the screen!).
(WebCore::MediaPlayerPrivateFullscreenWindow::wndProc): Moved WM_CREATE
code, as described above. Removed call to destroyRenderer when handling
WM_DESTROY; setHostWindow does this now. Fixed up our WM_PAINT handler
to do a synchronous paint and to clear our dirty region, while I was in
here.

* platform/graphics/win/WKCACFLayerRenderer.cpp:
(WebCore::WKCACFLayerRenderer::~WKCACFLayerRenderer): Changed to call
setHostWindow instead of destroyRenderer; the former calls the latter
if needed.
(WebCore::WKCACFLayerRenderer::setHostWindow): Moved here from the
header file. Destroys our old renderer (i.e., IDirect3DDevice9) if
we're losing our window, or creates a renderer if we're gaining a
window.
(WebCore::WKCACFLayerRenderer::createRenderer): Updated for WKSI function rename.
(WebCore::WKCACFLayerRenderer::destroyRenderer): Changed to clear the
D3D device from our context before releasing the device.

* platform/graphics/win/WKCACFLayerRenderer.h: Removed
WKCACFLayerRendererClient::animationsStarted. Removed setNeedsDisplay.
Make createRenderer, destroyRenderer, and renderSoon private.

WebKit/win:

Update for WKCACFLayerRenderer changes

* WebView.cpp:
(WebView::WebViewWndProc): Removed call to layerRendererBecameVisible
when handling WM_SHOWWINDOW. All this did was try to create the
renderer, but it had already been created in setAcceleratedCompositing,
so wasn't needed.
(WebView::setAcceleratedCompositing): Removed call to createRenderer;
setHostWindow does this for us now.

* WebView.h: Removed animationsStarted and layerRendererBecameVisible.

WebKitLibraries:

Make it possible to both set and clear a wkCACFContext's D3D device

* win/include/WebKitSystemInterface/WebKitSystemInterface.h:
* win/lib/WebKitSystemInterface.lib:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit/win/WebView.h
WebKitLibraries/ChangeLog
WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
WebKitLibraries/win/lib/WebKitSystemInterface.lib

index 8e9d79a..e8fe2cd 100644 (file)
@@ -1,5 +1,50 @@
 2011-01-17  Adam Roben  <aroben@apple.com>
 
+        Simplify WKCACFLayerRenderer's API
+
+        createRenderer/destroyRenderer are now hidden behind setHostWindow.
+        WKCACFLayerRendererClient::animationsStarted has been removed, as it
+        was never called. (The work it was supposed to do was already being
+        accomplished by WKCACFLayerRenderer::render telling each layer that
+        animations are starting.)
+
+        Fixes <http://webkit.org/b/52587> WKCACFLayerRenderer is hard to use
+
+        Reviewed by Chris Marrin.
+
+        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
+        (WebCore::MediaPlayerPrivateFullscreenWindow::createWindow): Moved the
+        call to setHostWindow here from the WM_CREATE handler. The WM_CREATE
+        handler was causing the Direct3D device to be created, but MSDN says
+        you shouldn't create a device while handling WM_CREATE. Removed
+        no-longer-needed call to createRenderer (setHostWindow does this now)
+        and the never-needed call to setNeedsDisplay (we never draw into the
+        root layer; this was just creating an unnecessary backing store the
+        size of the screen!).
+        (WebCore::MediaPlayerPrivateFullscreenWindow::wndProc): Moved WM_CREATE
+        code, as described above. Removed call to destroyRenderer when handling
+        WM_DESTROY; setHostWindow does this now. Fixed up our WM_PAINT handler
+        to do a synchronous paint and to clear our dirty region, while I was in
+        here.
+
+        * platform/graphics/win/WKCACFLayerRenderer.cpp:
+        (WebCore::WKCACFLayerRenderer::~WKCACFLayerRenderer): Changed to call
+        setHostWindow instead of destroyRenderer; the former calls the latter
+        if needed.
+        (WebCore::WKCACFLayerRenderer::setHostWindow): Moved here from the
+        header file. Destroys our old renderer (i.e., IDirect3DDevice9) if
+        we're losing our window, or creates a renderer if we're gaining a
+        window.
+        (WebCore::WKCACFLayerRenderer::createRenderer): Updated for WKSI function rename.
+        (WebCore::WKCACFLayerRenderer::destroyRenderer): Changed to clear the
+        D3D device from our context before releasing the device.
+
+        * platform/graphics/win/WKCACFLayerRenderer.h: Removed
+        WKCACFLayerRendererClient::animationsStarted. Removed setNeedsDisplay.
+        Make createRenderer, destroyRenderer, and renderSoon private.
+
+2011-01-17  Adam Roben  <aroben@apple.com>
+
         Remove special-cased support for providing content for the root layer
 
         Clients will just have to provide content through the normal
index cbe38aa..7abe2eb 100644 (file)
@@ -80,6 +80,10 @@ void MediaPlayerPrivateFullscreenWindow::createWindow(HWND parentHwnd)
         parentHwnd, 0, WebCore::instanceHandle(), this);
     ASSERT(IsWindow(m_hwnd));
 
+#if USE(ACCELERATED_COMPOSITING)
+    m_layerRenderer->setHostWindow(m_hwnd);
+#endif
+
     ::SetFocus(m_hwnd);
 }
 
@@ -139,17 +143,10 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA
     switch (message) {
     case WM_CREATE:
         m_hwnd = hWnd;
-#if USE(ACCELERATED_COMPOSITING)
-        m_layerRenderer->setHostWindow(m_hwnd);
-        m_layerRenderer->createRenderer();
-        if (m_rootChild)
-            m_layerRenderer->setNeedsDisplay();
-#endif
         break;
     case WM_DESTROY:
         m_hwnd = 0;
 #if USE(ACCELERATED_COMPOSITING)
-        m_layerRenderer->destroyRenderer();
         m_layerRenderer->setHostWindow(0);
 #endif
         break;
@@ -169,7 +166,8 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA
         break;
     case WM_PAINT:
 #if USE(ACCELERATED_COMPOSITING)
-        m_layerRenderer->renderSoon();
+        m_layerRenderer->paint();
+        ::ValidateRect(m_hwnd, 0);
 #endif
         break;
     }
index d7e7e13..7c83f86 100644 (file)
@@ -223,11 +223,25 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client)
 
 WKCACFLayerRenderer::~WKCACFLayerRenderer()
 {
-    destroyRenderer();
+    setHostWindow(0);
     WKCACFContextFlusher::shared().removeContext(m_context);
     wkCACFContextDestroy(m_context);
 }
 
+void WKCACFLayerRenderer::setHostWindow(HWND window)
+{
+    if (window == m_hostWindow)
+        return;
+
+    if (m_hostWindow)
+        destroyRenderer();
+
+    m_hostWindow = window;
+
+    if (m_hostWindow)
+        createRenderer();
+}
+
 PlatformCALayer* WKCACFLayerRenderer::rootLayer() const
 {
     return m_rootLayer.get();
@@ -252,17 +266,6 @@ void WKCACFLayerRenderer::layerTreeDidChange()
     renderSoon();
 }
 
-void WKCACFLayerRenderer::setNeedsDisplay(bool sync)
-{
-    ASSERT(m_rootLayer);
-    m_rootLayer->setNeedsDisplay(0);
-
-    if (sync)
-        syncCompositingStateSoon();
-    else
-        renderSoon();
-}
-
 bool WKCACFLayerRenderer::createRenderer()
 {
     if (m_d3dDevice || !m_mightBeAbleToCreateDeviceLater)
@@ -327,7 +330,7 @@ bool WKCACFLayerRenderer::createRenderer()
 
     initD3DGeometry();
 
-    wkCACFContextInitializeD3DDevice(m_context, m_d3dDevice.get());
+    wkCACFContextSetD3DDevice(m_context, m_d3dDevice.get());
 
     if (IsWindow(m_hostWindow))
         m_rootLayer->setBounds(bounds());
@@ -339,6 +342,7 @@ void WKCACFLayerRenderer::destroyRenderer()
 {
     wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer());
 
+    wkCACFContextSetD3DDevice(m_context, 0);
     m_d3dDevice = 0;
     if (s_d3d)
         s_d3d->Release();
index 2da6ac5..02cdbdb 100644 (file)
@@ -54,7 +54,6 @@ class WKCACFLayerRendererClient {
 public:
     virtual ~WKCACFLayerRendererClient() { }
     virtual bool shouldRender() const = 0;
-    virtual void animationsStarted(CFTimeInterval) { }
     virtual void syncCompositingState() { }
 };
 
@@ -72,13 +71,9 @@ public:
 
     void setRootChildLayer(PlatformCALayer*);
     void layerTreeDidChange();
-    void setNeedsDisplay(bool sync = false);
-    void setHostWindow(HWND window) { m_hostWindow = window; }
-    bool createRenderer();
-    void destroyRenderer();
+    void setHostWindow(HWND);
     void paint();
     void resize();
-    void renderSoon();
     void syncCompositingStateSoon();
 
 protected:
@@ -88,6 +83,9 @@ protected:
 private:
     WKCACFLayerRenderer(WKCACFLayerRendererClient*);
 
+    bool createRenderer();
+    void destroyRenderer();
+    void renderSoon();
     void renderTimerFired(Timer<WKCACFLayerRenderer>*);
 
     CGRect bounds() const;
index 12f269c..f26f0f2 100644 (file)
@@ -1,5 +1,23 @@
 2011-01-17  Adam Roben  <aroben@apple.com>
 
+        Update for WKCACFLayerRenderer changes
+
+        Fixes <http://webkit.org/b/52587> WKCACFLayerRenderer is hard to use
+
+        Reviewed by Chris Marrin.
+
+        * WebView.cpp:
+        (WebView::WebViewWndProc): Removed call to layerRendererBecameVisible
+        when handling WM_SHOWWINDOW. All this did was try to create the
+        renderer, but it had already been created in setAcceleratedCompositing,
+        so wasn't needed.
+        (WebView::setAcceleratedCompositing): Removed call to createRenderer;
+        setHostWindow does this for us now.
+
+        * WebView.h: Removed animationsStarted and layerRendererBecameVisible.
+
+2011-01-17  Adam Roben  <aroben@apple.com>
+
         Paint directly into a GraphicsLayer when using accelerated compositing
 
         Before this patch, we were painting into our normal backing store
index f50d7c1..ae91724 100644 (file)
@@ -2135,10 +2135,6 @@ LRESULT CALLBACK WebView::WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam,
                 // Null out our backing store.
                 webView->deleteBackingStore();
             }
-#if USE(ACCELERATED_COMPOSITING)
-            else if (webView->isAcceleratedCompositing())
-                webView->layerRendererBecameVisible();
-#endif
             break;
         case WM_SETFOCUS: {
             COMPtr<IWebUIDelegate> uiDelegate;
@@ -6286,7 +6282,6 @@ void WebView::setAcceleratedCompositing(bool accelerated)
             // Create the root layer
             ASSERT(m_viewWindow);
             m_layerRenderer->setHostWindow(m_viewWindow);
-            m_layerRenderer->createRenderer();
 
             // FIXME: We could perhaps get better performance by never allowing this layer to
             // become tiled (or choosing a higher-than-normal tiling threshold).
@@ -6312,11 +6307,6 @@ void WebView::setAcceleratedCompositing(bool accelerated)
         m_isAcceleratedCompositing = false;
     }
 }
-
-void WebView::layerRendererBecameVisible()
-{
-    m_layerRenderer->createRenderer();
-}
 #endif
 
 HRESULT STDMETHODCALLTYPE WebView::setPluginHalterDelegate(IWebPluginHalterDelegate* d)
@@ -6515,12 +6505,6 @@ bool WebView::shouldRender() const
     return !frameView->layoutPending();
 }
 
-void WebView::animationsStarted(CFTimeInterval t)
-{
-    // Tell the animation controller that its animations have started
-    m_page->mainFrame()->animation()->notifyAnimationStarted(0, t);
-}
-
 void WebView::syncCompositingState()
 {
     Frame* coreFrame = core(m_mainFrame);
index 3bd26f0..f775eaf 100644 (file)
@@ -949,7 +949,6 @@ private:
 
     // WKCACFLayerRendererClient
     virtual bool shouldRender() const;
-    virtual void animationsStarted(CFTimeInterval);
     virtual void syncCompositingState();
 #endif
 
@@ -1056,7 +1055,6 @@ protected:
 #if USE(ACCELERATED_COMPOSITING)
     bool isAcceleratedCompositing() const { return m_isAcceleratedCompositing; }
     void setAcceleratedCompositing(bool);
-    void layerRendererBecameVisible();
 
     OwnPtr<WebCore::WKCACFLayerRenderer> m_layerRenderer;
     OwnPtr<WebCore::GraphicsLayer> m_backingLayer;
index 9d9d930..ca243f4 100644 (file)
@@ -1,3 +1,14 @@
+2011-01-17  Adam Roben  <aroben@apple.com>
+
+        Make it possible to both set and clear a wkCACFContext's D3D device
+
+        Fixes <http://webkit.org/b/52587> WKCACFLayerRenderer is hard to use
+
+        Reviewed by Chris Marrin.
+
+        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
+        * win/lib/WebKitSystemInterface.lib:
+
 2011-01-07  Chris Marrin  <cmarrin@apple.com>
 
         Unreviewed.
index 564d4e8..744f80b 100644 (file)
@@ -152,7 +152,7 @@ void wkCACFContextSetUserData(WKCACFContext*, void*);
 
 void* wkCACFLayerGetContextUserData(CACFLayerRef);
 
-void wkCACFContextInitializeD3DDevice(WKCACFContext*, IDirect3DDevice9*);
+void wkCACFContextSetD3DDevice(WKCACFContext*, IDirect3DDevice9*);
 void wkCACFContextReleaseD3DResources(WKCACFContext*);
 
 bool wkCACFContextBeginUpdate(WKCACFContext*, void* buffer, size_t bufferSize, CFTimeInterval time, const CGRect& bounds, const CGRect dirtyRects[], size_t dirtyRectCount);
index a649d73..f1af3b0 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface.lib differ