Title: [201802] trunk/Source/WebKit2
Revision
201802
Author
carlo...@webkit.org
Date
2016-06-08 05:13:11 -0700 (Wed, 08 Jun 2016)

Log Message

LayerTreeHost should be created with a WebPage reference instead of a pointer
https://bugs.webkit.org/show_bug.cgi?id=158520

Reviewed by Žan Doberšek.

We are indeed creating the LayerTreeHost always from a WebPage reference but getting its address to pass it to
the LayerTreeHost create() function.

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp:
(WebKit::CoordinatedDrawingArea::enterAcceleratedCompositingMode):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::create):
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::didFlushRootLayer):
(WebKit::CoordinatedLayerTreeHost::performScheduledLayerFlush):
(WebKit::CoordinatedLayerTreeHost::commitSceneState):
(WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::create):
(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost):
(WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::ThreadedCoordinatedLayerTreeHost::compositorDidFlushLayers):
(WebKit::ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged):
(WebKit::ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect):
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode):
* WebProcess/WebPage/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::create):
(WebKit::LayerTreeHost::LayerTreeHost):
* WebProcess/WebPage/LayerTreeHost.h:
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::create):
(WebKit::LayerTreeHostGtk::LayerTreeHostGtk):
(WebKit::LayerTreeHostGtk::makeContextCurrent):
(WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged):
(WebKit::LayerTreeHostGtk::paintContents):
(WebKit::LayerTreeHostGtk::deviceScaleFactor):
(WebKit::LayerTreeHostGtk::pageScaleFactor):
(WebKit::LayerTreeHostGtk::flushPendingLayerChanges):
(WebKit::LayerTreeHostGtk::flushAndRenderLayers):
(WebKit::LayerTreeHostGtk::pageBackgroundTransparencyChanged):
(WebKit::LayerTreeHostGtk::initialize): Deleted.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (201801 => 201802)


--- trunk/Source/WebKit2/ChangeLog	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/ChangeLog	2016-06-08 12:13:11 UTC (rev 201802)
@@ -1,3 +1,51 @@
+2016-06-08  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        LayerTreeHost should be created with a WebPage reference instead of a pointer
+        https://bugs.webkit.org/show_bug.cgi?id=158520
+
+        Reviewed by Žan Doberšek.
+
+        We are indeed creating the LayerTreeHost always from a WebPage reference but getting its address to pass it to
+        the LayerTreeHost create() function.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp:
+        (WebKit::CoordinatedDrawingArea::enterAcceleratedCompositingMode):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::create):
+        (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
+        (WebKit::CoordinatedLayerTreeHost::didFlushRootLayer):
+        (WebKit::CoordinatedLayerTreeHost::performScheduledLayerFlush):
+        (WebKit::CoordinatedLayerTreeHost::commitSceneState):
+        (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::create):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::compositorDidFlushLayers):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect):
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode):
+        * WebProcess/WebPage/LayerTreeHost.cpp:
+        (WebKit::LayerTreeHost::create):
+        (WebKit::LayerTreeHost::LayerTreeHost):
+        * WebProcess/WebPage/LayerTreeHost.h:
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+        (WebKit::LayerTreeHostGtk::create):
+        (WebKit::LayerTreeHostGtk::LayerTreeHostGtk):
+        (WebKit::LayerTreeHostGtk::makeContextCurrent):
+        (WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged):
+        (WebKit::LayerTreeHostGtk::paintContents):
+        (WebKit::LayerTreeHostGtk::deviceScaleFactor):
+        (WebKit::LayerTreeHostGtk::pageScaleFactor):
+        (WebKit::LayerTreeHostGtk::flushPendingLayerChanges):
+        (WebKit::LayerTreeHostGtk::flushAndRenderLayers):
+        (WebKit::LayerTreeHostGtk::pageBackgroundTransparencyChanged):
+        (WebKit::LayerTreeHostGtk::initialize): Deleted.
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
+
 2016-06-07  Sam Weinig  <s...@webkit.org>
 
         Fix 10.10 build.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp	2016-06-08 12:13:11 UTC (rev 201802)
@@ -306,7 +306,7 @@
     m_exitCompositingTimer.stop();
     m_wantsToExitAcceleratedCompositingMode = false;
 
