Title: [114800] trunk/Source
Revision
114800
Author
[email protected]
Date
2012-04-20 16:49:41 -0700 (Fri, 20 Apr 2012)

Log Message

[chromium] Plumb a compositor surface ready notification through to the threaded compositor
https://bugs.webkit.org/show_bug.cgi?id=84305

Patch by James Robinson <[email protected]> on 2012-04-20
Reviewed by Adrienne Walker.

Source/Platform:

Add a notification for when the compositor surface associated with a given view is ready to use.

* chromium/public/WebLayerTreeView.h:
(WebLayerTreeView):

Source/WebCore:

Plumb setSurfaceReady through to the scheduler.

* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::setSurfaceReady):
(WebCore):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):
* platform/graphics/chromium/cc/CCProxy.h:
(CCProxy):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::setSurfaceReady):
(WebCore):
* platform/graphics/chromium/cc/CCSingleThreadProxy.h:
(CCSingleThreadProxy):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::setSurfaceReady):
(WebCore):
(WebCore::CCThreadProxy::setSurfaceReadyOnImplThread):
(WebCore::CCThreadProxy::initializeImplOnImplThread):
* platform/graphics/chromium/cc/CCThreadProxy.h:
(CCThreadProxy):

Source/WebKit/chromium:

Adds a notification to WebWidget for when the compositor surface is ready to use. This exists to fix a race
condition when WebKit requires that we enter compositing mode but we haven't completed initialization of the
native window/etc backing the WebWidget, and we can't block for this initialization to complete without inducing
deadlocks. In this situation, we proceed as usual except that we can't attempt to use the compositor context or
it will fail.

* public/WebWidget.h:
(WebWidget):
* src/WebLayerTreeView.cpp:
(WebKit::WebLayerTreeView::setSurfaceReady):
(WebKit):
* src/WebPagePopupImpl.cpp:
(WebKit::WebPagePopupImpl::setCompositorSurfaceReady):
(WebKit):
* src/WebPagePopupImpl.h:
(WebPagePopupImpl):
* src/WebPopupMenuImpl.cpp:
(WebKit::WebPopupMenuImpl::setCompositorSurfaceReady):
(WebKit):
* src/WebPopupMenuImpl.h:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setCompositorSurfaceReady):
(WebKit):
(WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
* src/WebViewImpl.h:
(WebViewImpl):

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (114799 => 114800)


--- trunk/Source/Platform/ChangeLog	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/Platform/ChangeLog	2012-04-20 23:49:41 UTC (rev 114800)
@@ -1,3 +1,15 @@
+2012-04-20  James Robinson  <[email protected]>
+
+        [chromium] Plumb a compositor surface ready notification through to the threaded compositor
+        https://bugs.webkit.org/show_bug.cgi?id=84305
+
+        Reviewed by Adrienne Walker.
+
+        Add a notification for when the compositor surface associated with a given view is ready to use.
+
+        * chromium/public/WebLayerTreeView.h:
+        (WebLayerTreeView):
+
 2012-04-16  James Robinson  <[email protected]>
 
         [chromium] Convert WebPluginContainerImpl over to use WebExternalTextureLayer

Modified: trunk/Source/Platform/chromium/public/WebLayerTreeView.h (114799 => 114800)


--- trunk/Source/Platform/chromium/public/WebLayerTreeView.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/Platform/chromium/public/WebLayerTreeView.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -85,6 +85,11 @@
     // Must be called before any methods below.
     WEBKIT_EXPORT bool initialize(WebLayerTreeViewClient*, const WebLayer& root, const Settings&);
 
+    // Indicates that the compositing surface used by this WebLayerTreeView is ready to use.
+    // A WebLayerTreeView may request a context from its client before the surface is ready,
+    // but it won't attempt to use it.
+    WEBKIT_EXPORT void setSurfaceReady();
+
     // Sets the root of the tree. The root is set by way of the constructor.
     // This is typically used to explicitly set the root to null to break
     // cycles.

Modified: trunk/Source/WebCore/ChangeLog (114799 => 114800)


--- trunk/Source/WebCore/ChangeLog	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/ChangeLog	2012-04-20 23:49:41 UTC (rev 114800)
@@ -1,3 +1,32 @@
+2012-04-20  James Robinson  <[email protected]>
+
+        [chromium] Plumb a compositor surface ready notification through to the threaded compositor
+        https://bugs.webkit.org/show_bug.cgi?id=84305
+
+        Reviewed by Adrienne Walker.
+
+        Plumb setSurfaceReady through to the scheduler.
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::setSurfaceReady):
+        (WebCore):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (CCLayerTreeHost):
+        * platform/graphics/chromium/cc/CCProxy.h:
+        (CCProxy):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::setSurfaceReady):
+        (WebCore):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
+        (CCSingleThreadProxy):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::setSurfaceReady):
+        (WebCore):
+        (WebCore::CCThreadProxy::setSurfaceReadyOnImplThread):
+        (WebCore::CCThreadProxy::initializeImplOnImplThread):
+        * platform/graphics/chromium/cc/CCThreadProxy.h:
+        (CCThreadProxy):
+
 2012-04-20  Mark Pilgrim  <[email protected]>
 
         [Chromium] Call memoryUsageMB directly

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (114799 => 114800)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -123,6 +123,11 @@
     numLayerTreeInstances--;
 }
 
