Skip to content
Permalink
Browse files
[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.

Canonical link: https://commits.webkit.org/184594@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Jan 29, 2017
1 parent 8fb901b commit 215f2f638cedfd342ba8c49c561547bd170be713
@@ -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
@@ -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();
@@ -66,7 +66,7 @@ void SimpleViewportController::didChangeViewportAttributes(const ViewportAttribu

m_hasViewportAttribute = true;

m_rawAttributes = newAttributes;
m_rawAttributes = WTFMove(newAttributes);
m_allowsUserScaling = m_rawAttributes.userScalable;
m_initiallyFitToViewport = m_rawAttributes.initialScale < 0;

@@ -41,7 +41,7 @@ class SimpleViewportController {

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;
@@ -371,6 +371,22 @@ void AcceleratedDrawingArea::destroyNativeSurfaceHandleForCompositing(bool& hand
}
#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) {
@@ -73,6 +73,14 @@ class AcceleratedDrawingArea : public DrawingArea {

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;

@@ -139,9 +139,9 @@ void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
didChangeViewport();
}

void ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties(const ViewportAttributes& attr)
void ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes(ViewportAttributes&& attr)
{
m_viewportController.didChangeViewportAttributes(attr);
m_viewportController.didChangeViewportAttributes(WTFMove(attr));
didChangeViewport();
}

@@ -59,7 +59,7 @@ class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost {
void pageBackgroundTransparencyChanged() override;

void contentsSizeChanged(const WebCore::IntSize&) override;
void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override;

void invalidate() override;

@@ -52,6 +52,7 @@ class FrameView;
class GraphicsLayer;
class GraphicsLayerFactory;
class MachSendRight;
struct ViewportAttributes;
}

namespace WebKit {
@@ -140,6 +141,14 @@ class DrawingArea : public IPC::MessageReceiver {

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&);

@@ -71,7 +71,6 @@ class LayerTreeHost : public RefCounted<LayerTreeHost> {
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();
@@ -85,7 +84,7 @@ class LayerTreeHost : public RefCounted<LayerTreeHost> {

#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)
@@ -96,6 +95,10 @@ class LayerTreeHost : public RefCounted<LayerTreeHost> {
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:
@@ -237,10 +237,6 @@
#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
@@ -1429,8 +1425,7 @@ void WebPage::sendViewportAttributesChanged(const ViewportArguments& viewportArg
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
@@ -1588,8 +1583,7 @@ void WebPage::scalePage(double scale, const IntPoint& origin)
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));
@@ -1666,8 +1660,7 @@ void WebPage::setDeviceScaleFactor(float scaleFactor)
}

#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
if (m_drawingArea->layerTreeHost())
m_drawingArea->layerTreeHost()->deviceOrPageScaleFactorChanged();
m_drawingArea->deviceOrPageScaleFactorChanged();
#endif
}

@@ -1751,8 +1744,8 @@ void WebPage::viewportPropertiesDidChange(const ViewportArguments& viewportArgum
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

0 comments on commit 215f2f6

Please sign in to comment.