-    m_layerTreeHost = LayerTreeHost::create(&m_webPage);
+    m_layerTreeHost = LayerTreeHost::create(m_webPage);
     if (!m_inUpdateBackingStoreState)
         m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2016-06-08 12:13:11 UTC (rev 201802)
@@ -49,7 +49,7 @@
 
 namespace WebKit {
 
-Ref<CoordinatedLayerTreeHost> CoordinatedLayerTreeHost::create(WebPage* webPage)
+Ref<CoordinatedLayerTreeHost> CoordinatedLayerTreeHost::create(WebPage& webPage)
 {
     return adoptRef(*new CoordinatedLayerTreeHost(webPage));
 }
@@ -58,7 +58,7 @@
 {
 }
 
-CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
+CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage& webPage)
     : LayerTreeHost(webPage)
     , m_notifyAfterScheduledLayerFlush(false)
     , m_isValid(true)
@@ -69,9 +69,9 @@
     , m_forceRepaintAsyncCallbackID(0)
     , m_viewOverlayRootLayer(nullptr)
 {
-    m_coordinator = std::make_unique<CompositingCoordinator>(webPage->corePage(), this);
+    m_coordinator = std::make_unique<CompositingCoordinator>(m_webPage.corePage(), this);
 
-    m_coordinator->createRootLayer(webPage->size());
+    m_coordinator->createRootLayer(m_webPage.size());
     m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id();
 
     CoordinatedSurface::setFactory(createCoordinatedSurface);
@@ -186,7 +186,7 @@
 {
     // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually.
     if (m_viewOverlayRootLayer)
-        m_viewOverlayRootLayer->flushCompositingState(visibleContentRect,  m_webPage->mainFrame()->view()->viewportIsStable());
+        m_viewOverlayRootLayer->flushCompositingState(visibleContentRect,  m_webPage.mainFrame()->view()->viewportIsStable());
 }
 
 void CoordinatedLayerTreeHost::performScheduledLayerFlush()
@@ -202,12 +202,12 @@
     bool didSync = m_coordinator->flushPendingLayerChanges();
 
     if (m_forceRepaintAsyncCallbackID) {
-        m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID));
+        m_webPage.send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID));
         m_forceRepaintAsyncCallbackID = 0;
     }
 
     if (m_notifyAfterScheduledLayerFlush && didSync) {
-        static_cast<CoordinatedDrawingArea*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
+        static_cast<CoordinatedDrawingArea*>(m_webPage.drawingArea())->layerHostDidFlushLayers();
         m_notifyAfterScheduledLayerFlush = false;
     }
 }
@@ -223,7 +223,7 @@
 
 void CoordinatedLayerTreeHost::commitSceneState(const WebCore::CoordinatedGraphicsState& state)
 {
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state));
+    m_webPage.send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state));
     m_isWaitingForRenderer = true;
 }
 
@@ -235,7 +235,7 @@
 void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
 {
     m_coordinator->deviceOrPageScaleFactorChanged();
-    m_webPage->mainFrame()->pageOverlayController().didChangeDeviceScaleFactor();
+    m_webPage.mainFrame()->pageOverlayController().didChangeDeviceScaleFactor();
 }
 
 void CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h	2016-06-08 12:13:11 UTC (rev 201802)
@@ -40,7 +40,7 @@
 class CoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::CompositingCoordinator::Client
 {
 public:
-    static Ref<CoordinatedLayerTreeHost> create(WebPage*);
+    static Ref<CoordinatedLayerTreeHost> create(WebPage&);
     virtual ~CoordinatedLayerTreeHost();
 
     const LayerTreeContext& layerTreeContext() override { return m_layerTreeContext; }
@@ -75,7 +75,7 @@
     static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
 
 protected:
-    explicit CoordinatedLayerTreeHost(WebPage*);
+    explicit CoordinatedLayerTreeHost(WebPage&);
 
 private:
     // CoordinatedLayerTreeHost

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp	2016-06-08 12:13:11 UTC (rev 201802)
@@ -48,7 +48,7 @@
 
 namespace WebKit {
 
-Ref<ThreadedCoordinatedLayerTreeHost> ThreadedCoordinatedLayerTreeHost::create(WebPage* webPage)
+Ref<ThreadedCoordinatedLayerTreeHost> ThreadedCoordinatedLayerTreeHost::create(WebPage webPage)
 {
     return adoptRef(*new ThreadedCoordinatedLayerTreeHost(webPage));
 }
@@ -57,7 +57,7 @@
 {
 }
 
-ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage* webPage)
+ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webPage)
     : LayerTreeHost(webPage)
     , m_forceRepaintAsyncCallbackID(0)
     , m_notifyAfterScheduledLayerFlush(false)