+void CCLayerTreeHost::setSurfaceReady()
+{
+    m_proxy->setSurfaceReady();
+}
+
 void CCLayerTreeHost::initializeLayerRenderer()
 {
     TRACE_EVENT("CCLayerTreeHost::initializeLayerRenderer", this, 0);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (114799 => 114800)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -128,6 +128,8 @@
     static PassOwnPtr<CCLayerTreeHost> create(CCLayerTreeHostClient*, const CCSettings&);
     virtual ~CCLayerTreeHost();
 
+    void setSurfaceReady();
+
     // Returns true if any CCLayerTreeHost is alive.
     static bool anyLayerTreeHostInstanceExists();
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h (114799 => 114800)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -67,6 +67,9 @@
     // The context will not be used and no frames may be produced until initializeLayerRenderer() is called.
     virtual bool initializeContext() = 0;
 
+    // Indicates that the compositing surface associated with our context is ready to use.
+    virtual void setSurfaceReady() = 0;
+
     // Attempts to initialize the layer renderer. Returns false if the context isn't usable for compositing.
     virtual bool initializeLayerRenderer() = 0;
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (114799 => 114800)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -126,6 +126,11 @@
     return true;
 }
 
+void CCSingleThreadProxy::setSurfaceReady()
+{
+    // Scheduling is controlled by the embedder in the single thread case, so nothing to do.
+}
+
 bool CCSingleThreadProxy::initializeLayerRenderer()
 {
     ASSERT(CCProxy::isMainThread());

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h (114799 => 114800)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -48,6 +48,7 @@
     virtual void finishAllRendering() OVERRIDE;
     virtual bool isStarted() const OVERRIDE;
     virtual bool initializeContext() OVERRIDE;
+    virtual void setSurfaceReady() OVERRIDE;
     virtual bool initializeLayerRenderer() OVERRIDE;
     virtual bool recreateContext() OVERRIDE;
     virtual int compositorIdentifier() const OVERRIDE { return m_compositorIdentifier; }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (114799 => 114800)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -180,6 +180,18 @@
     return true;
 }
 
+void CCThreadProxy::setSurfaceReady()
+{
+    TRACE_EVENT0("cc", "CCThreadProxy::setSurfaceReady");
+    CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::setSurfaceReadyOnImplThread));
+}
+
+void CCThreadProxy::setSurfaceReadyOnImplThread()
+{
+    TRACE_EVENT0("cc", "CCThreadProxy::setSurfaceReadyOnImplThread");
+    m_schedulerOnImplThread->setCanBeginFrame(true);
+}
+
 bool CCThreadProxy::initializeLayerRenderer()
 {
     TRACE_EVENT("CCThreadProxy::initializeLayerRenderer", this, 0);
@@ -711,7 +723,6 @@
     const double displayRefreshInterval = 1.0 / 60.0;
     OwnPtr<CCFrameRateController> frameRateController = adoptPtr(new CCFrameRateController(CCDelayBasedTimeSource::create(displayRefreshInterval, CCProxy::implThread())));
     m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.release());
