[Coordinated Graphics] WebPage shouldn't use the layerTreeHost directly
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jan 2017 10:06:30 +0000 (10:06 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jan 2017 10:06:30 +0000 (10:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167494

Reviewed by Michael Catanzaro.

In Coordinated Graphics we have a couple of methods that the WebPage uses directly from the layer tree host,
instead of using the drawing area interface. This patch adds DrawingArea::didChangeViewportAttributes and
DrawingArea::deviceOrPageScaleFactorChanged and renames LayerTreeHost::didChangeViewportProperties as
LayerTreeHost::didChangeViewportAttributes for consistency.

* Shared/CoordinatedGraphics/SimpleViewportController.cpp:
(WebKit::SimpleViewportController::didChangeViewportAttributes): Receive an rvalue reference to avoid copies.
* Shared/CoordinatedGraphics/SimpleViewportController.h:
* WebProcess/WebPage/AcceleratedDrawingArea.cpp:
(WebKit::AcceleratedDrawingArea::didChangeViewportAttributes): Forward it to the layer tree host if any.
(WebKit::AcceleratedDrawingArea::deviceOrPageScaleFactorChanged): Ditto.
* WebProcess/WebPage/AcceleratedDrawingArea.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes): Renamed and updated to pass an rvalue reference.
(WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties): Deleted.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/DrawingArea.h:
* WebProcess/WebPage/LayerTreeHost.h:
(WebKit::LayerTreeHost::didChangeViewportAttributes): Renamed and updated to pass an rvalue reference.
(WebKit::LayerTreeHost::didChangeViewportProperties): Deleted.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::sendViewportAttributesChanged): Use the drawing area.
(WebKit::WebPage::scalePage): Ditto
(WebKit::WebPage::setDeviceScaleFactor): Ditto.
(WebKit::WebPage::viewportPropertiesDidChange): Ditto.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp
Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h
Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp
Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index f1e9c80..1c9f867 100644 (file)
@@ -1,3 +1,36 @@
+2017-01-29  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [Coordinated Graphics] WebPage shouldn't use the layerTreeHost directly
+        https://bugs.webkit.org/show_bug.cgi?id=167494
+
+        Reviewed by Michael Catanzaro.
+
+        In Coordinated Graphics we have a couple of methods that the WebPage uses directly from the layer tree host,
+        instead of using the drawing area interface. This patch adds DrawingArea::didChangeViewportAttributes and
+        DrawingArea::deviceOrPageScaleFactorChanged and renames LayerTreeHost::didChangeViewportProperties as
+        LayerTreeHost::didChangeViewportAttributes for consistency.
+
+        * Shared/CoordinatedGraphics/SimpleViewportController.cpp:
+        (WebKit::SimpleViewportController::didChangeViewportAttributes): Receive an rvalue reference to avoid copies.
+        * Shared/CoordinatedGraphics/SimpleViewportController.h:
+        * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
+        (WebKit::AcceleratedDrawingArea::didChangeViewportAttributes): Forward it to the layer tree host if any.
+        (WebKit::AcceleratedDrawingArea::deviceOrPageScaleFactorChanged): Ditto.
+        * WebProcess/WebPage/AcceleratedDrawingArea.h:
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes): Renamed and updated to pass an rvalue reference.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties): Deleted.
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/DrawingArea.h:
+        * WebProcess/WebPage/LayerTreeHost.h:
+        (WebKit::LayerTreeHost::didChangeViewportAttributes): Renamed and updated to pass an rvalue reference.
+        (WebKit::LayerTreeHost::didChangeViewportProperties): Deleted.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::sendViewportAttributesChanged): Use the drawing area.
+        (WebKit::WebPage::scalePage): Ditto
+        (WebKit::WebPage::setDeviceScaleFactor): Ditto.
+        (WebKit::WebPage::viewportPropertiesDidChange): Ditto.
+
 2017-01-28  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [Threaded Compositor] Crash when detaching the CoordinatedGraphicsScene
 2017-01-28  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [Threaded Compositor] Crash when detaching the CoordinatedGraphicsScene
index bfb6ed3..a5eaafe 100644 (file)
@@ -57,7 +57,7 @@ void SimpleViewportController::didChangeContentsSize(const IntSize& newSize)
     }
 }
 
     }
 }
 