@@ -66,9 +66,9 @@
     , m_layerFlushTimer(RunLoop::main(), this, &ThreadedCoordinatedLayerTreeHost::performScheduledLayerFlush)
     , m_layerFlushSchedulingEnabled(true)
 {
-    m_coordinator = std::make_unique<CompositingCoordinator>(m_webPage->corePage(), this);
+    m_coordinator = std::make_unique<CompositingCoordinator>(m_webPage.corePage(), this);
 
-    m_coordinator->createRootLayer(m_webPage->size());
+    m_coordinator->createRootLayer(m_webPage.size());
 
     CoordinatedSurface::setFactory(createCoordinatedSurface);
 
@@ -149,7 +149,7 @@
 void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
 {
     m_coordinator->deviceOrPageScaleFactorChanged();
-    m_compositor->setDeviceScaleFactor(m_webPage->deviceScaleFactor());
+    m_compositor->setDeviceScaleFactor(m_webPage.deviceScaleFactor());
 }
 
 void ThreadedCoordinatedLayerTreeHost::pauseRendering()
@@ -180,12 +180,12 @@
 
 void ThreadedCoordinatedLayerTreeHost::compositorDidFlushLayers()
 {
-    static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
+    static_cast<DrawingAreaImpl*>(m_webPage.drawingArea())->layerHostDidFlushLayers();
 }
 
 void ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged(float scale, const IntPoint& origin)
 {
-    m_webPage->scalePage(scale, origin);
+    m_webPage.scalePage(scale, origin);
 }
 
 void ThreadedCoordinatedLayerTreeHost::setViewOverlayRootLayer(GraphicsLayer* graphicsLayer)
@@ -221,8 +221,8 @@
     if (m_lastScrollPosition != roundedIntPoint(rect.location())) {
         m_lastScrollPosition = roundedIntPoint(rect.location());
 
-        if (!m_webPage->corePage()->mainFrame().view()->useFixedLayout())
-            m_webPage->corePage()->mainFrame().view()->notifyScrollPositionChanged(m_lastScrollPosition);
+        if (!m_webPage.corePage()->mainFrame().view()->useFixedLayout())
+            m_webPage.corePage()->mainFrame().view()->notifyScrollPositionChanged(m_lastScrollPosition);
     }
 
     if (m_lastScaleFactor != scale) {

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h	2016-06-08 12:13:11 UTC (rev 201802)
@@ -61,7 +61,7 @@
 class ThreadedCoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::CompositingCoordinator::Client, public ThreadedCompositor::Client {
     WTF_MAKE_NONCOPYABLE(ThreadedCoordinatedLayerTreeHost); WTF_MAKE_FAST_ALLOCATED;
 public:
-    static Ref<ThreadedCoordinatedLayerTreeHost> create(WebPage*);
+    static Ref<ThreadedCoordinatedLayerTreeHost> create(WebPage&);
     virtual ~ThreadedCoordinatedLayerTreeHost();
 
     const LayerTreeContext& layerTreeContext() override { return m_layerTreeContext; };
@@ -101,7 +101,7 @@
     static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
 
 protected:
-    explicit ThreadedCoordinatedLayerTreeHost(WebPage*);
+    explicit ThreadedCoordinatedLayerTreeHost(WebPage&);
 
 private:
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp	2016-06-08 12:13:11 UTC (rev 201802)
@@ -471,7 +471,7 @@
 
     ASSERT(!m_layerTreeHost);
 
-    m_layerTreeHost = LayerTreeHost::create(&m_webPage);
+    m_layerTreeHost = LayerTreeHost::create(m_webPage);
 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
     if (m_nativeSurfaceHandleForCompositing)
         m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp	2016-06-08 12:13:11 UTC (rev 201802)
@@ -41,7 +41,7 @@
 
 namespace WebKit {
 
-PassRefPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage)
+RefPtr<LayerTreeHost> LayerTreeHost::create(WebPage& webPage)
 {
 #if USE(COORDINATED_GRAPHICS_THREADED)
     return ThreadedCoordinatedLayerTreeHost::create(webPage);
@@ -51,11 +51,11 @@
     return LayerTreeHostGtk::create(webPage);
 #else
     UNUSED_PARAM(webPage);
-    return 0;
+    return nullptr;
 #endif
 }
 
-LayerTreeHost::LayerTreeHost(WebPage* webPage)
+LayerTreeHost::LayerTreeHost(WebPage& webPage)
     : m_webPage(webPage)
 {
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h	2016-06-08 12:13:11 UTC (rev 201802)
@@ -57,7 +57,7 @@
 
 class LayerTreeHost : public RefCounted<LayerTreeHost> {
 public:
-    static PassRefPtr<LayerTreeHost> create(WebPage*);
+    static RefPtr<LayerTreeHost> create(WebPage&);
     virtual ~LayerTreeHost();
 
     virtual const LayerTreeContext& layerTreeContext() = 0;
@@ -101,9 +101,9 @@
     virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer*) = 0;
 
 protected:
-    explicit LayerTreeHost(WebPage*);
+    explicit LayerTreeHost(WebPage&);
 
-    WebPage* m_webPage;
+    WebPage& m_webPage;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp	2016-06-08 12:13:11 UTC (rev 201802)
@@ -126,14 +126,12 @@
     nextFrame();
 }
 
-PassRefPtr<LayerTreeHostGtk> LayerTreeHostGtk::create(WebPage* webPage)
+Ref<LayerTreeHostGtk> LayerTreeHostGtk::create(WebPage& webPage)
 {
-    RefPtr<LayerTreeHostGtk> host = adoptRef(new LayerTreeHostGtk(webPage));
-    host->initialize();
-    return host.release();
+    return adoptRef(*new LayerTreeHostGtk(webPage));
 }
 
-LayerTreeHostGtk::LayerTreeHostGtk(WebPage* webPage)
+LayerTreeHostGtk::LayerTreeHostGtk(WebPage& webPage)
     : LayerTreeHost(webPage)
     , m_isValid(true)
     , m_notifyAfterScheduledLayerFlush(false)
@@ -141,41 +139,21 @@
     , m_viewOverlayRootLayer(nullptr)
     , m_renderFrameScheduler(std::bind(&LayerTreeHostGtk::renderFrame, this))
 {
-}
-
-bool LayerTreeHostGtk::makeContextCurrent()
-{
-    if (!m_layerTreeContext.contextID) {
-        m_context = nullptr;
-        return false;
-    }
-
-    if (!m_context) {
-        m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_layerTreeContext.contextID), GLContext::sharingContext());
-        if (!m_context)
-            return false;
-    }
-
-    return m_context->makeContextCurrent();
-}
-
-void LayerTreeHostGtk::initialize()
-{
     m_rootLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
     m_rootLayer->setDrawsContent(false);
-    m_rootLayer->setSize(m_webPage->size());
+    m_rootLayer->setSize(m_webPage.size());
 
     m_scaleMatrix.makeIdentity();
-    m_scaleMatrix.scale(m_webPage->deviceScaleFactor() * m_webPage->pageScaleFactor());
+    m_scaleMatrix.scale(m_webPage.deviceScaleFactor() * m_webPage.pageScaleFactor());
     downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setAnchorPoint(FloatPoint3D());
     downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTransform(m_scaleMatrix);
 
     // The non-composited contents are a child of the root layer.
     m_nonCompositedContentLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
     m_nonCompositedContentLayer->setDrawsContent(true);
-    m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground());
-    m_nonCompositedContentLayer->setSize(m_webPage->size());
-    if (m_webPage->corePage()->settings().acceleratedDrawingEnabled())
+    m_nonCompositedContentLayer->setContentsOpaque(m_webPage.drawsBackground());
+    m_nonCompositedContentLayer->setSize(m_webPage.size());
+    if (m_webPage.corePage()->settings().acceleratedDrawingEnabled())
         m_nonCompositedContentLayer->setAcceleratesDrawing(true);
 
 #ifndef NDEBUG
@@ -187,6 +165,22 @@
     m_nonCompositedContentLayer->setNeedsDisplay();
 }
 
