Title: [98039] trunk/Source
Revision
98039
Author
nd...@chromium.org
Date
2011-10-20 16:36:29 -0700 (Thu, 20 Oct 2011)

Log Message

[chromium] Route onSwapBuffersComplete from LayerRenderer to CCScheduler.

Reviewed by James Robinson.

Source/WebCore:

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::create):
(WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::~LayerRendererSwapBuffersCompleteCallbackAdapter):
(WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::onSwapBuffersComplete):
(WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::LayerRendererSwapBuffersCompleteCallbackAdapter):
(WebCore::LayerRendererChromium::initialize):
(WebCore::LayerRendererChromium::~LayerRendererChromium):
(WebCore::LayerRendererChromium::swapBuffers):
(WebCore::LayerRendererChromium::onSwapBuffersComplete):
* platform/graphics/chromium/LayerRendererChromium.h:
* platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
(WebCore::CCHeadsUpDisplay::onSwapBuffers):
* platform/graphics/chromium/cc/CCHeadsUpDisplay.h:
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::LayerRendererCapabilities::LayerRendererCapabilities):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::swapBuffers):
(WebCore::CCLayerTreeHostImpl::onSwapBuffersComplete):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
* platform/graphics/chromium/cc/CCScheduler.cpp:
(WebCore::CCScheduler::requestRedraw):
(WebCore::CCScheduler::didDrawAndSwap):
(WebCore::CCScheduler::didSwapBuffersComplete):
(WebCore::CCScheduler::didSwapBuffersAbort):
* platform/graphics/chromium/cc/CCScheduler.h:
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::compositeImmediately):
* platform/graphics/chromium/cc/CCSingleThreadProxy.h:
(WebCore::CCSingleThreadProxy::onSwapBuffersCompleteOnImplThread):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxySchedulerClient::scheduleDrawAndSwap):
(WebCore::CCThreadProxy::drawLayersAndReadbackOnImplThread):
(WebCore::CCThreadProxy::onSwapBuffersCompleteOnImplThread):
(WebCore::CCThreadProxy::finishAllRenderingOnImplThread):
(WebCore::CCThreadProxy::drawLayersAndSwapOnImplThread):
(WebCore::CCThreadProxy::drawLayersOnImplThread):
* platform/graphics/chromium/cc/CCThreadProxy.h:

Source/WebKit/chromium:

* src/GraphicsContext3DChromium.cpp:
(WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::~GraphicsContext3DSwapBuffersCompleteCallbackAdapter):
(WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::GraphicsContext3DSwapBuffersCompleteCallbackAdapter):
(WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::onSwapBuffersComplete):
(WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::create):
(WebCore::GraphicsContext3DPrivate::setSwapBuffersCompleteCallbackCHROMIUM):
* src/GraphicsContext3DPrivate.h:
* tests/CCLayerTreeHostImplTest.cpp:
(WebCore::CCLayerTreeHostImplTest::onSwapBuffersCompleteOnImplThread):
* tests/CCSchedulerTest.cpp:
(WebCore::CCSchedulerTest::CCSchedulerTest):
(WebCore::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98038 => 98039)