-void SimpleViewportController::didChangeViewportAttributes(const ViewportAttributes& newAttributes)
+void SimpleViewportController::didChangeViewportAttributes(ViewportAttributes&& newAttributes)
 {
     if (newAttributes.layoutSize.isEmpty()) {
         resetViewportToDefaultState();
 {
     if (newAttributes.layoutSize.isEmpty()) {
         resetViewportToDefaultState();
@@ -66,7 +66,7 @@ void SimpleViewportController::didChangeViewportAttributes(const ViewportAttribu
 
     m_hasViewportAttribute = true;
 
 
     m_hasViewportAttribute = true;
 
-    m_rawAttributes = newAttributes;
+    m_rawAttributes = WTFMove(newAttributes);
     m_allowsUserScaling = m_rawAttributes.userScalable;
     m_initiallyFitToViewport = m_rawAttributes.initialScale < 0;
 
     m_allowsUserScaling = m_rawAttributes.userScalable;
     m_initiallyFitToViewport = m_rawAttributes.initialScale < 0;
 
index a311cd3..0bd1a35 100644 (file)
@@ -41,7 +41,7 @@ public:
 
     void didChangeViewportSize(const WebCore::IntSize&);
     void didChangeContentsSize(const WebCore::IntSize&);
 
     void didChangeViewportSize(const WebCore::IntSize&);
     void didChangeContentsSize(const WebCore::IntSize&);
-    void didChangeViewportAttributes(const WebCore::ViewportAttributes&);
+    void didChangeViewportAttributes(WebCore::ViewportAttributes&&);
     void didScroll(const WebCore::IntPoint&);
 
     WebCore::FloatRect visibleContentsRect() const;
     void didScroll(const WebCore::IntPoint&);
 
     WebCore::FloatRect visibleContentsRect() const;
index 0247ca5..fd9d308 100644 (file)
@@ -371,6 +371,22 @@ void AcceleratedDrawingArea::destroyNativeSurfaceHandleForCompositing(bool& hand
 }
 #endif
 
 }
 #endif
 
+#if USE(COORDINATED_GRAPHICS_THREADED)
+void AcceleratedDrawingArea::didChangeViewportAttributes(ViewportAttributes&& attrs)
+{
+    if (m_layerTreeHost)
+        m_layerTreeHost->didChangeViewportAttributes(WTFMove(attrs));
+}
+#endif
+
+#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
+void AcceleratedDrawingArea::deviceOrPageScaleFactorChanged()
+{
+    if (m_layerTreeHost)
+        m_layerTreeHost->deviceOrPageScaleFactorChanged();
+}
+#endif
+
 void AcceleratedDrawingArea::activityStateDidChange(ActivityState::Flags changed, bool, const Vector<uint64_t>&)
 {
     if (changed & ActivityState::IsVisible) {
 void AcceleratedDrawingArea::activityStateDidChange(ActivityState::Flags changed, bool, const Vector<uint64_t>&)
 {
     if (changed & ActivityState::IsVisible) {
index c84ee38..4f9754f 100644 (file)
@@ -73,6 +73,14 @@ protected:
 
     void layerHostDidFlushLayers() override;
 
 
     void layerHostDidFlushLayers() override;
 
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override;
+#endif
+
+#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
+    void deviceOrPageScaleFactorChanged() override;
+#endif
+
     // IPC message handlers.
     void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override;
 
     // IPC message handlers.
     void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override;
 
index c584c5d..48928b7 100644 (file)
@@ -139,9 +139,9 @@ void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
     didChangeViewport();
 }
 
     didChangeViewport();
 }
 
-void ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties(const ViewportAttributes& attr)
+void ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes(ViewportAttributes&& attr)
 {
 {
-    m_viewportController.didChangeViewportAttributes(attr);
+    m_viewportController.didChangeViewportAttributes(WTFMove(attr));
     didChangeViewport();
 }
 
     didChangeViewport();
 }
 
index 7cd44f8..85ccde1 100644 (file)
@@ -59,7 +59,7 @@ private:
     void pageBackgroundTransparencyChanged() override;
 
     void contentsSizeChanged(const WebCore::IntSize&) override;
     void pageBackgroundTransparencyChanged() override;
 
     void contentsSizeChanged(const WebCore::IntSize&) override;
-    void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
+    void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override;
 
     void invalidate() override;
 
 
     void invalidate() override;
 
index 8e4d09c..0d69c17 100644 (file)
@@ -52,6 +52,7 @@ class FrameView;
 class GraphicsLayer;
 class GraphicsLayerFactory;
 class MachSendRight;
 class GraphicsLayer;
 class GraphicsLayerFactory;
 class MachSendRight;
+struct ViewportAttributes;
 }
 
 namespace WebKit {
 }
 
 namespace WebKit {
@@ -140,6 +141,14 @@ public:
 
     virtual void layerHostDidFlushLayers() { };
 
 
     virtual void layerHostDidFlushLayers() { };
 
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    virtual void didChangeViewportAttributes(WebCore::ViewportAttributes&&) = 0;
+#endif
+
+#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
+    virtual void deviceOrPageScaleFactorChanged() = 0;
+#endif
+
 protected:
     DrawingArea(DrawingAreaType, WebPage&);
 
 protected:
     DrawingArea(DrawingAreaType, WebPage&);
 
index 584f7ad..3c64686 100644 (file)
@@ -71,7 +71,6 @@ public:
     virtual void forceRepaint() = 0;
     virtual bool forceRepaintAsync(uint64_t /*callbackID*/) { return false; }
     virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0;
     virtual void forceRepaint() = 0;
     virtual bool forceRepaintAsync(uint64_t /*callbackID*/) { return false; }
     virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0;
-    virtual void deviceOrPageScaleFactorChanged() = 0;
     virtual void pageBackgroundTransparencyChanged() = 0;
 
     virtual void pauseRendering();
     virtual void pageBackgroundTransparencyChanged() = 0;
 
     virtual void pauseRendering();
@@ -85,7 +84,7 @@ public:
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
     virtual void contentsSizeChanged(const WebCore::IntSize&) { };
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
     virtual void contentsSizeChanged(const WebCore::IntSize&) { };
-    virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) { };
+    virtual void didChangeViewportAttributes(WebCore::ViewportAttributes&&) { };
 #endif
 
 #if USE(COORDINATED_GRAPHICS)
 #endif
 
 #if USE(COORDINATED_GRAPHICS)
@@ -96,6 +95,10 @@ public:
     virtual void setNativeSurfaceHandleForCompositing(uint64_t) { };
 #endif
 
     virtual void setNativeSurfaceHandleForCompositing(uint64_t) { };
 #endif
 
+#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
+    virtual void deviceOrPageScaleFactorChanged() = 0;
+#endif
+
     virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverlayRootLayer) { m_viewOverlayRootLayer = viewOverlayRootLayer; }
 
 protected:
     virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverlayRootLayer) { m_viewOverlayRootLayer = viewOverlayRootLayer; }
 
 protected:
index 92af536..f55b64a 100644 (file)
 #include <wtf/RefCountedLeakCounter.h>
 #endif
 
 #include <wtf/RefCountedLeakCounter.h>
 #endif
 
-#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
-#include "LayerTreeHost.h"
-#endif
-
 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
 #include "CoordinatedLayerTreeHostMessages.h"
 #endif
 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
 #include "CoordinatedLayerTreeHostMessages.h"
 #endif
@@ -1429,8 +1425,7 @@ void WebPage::sendViewportAttributesChanged(const ViewportArguments& viewportArg
     setFixedLayoutSize(roundedIntSize(attr.layoutSize));
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
     setFixedLayoutSize(roundedIntSize(attr.layoutSize));
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
-    if (m_drawingArea->layerTreeHost())
-        m_drawingArea->layerTreeHost()->didChangeViewportProperties(attr);
+    m_drawingArea->didChangeViewportAttributes(WTFMove(attr));
 #else
     send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
 #endif
 #else
     send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
 #endif
@@ -1588,8 +1583,7 @@ void WebPage::scalePage(double scale, const IntPoint& origin)
         pluginView->pageScaleFactorDidChange();
 
 #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
         pluginView->pageScaleFactorDidChange();
 
 #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
-    if (m_drawingArea->layerTreeHost())
-        m_drawingArea->layerTreeHost()->deviceOrPageScaleFactorChanged();
+    m_drawingArea->deviceOrPageScaleFactorChanged();
 #endif
 
     send(Messages::WebPageProxy::PageScaleFactorDidChange(scale));
 #endif
 
     send(Messages::WebPageProxy::PageScaleFactorDidChange(scale));
@@ -1666,8 +1660,7 @@ void WebPage::setDeviceScaleFactor(float scaleFactor)
     }
 
 #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
     }
 
 #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
-    if (m_drawingArea->layerTreeHost())
-        m_drawingArea->layerTreeHost()->deviceOrPageScaleFactorChanged();
+    m_drawingArea->deviceOrPageScaleFactorChanged();
 #endif
 }
 
 #endif
 }
 
@@ -1751,8 +1744,8 @@ void WebPage::viewportPropertiesDidChange(const ViewportArguments& viewportArgum
     if (view && view->useFixedLayout())
         sendViewportAttributesChanged(viewportArguments);
 #if USE(COORDINATED_GRAPHICS_THREADED)
     if (view && view->useFixedLayout())
         sendViewportAttributesChanged(viewportArguments);
 #if USE(COORDINATED_GRAPHICS_THREADED)
-    else if (auto* layerTreeHost = m_drawingArea->layerTreeHost())
-        layerTreeHost->didChangeViewportProperties(ViewportAttributes());
+    else
+        m_drawingArea->didChangeViewportAttributes(ViewportAttributes());
 #endif
 #endif
 
 #endif
 #endif