+bool LayerTreeHostGtk::makeContextCurrent()
+{
+    if (!m_layerTreeContext.contextID) {
+        m_context = nullptr;
+        return false;
+    }
+
+    if (!m_context) {
+        m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_layerTreeContext.contextID), GLContext::sharingContext());
+        if (!m_context)
+            return false;
+    }
+
+    return m_context->makeContextCurrent();
+}
+
 LayerTreeHostGtk::~LayerTreeHostGtk()
 {
     ASSERT(!m_isValid);
@@ -279,7 +273,7 @@
     m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
 
     m_scaleMatrix.makeIdentity();
-    m_scaleMatrix.scale(m_webPage->deviceScaleFactor() * m_webPage->pageScaleFactor());
+    m_scaleMatrix.scale(m_webPage.deviceScaleFactor() * m_webPage.pageScaleFactor());
     downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTransform(m_scaleMatrix);
 }
 
@@ -291,17 +285,17 @@
 void LayerTreeHostGtk::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect& clipRect)
 {
     if (graphicsLayer == m_nonCompositedContentLayer.get())
-        m_webPage->drawRect(graphicsContext, enclosingIntRect(clipRect));
+        m_webPage.drawRect(graphicsContext, enclosingIntRect(clipRect));
 }
 
 float LayerTreeHostGtk::deviceScaleFactor() const
 {
-    return m_webPage->deviceScaleFactor();
+    return m_webPage.deviceScaleFactor();
 }
 
 float LayerTreeHostGtk::pageScaleFactor() const
 {
-    return m_webPage->pageScaleFactor();
+    return m_webPage.pageScaleFactor();
 }
 
 bool LayerTreeHostGtk::renderFrame()