--- trunk/Source/WebCore/ChangeLog	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/ChangeLog	2011-10-20 23:36:29 UTC (rev 98039)
@@ -1,3 +1,47 @@
+2011-10-20  Nat Duca  <nd...@chromium.org>
+
+        [chromium] Route onSwapBuffersComplete from LayerRenderer to CCScheduler.
+
+        Reviewed by James Robinson.
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::create):
+        (WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::~LayerRendererSwapBuffersCompleteCallbackAdapter):
+        (WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::onSwapBuffersComplete):
+        (WebCore::LayerRendererSwapBuffersCompleteCallbackAdapter::LayerRendererSwapBuffersCompleteCallbackAdapter):
+        (WebCore::LayerRendererChromium::initialize):
+        (WebCore::LayerRendererChromium::~LayerRendererChromium):
+        (WebCore::LayerRendererChromium::swapBuffers):
+        (WebCore::LayerRendererChromium::onSwapBuffersComplete):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
+        (WebCore::CCHeadsUpDisplay::onSwapBuffers):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplay.h:
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::LayerRendererCapabilities::LayerRendererCapabilities):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::swapBuffers):
+        (WebCore::CCLayerTreeHostImpl::onSwapBuffersComplete):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        * platform/graphics/chromium/cc/CCScheduler.cpp:
+        (WebCore::CCScheduler::requestRedraw):
+        (WebCore::CCScheduler::didDrawAndSwap):
+        (WebCore::CCScheduler::didSwapBuffersComplete):
+        (WebCore::CCScheduler::didSwapBuffersAbort):
+        * platform/graphics/chromium/cc/CCScheduler.h:
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::compositeImmediately):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
+        (WebCore::CCSingleThreadProxy::onSwapBuffersCompleteOnImplThread):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxySchedulerClient::scheduleDrawAndSwap):
+        (WebCore::CCThreadProxy::drawLayersAndReadbackOnImplThread):
+        (WebCore::CCThreadProxy::onSwapBuffersCompleteOnImplThread):
+        (WebCore::CCThreadProxy::finishAllRenderingOnImplThread):
+        (WebCore::CCThreadProxy::drawLayersAndSwapOnImplThread):
+        (WebCore::CCThreadProxy::drawLayersOnImplThread):
+        * platform/graphics/chromium/cc/CCThreadProxy.h:
+
 2011-10-20  Julien Chaffraix  <jchaffr...@webkit.org>
 
         RenderDeprecatedFlexibleBox does not call its children's layout method

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -56,6 +56,7 @@
 #include "cc/CCLayerImpl.h"
 #include "cc/CCLayerTreeHostCommon.h"
 #include "cc/CCMainThreadTask.h"
+#include "cc/CCThreadProxy.h"
 #if USE(SKIA)
 #include "Extensions3D.h"
 #include "GrContext.h"
@@ -130,6 +131,29 @@
 
 } // anonymous namespace
 
+class LayerRendererSwapBuffersCompleteCallbackAdapter : public Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM {
+public:
+    static PassOwnPtr<LayerRendererSwapBuffersCompleteCallbackAdapter> create(LayerRendererChromium* layerRenderer)
+    {
+        return adoptPtr(new LayerRendererSwapBuffersCompleteCallbackAdapter(layerRenderer));
+    }
+    virtual ~LayerRendererSwapBuffersCompleteCallbackAdapter() { }
+
+    virtual void onSwapBuffersComplete()
+    {
+        m_layerRenderer->onSwapBuffersComplete();
+    }
+
+private:
+    explicit LayerRendererSwapBuffersCompleteCallbackAdapter(LayerRendererChromium* layerRenderer)
+    {
+        m_layerRenderer = layerRenderer;
+    }
+
+    LayerRendererChromium* m_layerRenderer;
+};
+
+
 PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(CCLayerTreeHostImpl* owner, PassRefPtr<GraphicsContext3D> context)
 {
 #if USE(SKIA)
@@ -165,6 +189,18 @@
     if (m_capabilities.usingMapSub)
         extensions->ensureEnabled("GL_CHROMIUM_map_sub");
 
+    // Use the swapBuffers callback only with the threaded proxy.
+    if (settings().enableCompositorThread)
+        m_capabilities.usingSwapCompleteCallback = extensions->supports("GL_CHROMIUM_swapbuffers_complete_callback");
+    if (m_capabilities.usingSwapCompleteCallback) {
+        extensions->ensureEnabled("GL_CHROMIUM_swapbuffers_complete_callback");
+        Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions);
+        extensions3DChromium->setSwapBuffersCompleteCallbackCHROMIUM(LayerRendererSwapBuffersCompleteCallbackAdapter::create(this));
+    }
+
+    if (extensions->supports("GL_EXT_texture_format_BGRA8888"))
+        extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888");
+
     GLC(m_context.get(), m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_capabilities.maxTextureSize));
     m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context.get());
 
@@ -180,8 +216,9 @@
 
 LayerRendererChromium::~LayerRendererChromium()
 {
-    ASSERT(CCProxy::isImplThread
-());
+    ASSERT(CCProxy::isImplThread());
+    Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(m_context->getExtensions());
+    extensions3DChromium->setSwapBuffersCompleteCallbackCHROMIUM(nullptr);
     m_headsUpDisplay.clear(); // Explicitly destroy the HUD before the TextureManager dies.
     cleanupSharedObjects();
 }
