Title: [118563] trunk/Source/WebKit/chromium
Revision
118563
Author
[email protected]
Date
2012-05-25 14:28:28 -0700 (Fri, 25 May 2012)

Log Message

[chromium] WebLayerTreeViewImpl should not hide methods in CCLayerTreeHost with signatures that match the Client interface
https://bugs.webkit.org/show_bug.cgi?id=87301

Reviewed by James Robinson.

Most methods in the CCLayerTreeHostClient interface have a matching
method signature on CCLayerTreeHost that simply calls the client, if
one exists at all. However, CCLayerTreeHost::updateAnimations() does
important work in addition to calling the client.

Currently WebLayerTreeViewImpl itself implements the interface for
CCLayerTreeHostClient as well as CCLayerTreeHost, and simply forwards
any call to a method in the client interface to its own client. This
blocks WebViewImpl from calling CCLayerTreeHost::updateAnimations, since
the method is also in the client interface.

We change WebLayerTreeViewImpl to own a CCLayerTreeHost and a
WebLayerTreeHostClientAdapter. This fixes the shadowing by making
the two interfaces separate, and resolves lifetime issues by
ensuring that the CCLayerTreeHost is destroyed before its client.

* src/WebLayerTreeView.cpp:
(WebKit::WebLayerTreeView::setSurfaceReady):
(WebKit::WebLayerTreeView::setRootLayer):
(WebKit::WebLayerTreeView::compositorIdentifier):
(WebKit::WebLayerTreeView::setViewportSize):
(WebKit::WebLayerTreeView::viewportSize):
(WebKit::WebLayerTreeView::setBackgroundColor):
(WebKit::WebLayerTreeView::setVisible):
(WebKit::WebLayerTreeView::setPageScaleFactorAndLimits):
(WebKit::WebLayerTreeView::startPageScaleAnimation):
(WebKit::WebLayerTreeView::setNeedsAnimate):
(WebKit::WebLayerTreeView::setNeedsRedraw):
(WebKit::WebLayerTreeView::commitRequested):
(WebKit::WebLayerTreeView::composite):
(WebKit::WebLayerTreeView::updateAnimations):
(WebKit::WebLayerTreeView::compositeAndReadback):
(WebKit::WebLayerTreeView::finishAllRendering):
(WebKit::WebLayerTreeView::context):
(WebKit::WebLayerTreeView::loseCompositorContext):
* src/WebLayerTreeViewImpl.cpp:
(WebKit):
(WebLayerTreeViewClientAdapter):
(WebKit::WebLayerTreeViewClientAdapter::WebLayerTreeViewClientAdapter):
(WebKit::WebLayerTreeViewClientAdapter::~WebLayerTreeViewClientAdapter):
(WebKit::WebLayerTreeViewImpl::create):
(WebKit::WebLayerTreeViewImpl::WebLayerTreeViewImpl):
(WebKit::WebLayerTreeViewImpl::~WebLayerTreeViewImpl):
* src/WebLayerTreeViewImpl.h:
(WebCore):
(WebKit):
(WebKit::WebLayerTreeViewImpl::layerTreeHost):
(WebLayerTreeViewImpl):

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (118562 => 118563)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-25 21:17:33 UTC (rev 118562)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-25 21:28:28 UTC (rev 118563)
@@ -1,3 +1,59 @@
+2012-05-25  Dana Jansens  <[email protected]>
+
+        [chromium] WebLayerTreeViewImpl should not hide methods in CCLayerTreeHost with signatures that match the Client interface
+        https://bugs.webkit.org/show_bug.cgi?id=87301
+
+        Reviewed by James Robinson.
+
+        Most methods in the CCLayerTreeHostClient interface have a matching
+        method signature on CCLayerTreeHost that simply calls the client, if
+        one exists at all. However, CCLayerTreeHost::updateAnimations() does
+        important work in addition to calling the client.
+
+        Currently WebLayerTreeViewImpl itself implements the interface for
+        CCLayerTreeHostClient as well as CCLayerTreeHost, and simply forwards
+        any call to a method in the client interface to its own client. This
+        blocks WebViewImpl from calling CCLayerTreeHost::updateAnimations, since
+        the method is also in the client interface.
+
+        We change WebLayerTreeViewImpl to own a CCLayerTreeHost and a
+        WebLayerTreeHostClientAdapter. This fixes the shadowing by making
+        the two interfaces separate, and resolves lifetime issues by
+        ensuring that the CCLayerTreeHost is destroyed before its client.
+
+        * src/WebLayerTreeView.cpp:
+        (WebKit::WebLayerTreeView::setSurfaceReady):
+        (WebKit::WebLayerTreeView::setRootLayer):
+        (WebKit::WebLayerTreeView::compositorIdentifier):
+        (WebKit::WebLayerTreeView::setViewportSize):
+        (WebKit::WebLayerTreeView::viewportSize):
+        (WebKit::WebLayerTreeView::setBackgroundColor):
+        (WebKit::WebLayerTreeView::setVisible):
+        (WebKit::WebLayerTreeView::setPageScaleFactorAndLimits):
+        (WebKit::WebLayerTreeView::startPageScaleAnimation):
+        (WebKit::WebLayerTreeView::setNeedsAnimate):
+        (WebKit::WebLayerTreeView::setNeedsRedraw):
+        (WebKit::WebLayerTreeView::commitRequested):
+        (WebKit::WebLayerTreeView::composite):
+        (WebKit::WebLayerTreeView::updateAnimations):
+        (WebKit::WebLayerTreeView::compositeAndReadback):
+        (WebKit::WebLayerTreeView::finishAllRendering):
+        (WebKit::WebLayerTreeView::context):
+        (WebKit::WebLayerTreeView::loseCompositorContext):
+        * src/WebLayerTreeViewImpl.cpp:
+        (WebKit):
+        (WebLayerTreeViewClientAdapter):
+        (WebKit::WebLayerTreeViewClientAdapter::WebLayerTreeViewClientAdapter):
+        (WebKit::WebLayerTreeViewClientAdapter::~WebLayerTreeViewClientAdapter):
+        (WebKit::WebLayerTreeViewImpl::create):
+        (WebKit::WebLayerTreeViewImpl::WebLayerTreeViewImpl):
+        (WebKit::WebLayerTreeViewImpl::~WebLayerTreeViewImpl):
+        * src/WebLayerTreeViewImpl.h:
+        (WebCore):
+        (WebKit):
+        (WebKit::WebLayerTreeViewImpl::layerTreeHost):
+        (WebLayerTreeViewImpl):
+
 2012-05-25  Kinuko Yasuda  <[email protected]>
 
         Unreviewed; rolling chromium deps.

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp (118562 => 118563)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-05-25 21:17:33 UTC (rev 118562)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-05-25 21:28:28 UTC (rev 118563)
@@ -75,98 +75,98 @@
 
 void WebLayerTreeView::setSurfaceReady()
 {
-    m_private->setSurfaceReady();
+    m_private->layerTreeHost()->setSurfaceReady();
 }
 
 void WebLayerTreeView::setRootLayer(WebLayer *root)
 {
     if (root)
-        m_private->setRootLayer(*root);
+        m_private->layerTreeHost()->setRootLayer(*root);
     else
-        m_private->setRootLayer(PassRefPtr<LayerChromium>());
+        m_private->layerTreeHost()->setRootLayer(PassRefPtr<LayerChromium>());
 }
 
 int WebLayerTreeView::compositorIdentifier()
 {
-    return m_private->compositorIdentifier();
+    return m_private->layerTreeHost()->compositorIdentifier();
 }
 
 void WebLayerTreeView::setViewportSize(const WebSize& viewportSize)
 {
-    m_private->setViewportSize(viewportSize);
+    m_private->layerTreeHost()->setViewportSize(viewportSize);
 }
 
 WebSize WebLayerTreeView::viewportSize() const
 {
-    return WebSize(m_private->viewportSize());
+    return WebSize(m_private->layerTreeHost()->viewportSize());
 }
 
 void WebLayerTreeView::setBackgroundColor(WebColor color)
 {
-    m_private->setBackgroundColor(color);
+    m_private->layerTreeHost()->setBackgroundColor(color);
 }
 
 void WebLayerTreeView::setVisible(bool visible)
 {
-    m_private->setVisible(visible);
+    m_private->layerTreeHost()->setVisible(visible);
 }
 
 void WebLayerTreeView::setPageScaleFactorAndLimits(float pageScaleFactor, float minimum, float maximum)
 {
-    m_private->setPageScaleFactorAndLimits(pageScaleFactor, minimum, maximum);
+    m_private->layerTreeHost()->setPageScaleFactorAndLimits(pageScaleFactor, minimum, maximum);
 }
 
 void WebLayerTreeView::startPageScaleAnimation(const WebPoint& scroll, bool useAnchor, float newPageScale, double durationSec)
 {
-    m_private->startPageScaleAnimation(IntSize(scroll.x, scroll.y), useAnchor, newPageScale, durationSec);
+    m_private->layerTreeHost()->startPageScaleAnimation(IntSize(scroll.x, scroll.y), useAnchor, newPageScale, durationSec);
 }
 
 void WebLayerTreeView::setNeedsAnimate()
 {
-    m_private->setNeedsAnimate();
+    m_private->layerTreeHost()->setNeedsAnimate();
 }
 
 void WebLayerTreeView::setNeedsRedraw()
 {
-    m_private->setNeedsRedraw();
+    m_private->layerTreeHost()->setNeedsRedraw();
 }
 
 bool WebLayerTreeView::commitRequested() const
 {
-    return m_private->commitRequested();
+    return m_private->layerTreeHost()->commitRequested();
 }
 
 void WebLayerTreeView::composite()
 {
     if (CCProxy::hasImplThread())
-        m_private->setNeedsCommit();
+        m_private->layerTreeHost()->setNeedsCommit();
     else
-        m_private->composite();
+        m_private->layerTreeHost()->composite();
 }
 
 void WebLayerTreeView::updateAnimations(double frameBeginTime)
 {
-    m_private->updateAnimations(frameBeginTime);
+    m_private->layerTreeHost()->updateAnimations(frameBeginTime);
 }
 
 bool WebLayerTreeView::compositeAndReadback(void *pixels, const WebRect& rect)
 {
-    return m_private->compositeAndReadback(pixels, rect);
+    return m_private->layerTreeHost()->compositeAndReadback(pixels, rect);
 }
 
 void WebLayerTreeView::finishAllRendering()
 {
-    m_private->finishAllRendering();
+    m_private->layerTreeHost()->finishAllRendering();
 }
 
 WebGraphicsContext3D* WebLayerTreeView::context()
 {
-    return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_private->context());
+    return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_private->layerTreeHost()->context());
 }
 
 void WebLayerTreeView::loseCompositorContext(int numTimes)
 {
-    m_private->loseContext(numTimes);
+    m_private->layerTreeHost()->loseContext(numTimes);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp (118562 => 118563)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp	2012-05-25 21:17:33 UTC (rev 118562)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp	2012-05-25 21:28:28 UTC (rev 118563)
@@ -29,6 +29,7 @@
 #include "CCThreadImpl.h"
 #include "GraphicsContext3DPrivate.h"
 #include "LayerChromium.h"
+#include "cc/CCLayerTreeHost.h"
 #include "cc/CCThreadProxy.h"
 #include "platform/WebGraphicsContext3D.h"
 #include "platform/WebLayer.h"
@@ -41,18 +42,48 @@
 
 namespace WebKit {
 
+// Converts messages from CCLayerTreeHostClient to WebLayerTreeViewClient.
+class WebLayerTreeViewClientAdapter : public WebCore::CCLayerTreeHostClient {
+public:
+    WebLayerTreeViewClientAdapter(WebLayerTreeViewClient* client) : m_client(client) { }
+    virtual ~WebLayerTreeViewClientAdapter() { }
+
+    // CCLayerTreeHostClient implementation
+    virtual void willBeginFrame() OVERRIDE { m_client->willBeginFrame(); }
+    virtual void didBeginFrame() OVERRIDE { m_client->didBeginFrame(); }
+    virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE { m_client->updateAnimations(monotonicFrameBeginTime); }
+    virtual void layout() OVERRIDE { m_client->layout(); }
+    virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale) OVERRIDE { m_client->applyScrollAndScale(scrollDelta, pageScale); }
+    virtual PassRefPtr<WebCore::GraphicsContext3D> createContext() OVERRIDE
+    {
+        OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(m_client->createContext3D());
+        if (!webContext)
+            return 0;
+        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow, false /* preserveDrawingBuffer */ );
+    }
+    virtual void didRecreateContext(bool success) OVERRIDE { m_client->didRebindGraphicsContext(success); }
+    virtual void willCommit() OVERRIDE { m_client->willCommit(); }
+    virtual void didCommit() OVERRIDE { m_client->didCommit(); }
+    virtual void didCommitAndDrawFrame() OVERRIDE { m_client->didCommitAndDrawFrame(); }
+    virtual void didCompleteSwapBuffers() OVERRIDE { m_client->didCompleteSwapBuffers(); }
+    virtual void scheduleComposite() OVERRIDE { m_client->scheduleComposite(); }
+
+private:
+    WebLayerTreeViewClient* m_client;
+};
+
 PassOwnPtr<WebLayerTreeViewImpl> WebLayerTreeViewImpl::create(WebLayerTreeViewClient* client, const WebLayer& root, const WebLayerTreeView::Settings& settings)
 {
-    OwnPtr<WebLayerTreeViewImpl> host = adoptPtr(new WebLayerTreeViewImpl(client, settings));
-    if (!host->initialize())
+    OwnPtr<WebLayerTreeViewImpl> impl = adoptPtr(new WebLayerTreeViewImpl(client, settings));
+    if (!impl->layerTreeHost())
         return nullptr;
-    host->setRootLayer(root);
-    return host.release();
+    impl->layerTreeHost()->setRootLayer(root);
+    return impl.release();
 }
 
 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client, const WebLayerTreeView::Settings& settings) 