@@ -312,11 +306,11 @@
 
 bool LayerTreeHostGtk::flushPendingLayerChanges()
 {
-    bool viewportIsStable = m_webPage->corePage()->mainFrame().view()->viewportIsStable();
+    bool viewportIsStable = m_webPage.corePage()->mainFrame().view()->viewportIsStable();
     m_rootLayer->flushCompositingStateForThisLayerOnly(viewportIsStable);
     m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(viewportIsStable);
 
-    if (!m_webPage->corePage()->mainFrame().view()->flushCompositingStateIncludingSubframes())
+    if (!m_webPage.corePage()->mainFrame().view()->flushCompositingStateIncludingSubframes())
         return false;
 
     if (m_viewOverlayRootLayer)
@@ -354,7 +348,7 @@
 {
     {
         RefPtr<LayerTreeHostGtk> protect(this);
-        m_webPage->layoutIfNeeded();
+        m_webPage.layoutIfNeeded();
 
         if (!m_isValid)
             return;
@@ -371,7 +365,7 @@
 
     if (m_notifyAfterScheduledLayerFlush) {
         // Let the drawing area know that we've done a flush of the layer changes.
-        static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
+        static_cast<DrawingAreaImpl*>(m_webPage.drawingArea())->layerHostDidFlushLayers();
         m_notifyAfterScheduledLayerFlush = false;
     }
 }
@@ -401,7 +395,7 @@
 
 void LayerTreeHostGtk::pageBackgroundTransparencyChanged()
 {
-    m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground());
+    m_nonCompositedContentLayer->setContentsOpaque(m_webPage.drawsBackground());
 }
 
 void LayerTreeHostGtk::cancelPendingLayerFlush()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h (201801 => 201802)


--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h	2016-06-08 09:06:07 UTC (rev 201801)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h	2016-06-08 12:13:11 UTC (rev 201802)
@@ -41,16 +41,14 @@
 
 class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClient {
 public:
-    static PassRefPtr<LayerTreeHostGtk> create(WebPage*);
+    static Ref<LayerTreeHostGtk> create(WebPage&);
     virtual ~LayerTreeHostGtk();
 
-protected:
-    explicit LayerTreeHostGtk(WebPage*);
+private:
+    explicit LayerTreeHostGtk(WebPage&);
 
     WebCore::GraphicsLayer* rootLayer() const { return m_rootLayer.get(); }
 
-    void initialize();
-
     // LayerTreeHost
     void scheduleLayerFlush() override;
     void setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) override;
@@ -64,8 +62,6 @@
 
     void setNativeSurfaceHandleForCompositing(uint64_t) override;
 
-private:
-
     class RenderFrameScheduler {
     public:
         RenderFrameScheduler(std::function<bool()>);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to