@@ -411,18 +448,23 @@
     m_context->finish();
 }
 
-void LayerRendererChromium::present()
+void LayerRendererChromium::swapBuffers()
 {
-    TRACE_EVENT("LayerRendererChromium::present", this, 0);
+    TRACE_EVENT("LayerRendererChromium::swapBuffers", this, 0);
     // We're done! Time to swapbuffers!
 
     // Note that currently this has the same effect as swapBuffers; we should
     // consider exposing a different entry point on GraphicsContext3D.
     m_context->prepareTexture();
 
-    m_headsUpDisplay->onPresent();
+    m_headsUpDisplay->onSwapBuffers();
 }
 
+void LayerRendererChromium::onSwapBuffersComplete()
+{
+    m_owner->onSwapBuffersComplete();
+}
+
 void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& rect)
 {
     ASSERT(rect.maxX() <= viewportWidth() && rect.maxY() <= viewportHeight());

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -70,6 +70,7 @@
 class GraphicsContext3D;
 class NonCompositedContentHost;
 class TrackingTextureAllocator;
+class LayerRendererSwapBuffersCompleteCallbackAdapter;
 
 // Class that handles drawing of composited render layers using GL.
 class LayerRendererChromium {
@@ -103,7 +104,7 @@
     void finish();
 
     // puts backbuffer onscreen
-    void present();
+    void swapBuffers();
 
     void setZoomAnimatorTransform(const TransformationMatrix& t) { m_zoomAnimatorTransform = t; }
 
@@ -182,6 +183,9 @@
 
     void clearRenderSurfacesOnCCLayerImplRecursive(CCLayerImpl*);
 
+    friend class LayerRendererSwapBuffersCompleteCallbackAdapter;
+    void onSwapBuffersComplete();
+
     CCLayerTreeHostImpl* m_owner;
 
     LayerRendererCapabilities m_capabilities;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -82,7 +82,7 @@
     m_beginTimeHistoryInSec[m_currentFrameNumber % kBeginFrameHistorySize] = timestamp;
 }
 
-void CCHeadsUpDisplay::onPresent()
+void CCHeadsUpDisplay::onSwapBuffers()
 {
     m_currentFrameNumber += 1;
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -53,7 +53,7 @@
     int currentFrameNumber() const { return m_currentFrameNumber; }
 
     void onFrameBegin(double timestamp);
-    void onPresent();
+    void onSwapBuffers();
 
     bool enabled() const;
     void draw();

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -83,11 +83,13 @@
         : bestTextureFormat(0)
         , usingMapSub(false)
         , usingAcceleratedPainting(false)
+        , usingSwapCompleteCallback(false)
         , maxTextureSize(0) { }
 
     GC3Denum bestTextureFormat;
     bool usingMapSub;
     bool usingAcceleratedPainting;
+    bool usingSwapCompleteCallback;
     int maxTextureSize;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -104,12 +104,17 @@
     return m_layerRenderer ? m_layerRenderer->contentsTextureAllocator() : 0;
 }
 
-void CCLayerTreeHostImpl::present()
+void CCLayerTreeHostImpl::swapBuffers()
 {
     ASSERT(m_layerRenderer && !isContextLost());
-    m_layerRenderer->present();
+    m_layerRenderer->swapBuffers();
 }
 
+void CCLayerTreeHostImpl::onSwapBuffersComplete()
+{
+    m_client->onSwapBuffersCompleteOnImplThread();
+}
+
 void CCLayerTreeHostImpl::readback(void* pixels, const IntRect& rect)
 {
     ASSERT(m_layerRenderer && !isContextLost());

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -46,6 +46,7 @@
 // CCLayerTreeHost->CCProxy callback interface.
 class CCLayerTreeHostImplClient {
 public:
+    virtual void onSwapBuffersCompleteOnImplThread() = 0;
     virtual void setNeedsRedrawOnImplThread() = 0;
     virtual void setNeedsCommitOnImplThread() = 0;
 };
@@ -76,7 +77,8 @@
     const LayerRendererCapabilities& layerRendererCapabilities() const;
     TextureAllocator* contentsTextureAllocator() const;
 
-    void present();
+    void swapBuffers();
+    void onSwapBuffersComplete();
 
     void readback(void* pixels, const IntRect&);
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -58,7 +58,7 @@
 
     m_redrawPending = true;
 
-    m_client->scheduleDrawAndPresent();
+    m_client->scheduleDrawAndSwap();
 }
 
 void CCScheduler::didCommit()
@@ -66,9 +66,17 @@
     m_commitPending = false;
 }
 