-    : CCLayerTreeHost(this, settings)
-    , m_client(client)
+    : m_clientAdapter(adoptPtr(new WebLayerTreeViewClientAdapter(client)))
+    , m_layerTreeHost(CCLayerTreeHost::create(m_clientAdapter.get(), settings))
 {
 }
 
@@ -60,68 +91,4 @@
 {
 }
 
-void WebLayerTreeViewImpl::willBeginFrame()
-{
-    m_client->willBeginFrame();
-}
-
-void WebLayerTreeViewImpl::didBeginFrame()
-{
-    m_client->didBeginFrame();
-}
-
-void WebLayerTreeViewImpl::updateAnimations(double monotonicFrameBeginTime)
-{
-    m_client->updateAnimations(monotonicFrameBeginTime);
-}
-
-void WebLayerTreeViewImpl::layout()
-{
-    m_client->layout();
-}
-
-void WebLayerTreeViewImpl::applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale)
-{
-    m_client->applyScrollAndScale(WebSize(scrollDelta), pageScale);
-}
-
-PassRefPtr<GraphicsContext3D> WebLayerTreeViewImpl::createContext()
-{
-    OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(m_client->createContext3D());
-    if (!webContext)
-        return 0;
-
-    return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow, false /* preserveDrawingBuffer */ );
-}
-
-void WebLayerTreeViewImpl::didRecreateContext(bool success)
-{
-    m_client->didRebindGraphicsContext(success);
-}
-
-void WebLayerTreeViewImpl::willCommit()
-{
-    m_client->willCommit();
-}
-
-void WebLayerTreeViewImpl::didCommit()
-{
-    m_client->didCommit();
-}
-
-void WebLayerTreeViewImpl::didCommitAndDrawFrame()
-{
-    m_client->didCommitAndDrawFrame();
-}
-
-void WebLayerTreeViewImpl::didCompleteSwapBuffers()
-{
-    m_client->didCompleteSwapBuffers();
-}
-
-void WebLayerTreeViewImpl::scheduleComposite()
-{
-    m_client->scheduleComposite();
-}
-
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h (118562 => 118563)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h	2012-05-25 21:17:33 UTC (rev 118562)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h	2012-05-25 21:28:28 UTC (rev 118563)
@@ -27,37 +27,30 @@
 #define WebLayerTreeViewImpl_h
 
 #include "platform/WebLayerTreeView.h"