-    m_schedulerOnImplThread->setCanBeginFrame(true); // FIXME: Set this when we actually can begin a frame.
     m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
 
     m_inputHandlerOnImplThread = CCInputHandler::create(m_layerTreeHostImpl.get());

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h (114799 => 114800)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -57,6 +57,7 @@
     virtual void finishAllRendering() OVERRIDE;
     virtual bool isStarted() const OVERRIDE;
     virtual bool initializeContext() OVERRIDE;
+    virtual void setSurfaceReady() OVERRIDE;
     virtual bool initializeLayerRenderer() OVERRIDE;
     virtual bool recreateContext() OVERRIDE;
     virtual int compositorIdentifier() const OVERRIDE;
@@ -129,6 +130,7 @@
     void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, double durationSec);
     void finishAllRenderingOnImplThread(CCCompletionEvent*);
     void initializeImplOnImplThread(CCCompletionEvent*);
+    void setSurfaceReadyOnImplThread();
     void initializeContextOnImplThread(GraphicsContext3D*);
     void initializeLayerRendererOnImplThread(CCCompletionEvent*, bool* initializeSucceeded, LayerRendererCapabilities*);
     void setVisibleOnImplThread(CCCompletionEvent*, bool visible);

Modified: trunk/Source/WebKit/chromium/ChangeLog (114799 => 114800)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-20 23:49:41 UTC (rev 114800)
@@ -1,3 +1,37 @@
+2012-04-20  James Robinson  <[email protected]>
+
+        [chromium] Plumb a compositor surface ready notification through to the threaded compositor
+        https://bugs.webkit.org/show_bug.cgi?id=84305
+
+        Reviewed by Adrienne Walker.
+
+        Adds a notification to WebWidget for when the compositor surface is ready to use. This exists to fix a race
+        condition when WebKit requires that we enter compositing mode but we haven't completed initialization of the
+        native window/etc backing the WebWidget, and we can't block for this initialization to complete without inducing
+        deadlocks. In this situation, we proceed as usual except that we can't attempt to use the compositor context or
+        it will fail.
+
+        * public/WebWidget.h:
+        (WebWidget):
+        * src/WebLayerTreeView.cpp:
+        (WebKit::WebLayerTreeView::setSurfaceReady):
+        (WebKit):
+        * src/WebPagePopupImpl.cpp:
+        (WebKit::WebPagePopupImpl::setCompositorSurfaceReady):
+        (WebKit):
+        * src/WebPagePopupImpl.h:
+        (WebPagePopupImpl):
+        * src/WebPopupMenuImpl.cpp:
+        (WebKit::WebPopupMenuImpl::setCompositorSurfaceReady):
+        (WebKit):
+        * src/WebPopupMenuImpl.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::setCompositorSurfaceReady):
+        (WebKit):
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+        * src/WebViewImpl.h:
+        (WebViewImpl):
+
 2012-04-20  Mark Pilgrim  <[email protected]>
 
         [Chromium] Call memoryUsageMB directly

Modified: trunk/Source/WebKit/chromium/public/WebWidget.h (114799 => 114800)


--- trunk/Source/WebKit/chromium/public/WebWidget.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/public/WebWidget.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -40,6 +40,7 @@
 #include "platform/WebSize.h"
 
 #define WEBKIT_HAS_NEW_FULLSCREEN_API 1
+#define WEBWIDGET_HAS_SETCOMPOSITORSURFACEREADY 1
 
 namespace WebKit {
 
@@ -107,6 +108,10 @@
     // animate or layout in this case.
     virtual void composite(bool finish) = 0;
 
+    // Indicates that the compositing surface associated with this WebWidget is
+    // ready to use.
+    virtual void setCompositorSurfaceReady() = 0;
+
     // Temporary method for the embedder to notify the WebWidget that the widget
     // has taken damage, e.g. due to a window expose. This method will be
     // removed when the WebWidget inversion patch lands --- http://crbug.com/112837

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp (114799 => 114800)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -69,6 +69,11 @@
     return !isNull();
 }
 