-void CCScheduler::didDraw()
+void CCScheduler::didDrawAndSwap()
 {
     m_redrawPending = false;
 }
 
+void CCScheduler::didSwapBuffersComplete()
+{
 }
+
+void CCScheduler::didSwapBuffersAbort()
+{
+}
+
+}

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h (98038 => 98039)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -35,7 +35,7 @@
 class CCSchedulerClient {
 public:
     virtual void scheduleBeginFrameAndCommit() = 0;
-    virtual void scheduleDrawAndPresent() = 0;
+    virtual void scheduleDrawAndSwap() = 0;
 
 protected:
     virtual ~CCSchedulerClient() { }
@@ -54,7 +54,9 @@
     void requestRedraw();
 
     void didCommit();
-    void didDraw();
+    void didDrawAndSwap();
+    void didSwapBuffersComplete();
+    void didSwapBuffersAbort();
 
     bool commitPending() const { return m_commitPending; }
     bool redrawPending() const { return m_redrawPending; }

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -198,7 +198,7 @@
     commitIfNeeded();
 
     if (doComposite())
-        m_layerTreeHostImpl->present();
+        m_layerTreeHostImpl->swapBuffers();
 }
 
 bool CCSingleThreadProxy::recreateContextIfNeeded()

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -56,6 +56,7 @@
     virtual void stop();
 
     // CCLayerTreeHostImplClient implementation
+    virtual void onSwapBuffersCompleteOnImplThread() { ASSERT_NOT_REACHED(); }
     virtual void setNeedsRedrawOnImplThread() { m_layerTreeHost->setNeedsCommitThenRedraw(); }
     virtual void setNeedsCommitOnImplThread() { m_layerTreeHost->setNeedsCommitThenRedraw(); }
 

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -65,9 +65,9 @@
         m_proxy->postBeginFrameAndCommitOnImplThread();
     }
 
-    virtual void scheduleDrawAndPresent()
+    virtual void scheduleDrawAndSwap()
     {
-        m_proxy->drawLayersAndPresentOnImplThread();
+        m_proxy->drawLayersAndSwapOnImplThread();
     }
 
 private:
@@ -146,7 +146,10 @@
     }
     drawLayersOnImplThread();
     m_layerTreeHostImpl->readback(pixels, rect);
-    *success = m_layerTreeHostImpl->isContextLost();
+    bool lost = m_layerTreeHostImpl->isContextLost();
+    if (lost)
+        m_schedulerOnImplThread->didSwapBuffersAbort();
+    *success = !lost;
     completion->signal();
 }
 
@@ -252,6 +255,13 @@
     m_schedulerOnImplThread->requestAnimate();
 }
 
+void CCThreadProxy::onSwapBuffersCompleteOnImplThread()
+{
+    ASSERT(isImplThread());
+    TRACE_EVENT("CCThreadProxy::onSwapBuffersCompleteOnImplThread", this, 0);
+    m_schedulerOnImplThread->didSwapBuffersComplete();
+}
+
 void CCThreadProxy::setNeedsCommitOnImplThread()
 {
     ASSERT(isImplThread());
@@ -309,8 +319,8 @@
     ASSERT(isImplThread());
     if (m_schedulerOnImplThread->redrawPending()) {
         drawLayersOnImplThread();
-        m_layerTreeHostImpl->present();
-        m_schedulerOnImplThread->didDraw();
+        m_layerTreeHostImpl->swapBuffers();
+        m_schedulerOnImplThread->didDrawAndSwap();
     }
     m_layerTreeHostImpl->finishAllRendering();
     completion->signal();
@@ -417,16 +427,16 @@
     m_schedulerOnImplThread->didCommit();
 }
 