-#include "cc/CCLayerTreeHost.h"
+#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 
+namespace WebCore {
+class CCLayerTreeHost;
+}
+
 namespace WebKit {
 class WebLayer;
 class WebLayerTreeViewClient;
+class WebLayerTreeViewClientAdapter;
 
-class WebLayerTreeViewImpl : public WebCore::CCLayerTreeHost, public WebCore::CCLayerTreeHostClient {
+class WebLayerTreeViewImpl {
 public:
     static PassOwnPtr<WebLayerTreeViewImpl> create(WebLayerTreeViewClient*, const WebLayer& root, const WebLayerTreeView::Settings&);
     virtual ~WebLayerTreeViewImpl();
 
-    virtual void willBeginFrame() OVERRIDE;
-    virtual void didBeginFrame() OVERRIDE;
-    virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE;
-    virtual void layout() OVERRIDE;
-    virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale) OVERRIDE;
-    virtual PassRefPtr<WebCore::GraphicsContext3D> createContext() OVERRIDE;
-    virtual void didRecreateContext(bool success) OVERRIDE;
-    virtual void willCommit() OVERRIDE;
-    virtual void didCommit() OVERRIDE;
-    virtual void didCommitAndDrawFrame() OVERRIDE;
-    virtual void didCompleteSwapBuffers() OVERRIDE;
+    WebCore::CCLayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); }
 
-    // Only used in the single threaded path.
-    virtual void scheduleComposite() OVERRIDE;
-
 private:
     WebLayerTreeViewImpl(WebLayerTreeViewClient*, const WebLayerTreeView::Settings&);
 
-    WebLayerTreeViewClient* m_client;
+    OwnPtr<WebLayerTreeViewClientAdapter> m_clientAdapter;
+    OwnPtr<WebCore::CCLayerTreeHost> m_layerTreeHost;
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to