+void WebLayerTreeView::setSurfaceReady()
+{
+    m_private->setSurfaceReady();
+}
+
 void WebLayerTreeView::setRootLayer(WebLayer *root)
 {
     if (root)

Modified: trunk/Source/WebKit/chromium/src/WebPagePopupImpl.cpp (114799 => 114800)


--- trunk/Source/WebKit/chromium/src/WebPagePopupImpl.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/src/WebPagePopupImpl.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -209,6 +209,10 @@
     PageWidgetDelegate::animate(m_page.get(), monotonicallyIncreasingTime());
 }
 
+void WebPagePopupImpl::setCompositorSurfaceReady()
+{
+}
+
 void WebPagePopupImpl::composite(bool)
 {
 }

Modified: trunk/Source/WebKit/chromium/src/WebPagePopupImpl.h (114799 => 114800)


--- trunk/Source/WebKit/chromium/src/WebPagePopupImpl.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/src/WebPagePopupImpl.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -65,6 +65,7 @@
     // WebWidget functions
     virtual WebSize size() OVERRIDE;
     virtual void animate(double) OVERRIDE;
+    virtual void setCompositorSurfaceReady() OVERRIDE;
     virtual void composite(bool) OVERRIDE;
     virtual void layout() OVERRIDE;
     virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;

Modified: trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp (114799 => 114800)


--- trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -207,6 +207,11 @@
     notImplemented();
 }
 
+void WebPopupMenuImpl::setCompositorSurfaceReady()
+{
+    notImplemented();
+}
+
 void WebPopupMenuImpl::composite(bool)
 {
     notImplemented();

Modified: trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h (114799 => 114800)


--- trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -75,6 +75,7 @@
     virtual void layout() OVERRIDE;
     virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
     virtual void themeChanged() OVERRIDE;
+    virtual void setCompositorSurfaceReady() OVERRIDE;
     virtual void composite(bool finish) OVERRIDE;
     virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
     virtual void mouseCaptureLost() OVERRIDE;

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (114799 => 114800)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -384,6 +384,7 @@
     , m_isAcceleratedCompositingActive(false)
     , m_compositorCreationFailed(false)
     , m_recreatingGraphicsContext(false)
+    , m_compositorSurfaceReady(false)
 #endif
 #if ENABLE(INPUT_SPEECH)
     , m_speechInputClient(SpeechInputClientImpl::create(client))
@@ -1401,6 +1402,13 @@
 }
 #endif
 
+void WebViewImpl::setCompositorSurfaceReady()
+{
+    m_compositorSurfaceReady = true;
+    if (!m_layerTreeView.isNull())
+        m_layerTreeView.setSurfaceReady();
+}
+
 void WebViewImpl::animate(double)
 {
 #if ENABLE(REQUEST_ANIMATION_FRAME)
@@ -3269,6 +3277,8 @@
         m_layerTreeView.initialize(this, m_rootLayer, layerTreeViewSettings);
         if (!m_layerTreeView.isNull()) {
             m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
+            if (m_compositorSurfaceReady)
+                m_layerTreeView.setSurfaceReady();
             updateLayerTreeViewport();
             m_client->didActivateCompositor(m_layerTreeView.compositorIdentifier());
             m_isAcceleratedCompositingActive = true;

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (114799 => 114800)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-04-20 23:49:41 UTC (rev 114800)
@@ -124,6 +124,7 @@
     virtual void didEnterFullScreen();
     virtual void willExitFullScreen();
     virtual void didExitFullScreen();
+    virtual void setCompositorSurfaceReady();
     virtual void animate(double);
     virtual void layout(); // Also implements WebLayerTreeViewClient::layout()
     virtual void paint(WebCanvas*, const WebRect&);
@@ -754,6 +755,7 @@
     bool m_compositorCreationFailed;
     // If true, the graphics context is being restored.
     bool m_recreatingGraphicsContext;
+    bool m_compositorSurfaceReady;
 #endif
     static const WebInputEvent* m_currentInputEvent;
 

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (114799 => 114800)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-04-20 23:47:03 UTC (rev 114799)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-04-20 23:49:41 UTC (rev 114800)
@@ -538,6 +538,7 @@
     m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings);
     ASSERT_TRUE(m_layerTreeHost);
     rootLayer->setLayerTreeHost(m_layerTreeHost.get());
+    m_layerTreeHost->setSurfaceReady();
 
     m_beginning = true;
     beginTest();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to