-void CCThreadProxy::drawLayersAndPresentOnImplThread()
+void CCThreadProxy::drawLayersAndSwapOnImplThread()
 {
-    TRACE_EVENT("CCThreadProxy::drawLayersOnImplThread", this, 0);
+    TRACE_EVENT("CCThreadProxy::drawLayersAndSwapOnImplThread", this, 0);
     ASSERT(isImplThread());
     if (!m_layerTreeHostImpl)
         return;
 
     drawLayersOnImplThread();
-    m_layerTreeHostImpl->present();
-    m_schedulerOnImplThread->didDraw();
+    m_layerTreeHostImpl->swapBuffers();
+    m_schedulerOnImplThread->didDrawAndSwap();
 }
 
 void CCThreadProxy::drawLayersOnImplThread()
@@ -436,6 +446,8 @@
     ASSERT(m_layerTreeHostImpl);
 
     m_layerTreeHostImpl->drawLayers();
+    // FIXME: handle case where m_layerTreeHostImpl->isContextLost.
+    // FIXME: pass didSwapBuffersAbort if m_layerTreeHostImpl->isContextLost.
     ASSERT(!m_layerTreeHostImpl->isContextLost());
 }
 

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -66,6 +66,7 @@
     virtual void stop();
 
     // CCLayerTreeHostImplClient implementation
+    virtual void onSwapBuffersCompleteOnImplThread();
     virtual void setNeedsRedrawOnImplThread();
     virtual void setNeedsCommitOnImplThread();
 
@@ -80,7 +81,7 @@
     PassOwnPtr<CCMainThread::Task> createBeginFrameAndCommitTaskOnImplThread();
     void obtainBeginFrameAndCommitTaskFromCCThread(CCCompletionEvent*, CCMainThread::Task**);
     void commitOnImplThread(CCCompletionEvent*);
-    void drawLayersAndPresentOnImplThread();
+    void drawLayersAndSwapOnImplThread();
     void drawLayersOnImplThread();
     void drawLayersAndReadbackOnImplThread(CCCompletionEvent*, bool* success, void* pixels, const IntRect&);
     void finishAllRenderingOnImplThread(CCCompletionEvent*);

Modified: trunk/Source/WebKit/chromium/ChangeLog (98038 => 98039)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-10-20 23:36:29 UTC (rev 98039)
@@ -1,3 +1,22 @@
+2011-10-20  Nat Duca  <nd...@chromium.org>
+
+        [chromium] Route onSwapBuffersComplete from LayerRenderer to CCScheduler.
+
+        Reviewed by James Robinson.
+
+        * src/GraphicsContext3DChromium.cpp:
+        (WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::~GraphicsContext3DSwapBuffersCompleteCallbackAdapter):
+        (WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::GraphicsContext3DSwapBuffersCompleteCallbackAdapter):
+        (WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::onSwapBuffersComplete):
+        (WebCore::GraphicsContext3DSwapBuffersCompleteCallbackAdapter::create):
+        (WebCore::GraphicsContext3DPrivate::setSwapBuffersCompleteCallbackCHROMIUM):
+        * src/GraphicsContext3DPrivate.h:
+        * tests/CCLayerTreeHostImplTest.cpp:
+        (WebCore::CCLayerTreeHostImplTest::onSwapBuffersCompleteOnImplThread):
+        * tests/CCSchedulerTest.cpp:
+        (WebCore::CCSchedulerTest::CCSchedulerTest):
+        (WebCore::TEST_F):
+
 2011-10-20  Michal Mocny  <mmo...@google.com>
 
         [chromium] Add a setVisibility method to WebGraphicsContext3D.

Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp (98038 => 98039)


--- trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -1275,30 +1275,31 @@
     return m_private->isGLES2Compliant();
 }
 
-class SwapBuffersCompleteCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM {
+class GraphicsContext3DSwapBuffersCompleteCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM {
 public:
     virtual void onSwapBuffersComplete();
-    static PassOwnPtr<SwapBuffersCompleteCallbackAdapter> create(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM>);
-    virtual ~SwapBuffersCompleteCallbackAdapter() { }
+    static PassOwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> create(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM>);
+    virtual ~GraphicsContext3DSwapBuffersCompleteCallbackAdapter() { }
+
 private:
-    SwapBuffersCompleteCallbackAdapter(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) : m_swapBuffersCompleteCallback(cb) { }
+    GraphicsContext3DSwapBuffersCompleteCallbackAdapter(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) : m_swapBuffersCompleteCallback(cb) { }
     OwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> m_swapBuffersCompleteCallback;
 };
 
-void SwapBuffersCompleteCallbackAdapter::onSwapBuffersComplete()
+void GraphicsContext3DSwapBuffersCompleteCallbackAdapter::onSwapBuffersComplete()
 {
     if (m_swapBuffersCompleteCallback)
         m_swapBuffersCompleteCallback->onSwapBuffersComplete();
 }
 
-PassOwnPtr<SwapBuffersCompleteCallbackAdapter> SwapBuffersCompleteCallbackAdapter::create(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb)
+PassOwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> GraphicsContext3DSwapBuffersCompleteCallbackAdapter::create(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb)
 {
-    return adoptPtr(cb.get() ? new SwapBuffersCompleteCallbackAdapter(cb) : 0);
+    return adoptPtr(cb.get() ? new GraphicsContext3DSwapBuffersCompleteCallbackAdapter(cb) : 0);
 }
 
 void GraphicsContext3DPrivate::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb)
 {
-    m_swapBuffersCompleteCallbackAdapter = SwapBuffersCompleteCallbackAdapter::create(cb);
+    m_swapBuffersCompleteCallbackAdapter = GraphicsContext3DSwapBuffersCompleteCallbackAdapter::create(cb);
     m_impl->setSwapBuffersCompleteCallbackCHROMIUM(m_swapBuffersCompleteCallbackAdapter.get());
 }
 

Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h (98038 => 98039)


--- trunk/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h	2011-10-20 23:36:29 UTC (rev 98039)
@@ -51,7 +51,7 @@
 class WebGLLayerChromium;
 #endif
 class GraphicsContextLostCallbackAdapter;
-class SwapBuffersCompleteCallbackAdapter;
+class GraphicsContext3DSwapBuffersCompleteCallbackAdapter;
 
 class GraphicsContext3DPrivate {
 public:
@@ -312,7 +312,7 @@
     OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
     OwnPtr<Extensions3DChromium> m_extensions;
     OwnPtr<GraphicsContextLostCallbackAdapter> m_contextLostCallbackAdapter;
-    OwnPtr<SwapBuffersCompleteCallbackAdapter> m_swapBuffersCompleteCallbackAdapter;
+    OwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> m_swapBuffersCompleteCallbackAdapter;
     WebKit::WebViewImpl* m_webViewImpl;
     bool m_initializedAvailableExtensions;
     HashSet<String> m_enabledExtensions;

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (98038 => 98039)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -44,6 +44,7 @@
         m_hostImpl = CCLayerTreeHostImpl::create(settings, this);
     }
 
+    virtual void onSwapBuffersCompleteOnImplThread() { }
     virtual void setNeedsRedrawOnImplThread() { m_didRequestRedraw = true; }
     virtual void setNeedsCommitOnImplThread() { m_didRequestCommit = true; }
 

Modified: trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp (98038 => 98039)


--- trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp	2011-10-20 23:34:13 UTC (rev 98038)
+++ trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp	2011-10-20 23:36:29 UTC (rev 98039)
@@ -38,7 +38,7 @@
 class MockCCSchedulerClient : public CCSchedulerClient {
 public:
     MOCK_METHOD0(scheduleBeginFrameAndCommit, void());
-    MOCK_METHOD0(scheduleDrawAndPresent, void());
+    MOCK_METHOD0(scheduleDrawAndSwap, void());
 };
 
 class CCSchedulerTest : public testing::Test {
@@ -48,7 +48,7 @@
         , m_scheduler(CCScheduler::create(m_client.get()))
     {
         EXPECT_CALL(*m_client, scheduleBeginFrameAndCommit()).Times(0);
-        EXPECT_CALL(*m_client, scheduleDrawAndPresent()).Times(0);
+        EXPECT_CALL(*m_client, scheduleDrawAndSwap()).Times(0);
     }
 
 protected:
@@ -75,9 +75,8 @@
 
 TEST_F(CCSchedulerTest, RequestRedraw)
 {
-    EXPECT_CALL(*m_client, scheduleDrawAndPresent()).Times(1);
+    EXPECT_CALL(*m_client, scheduleDrawAndSwap()).Times(1);
     m_scheduler->requestRedraw();
 }
 
 }
-
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to