Duplicated code in DrawingAreaProxyImpl and CoordinatedDrawingAreaProxy
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Aug 2016 05:38:27 +0000 (05:38 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Aug 2016 05:38:27 +0000 (05:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160506

Reviewed by Michael Catanzaro.

Same logic as in r202855 but in the UI process. CoordinatedDrawingAreaProxy is just a copy paste of
DrawingAreaProxyImpl with non-accelerated code path removed. There's actually nothing (or very little) specific
to coordinated graphics in the CoordinatedDrawingAreaProxy implementation. This patch renames
CoordinatedDrawingAreaProxy as AcceleratedDrawingAreaProxy and makes DrawingAreaProxyImpl inherit from it, so
that in case of accelerated compositing the parent class is used, and DrawingAreaProxyImpl only adds the non
accelerated code path.
To simplify the common API of AcceleratedDrawingAreaProxy, I have changed CoordinatedLayerTreeHostProxy to
receive a WebPageProxy in the constructor instead of a drawing area, since the drawing area was used just to get
the page proxy.

* PlatformEfl.cmake:
* PlatformGTK.cmake:
* UIProcess/AcceleratedDrawingAreaProxy.cpp: Renamed from Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.cpp.
(WebKit::AcceleratedDrawingAreaProxy::AcceleratedDrawingAreaProxy):
(WebKit::AcceleratedDrawingAreaProxy::~AcceleratedDrawingAreaProxy):
(WebKit::AcceleratedDrawingAreaProxy::alwaysUseCompositing):
(WebKit::AcceleratedDrawingAreaProxy::dispatchAfterEnsuringDrawing):
(WebKit::AcceleratedDrawingAreaProxy::sizeDidChange):
(WebKit::AcceleratedDrawingAreaProxy::deviceScaleFactorDidChange):
(WebKit::AcceleratedDrawingAreaProxy::visibilityDidChange):
(WebKit::AcceleratedDrawingAreaProxy::waitForBackingStoreUpdateOnNextPaint):
(WebKit::AcceleratedDrawingAreaProxy::didUpdateBackingStoreState):
(WebKit::AcceleratedDrawingAreaProxy::enterAcceleratedCompositingMode):
(WebKit::AcceleratedDrawingAreaProxy::exitAcceleratedCompositingMode):
(WebKit::AcceleratedDrawingAreaProxy::updateAcceleratedCompositingMode):
(WebKit::AcceleratedDrawingAreaProxy::backingStoreStateDidChange):
(WebKit::AcceleratedDrawingAreaProxy::sendUpdateBackingStoreState):
(WebKit::AcceleratedDrawingAreaProxy::waitForAndDispatchDidUpdateBackingStoreState):
(WebKit::AcceleratedDrawingAreaProxy::setNativeSurfaceHandleForCompositing):
(WebKit::AcceleratedDrawingAreaProxy::destroyNativeSurfaceHandleForCompositing):
* UIProcess/AcceleratedDrawingAreaProxy.h: Renamed from Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.h.
(WebKit::AcceleratedDrawingAreaProxy::isInAcceleratedCompositingMode):
(WebKit::AcceleratedDrawingAreaProxy::coordinatedLayerTreeHostProxy):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
(WebKit::CoordinatedLayerTreeHostProxy::CoordinatedLayerTreeHostProxy):
(WebKit::CoordinatedLayerTreeHostProxy::~CoordinatedLayerTreeHostProxy):
(WebKit::CoordinatedLayerTreeHostProxy::updateViewport):
(WebKit::CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState):
(WebKit::CoordinatedLayerTreeHostProxy::setVisibleContentsRect):
(WebKit::CoordinatedLayerTreeHostProxy::renderNextFrame):
(WebKit::CoordinatedLayerTreeHostProxy::commitScrollOffset):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
* UIProcess/CoordinatedGraphics/PageViewportController.cpp:
(WebKit::PageViewportController::syncVisibleContents):
* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::DrawingAreaProxyImpl):
(WebKit::DrawingAreaProxyImpl::paint):
(WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState):
(WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode):
(WebKit::DrawingAreaProxyImpl::enterAcceleratedCompositingMode):
(WebKit::DrawingAreaProxyImpl::~DrawingAreaProxyImpl): Deleted.
(WebKit::DrawingAreaProxyImpl::update): Deleted.
(WebKit::DrawingAreaProxyImpl::incorporateUpdate): Deleted.
(WebKit::DrawingAreaProxyImpl::discardBackingStoreSoon): Deleted.
(WebKit::DrawingAreaProxyImpl::discardBackingStore): Deleted.
* UIProcess/DrawingAreaProxyImpl.h:
* UIProcess/efl/WebView.cpp:
(WebKit::WebView::setVisible):
(WebKit::WebView::coordinatedGraphicsScene):
(WebKit::WebView::updateViewportSize):
(WebKit::WebView::createDrawingAreaProxy):

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

Source/WebKit2/ChangeLog
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/UIProcess/AcceleratedDrawingAreaProxy.cpp [moved from Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.cpp with 70% similarity]
Source/WebKit2/UIProcess/AcceleratedDrawingAreaProxy.h [moved from Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.h with 64% similarity]
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h
Source/WebKit2/UIProcess/CoordinatedGraphics/PageViewportController.cpp
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
Source/WebKit2/UIProcess/efl/WebView.cpp

index 50f9c81..3446221 100644 (file)
@@ -1,3 +1,72 @@
+2016-08-07  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Duplicated code in DrawingAreaProxyImpl and CoordinatedDrawingAreaProxy
+        https://bugs.webkit.org/show_bug.cgi?id=160506
+
+        Reviewed by Michael Catanzaro.
+
+        Same logic as in r202855 but in the UI process. CoordinatedDrawingAreaProxy is just a copy paste of
+        DrawingAreaProxyImpl with non-accelerated code path removed. There's actually nothing (or very little) specific
+        to coordinated graphics in the CoordinatedDrawingAreaProxy implementation. This patch renames
+        CoordinatedDrawingAreaProxy as AcceleratedDrawingAreaProxy and makes DrawingAreaProxyImpl inherit from it, so
+        that in case of accelerated compositing the parent class is used, and DrawingAreaProxyImpl only adds the non
+        accelerated code path.
+        To simplify the common API of AcceleratedDrawingAreaProxy, I have changed CoordinatedLayerTreeHostProxy to
+        receive a WebPageProxy in the constructor instead of a drawing area, since the drawing area was used just to get
+        the page proxy.
+
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * UIProcess/AcceleratedDrawingAreaProxy.cpp: Renamed from Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.cpp.
+        (WebKit::AcceleratedDrawingAreaProxy::AcceleratedDrawingAreaProxy):
+        (WebKit::AcceleratedDrawingAreaProxy::~AcceleratedDrawingAreaProxy):
+        (WebKit::AcceleratedDrawingAreaProxy::alwaysUseCompositing):
+        (WebKit::AcceleratedDrawingAreaProxy::dispatchAfterEnsuringDrawing):
+        (WebKit::AcceleratedDrawingAreaProxy::sizeDidChange):
+        (WebKit::AcceleratedDrawingAreaProxy::deviceScaleFactorDidChange):
+        (WebKit::AcceleratedDrawingAreaProxy::visibilityDidChange):
+        (WebKit::AcceleratedDrawingAreaProxy::waitForBackingStoreUpdateOnNextPaint):
+        (WebKit::AcceleratedDrawingAreaProxy::didUpdateBackingStoreState):
+        (WebKit::AcceleratedDrawingAreaProxy::enterAcceleratedCompositingMode):
+        (WebKit::AcceleratedDrawingAreaProxy::exitAcceleratedCompositingMode):
+        (WebKit::AcceleratedDrawingAreaProxy::updateAcceleratedCompositingMode):
+        (WebKit::AcceleratedDrawingAreaProxy::backingStoreStateDidChange):
+        (WebKit::AcceleratedDrawingAreaProxy::sendUpdateBackingStoreState):
+        (WebKit::AcceleratedDrawingAreaProxy::waitForAndDispatchDidUpdateBackingStoreState):
+        (WebKit::AcceleratedDrawingAreaProxy::setNativeSurfaceHandleForCompositing):
+        (WebKit::AcceleratedDrawingAreaProxy::destroyNativeSurfaceHandleForCompositing):
+        * UIProcess/AcceleratedDrawingAreaProxy.h: Renamed from Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.h.
+        (WebKit::AcceleratedDrawingAreaProxy::isInAcceleratedCompositingMode):
+        (WebKit::AcceleratedDrawingAreaProxy::coordinatedLayerTreeHostProxy):
+        * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
+        (WebKit::CoordinatedLayerTreeHostProxy::CoordinatedLayerTreeHostProxy):
+        (WebKit::CoordinatedLayerTreeHostProxy::~CoordinatedLayerTreeHostProxy):
+        (WebKit::CoordinatedLayerTreeHostProxy::updateViewport):
+        (WebKit::CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState):
+        (WebKit::CoordinatedLayerTreeHostProxy::setVisibleContentsRect):
+        (WebKit::CoordinatedLayerTreeHostProxy::renderNextFrame):
+        (WebKit::CoordinatedLayerTreeHostProxy::commitScrollOffset):
+        * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
+        * UIProcess/CoordinatedGraphics/PageViewportController.cpp:
+        (WebKit::PageViewportController::syncVisibleContents):
+        * UIProcess/DrawingAreaProxyImpl.cpp:
+        (WebKit::DrawingAreaProxyImpl::DrawingAreaProxyImpl):
+        (WebKit::DrawingAreaProxyImpl::paint):
+        (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState):
+        (WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode):
+        (WebKit::DrawingAreaProxyImpl::enterAcceleratedCompositingMode):
+        (WebKit::DrawingAreaProxyImpl::~DrawingAreaProxyImpl): Deleted.
+        (WebKit::DrawingAreaProxyImpl::update): Deleted.
+        (WebKit::DrawingAreaProxyImpl::incorporateUpdate): Deleted.
+        (WebKit::DrawingAreaProxyImpl::discardBackingStoreSoon): Deleted.
+        (WebKit::DrawingAreaProxyImpl::discardBackingStore): Deleted.
+        * UIProcess/DrawingAreaProxyImpl.h:
+        * UIProcess/efl/WebView.cpp:
+        (WebKit::WebView::setVisible):
+        (WebKit::WebView::coordinatedGraphicsScene):
+        (WebKit::WebView::updateViewportSize):
+        (WebKit::WebView::createDrawingAreaProxy):
+
 2016-08-07  Dan Bernstein  <mitz@apple.com>
 
         [Cocoa] Reply block leaks if the remote object doesn’t call it
index 2020fbe..faa7bb3 100644 (file)
@@ -54,6 +54,7 @@ list(APPEND WebKit2_SOURCES
 
     Shared/unix/ChildProcessMain.cpp
 
+    UIProcess/AcceleratedDrawingAreaProxy.cpp
     UIProcess/BackingStore.cpp
     UIProcess/DefaultUndoController.cpp
     UIProcess/LegacySessionStateCodingNone.cpp
@@ -112,7 +113,6 @@ list(APPEND WebKit2_SOURCES
     UIProcess/API/efl/ewk_view.cpp
     UIProcess/API/efl/ewk_window_features.cpp
 
-    UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.cpp
     UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp
     UIProcess/CoordinatedGraphics/PageViewportController.cpp
     UIProcess/CoordinatedGraphics/WebPageProxyCoordinatedGraphics.cpp
index 369aa02..7889664 100644 (file)
@@ -81,6 +81,7 @@ list(APPEND WebKit2_SOURCES
 
     Shared/unix/ChildProcessMain.cpp
 
+    UIProcess/AcceleratedDrawingAreaProxy.cpp
     UIProcess/BackingStore.cpp
     UIProcess/DefaultUndoController.cpp
     UIProcess/DrawingAreaProxyImpl.cpp
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2016 Igalia S.L.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
+#include "AcceleratedDrawingAreaProxy.h"
 
-#if USE(COORDINATED_GRAPHICS)
-#include "CoordinatedDrawingAreaProxy.h"
-
-#include "CoordinatedLayerTreeHostProxy.h"
 #include "DrawingAreaMessages.h"
 #include "DrawingAreaProxyMessages.h"
 #include "LayerTreeContext.h"
 #include "UpdateInfo.h"
-#include "WebPageGroup.h"
 #include "WebPageProxy.h"
 #include "WebPreferences.h"
 #include "WebProcessProxy.h"
 #include <WebCore/Region.h>
 
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
+#include "CoordinatedLayerTreeHostProxy.h"
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
 
-CoordinatedDrawingAreaProxy::CoordinatedDrawingAreaProxy(WebPageProxy& webPageProxy)
+AcceleratedDrawingAreaProxy::AcceleratedDrawingAreaProxy(WebPageProxy& webPageProxy)
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     : DrawingAreaProxy(DrawingAreaTypeCoordinated, webPageProxy)
-    , m_currentBackingStoreStateID(0)
-    , m_nextBackingStoreStateID(0)
-    , m_isWaitingForDidUpdateBackingStoreState(false)
-    , m_hasReceivedFirstUpdate(false)
+#else
+    : DrawingAreaProxy(DrawingAreaTypeImpl, webPageProxy)
+#endif
 {
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     // Construct the proxy early to allow messages to be sent to the web process while AC is entered there.
-    m_coordinatedLayerTreeHostProxy = std::make_unique<CoordinatedLayerTreeHostProxy>(this);
+    m_coordinatedLayerTreeHostProxy = std::make_unique<CoordinatedLayerTreeHostProxy>(webPageProxy);
+#endif
 }
 
-CoordinatedDrawingAreaProxy::~CoordinatedDrawingAreaProxy()
+AcceleratedDrawingAreaProxy::~AcceleratedDrawingAreaProxy()
 {
     // Make sure to exit accelerated compositing mode.
     if (isInAcceleratedCompositingMode())
         exitAcceleratedCompositingMode();
 }
 
-void CoordinatedDrawingAreaProxy::updateViewport()
-{
-    m_webPageProxy.setViewNeedsDisplay(viewportVisibleRect());
-}
-
-WebCore::IntRect CoordinatedDrawingAreaProxy::contentsRect() const
+bool AcceleratedDrawingAreaProxy::alwaysUseCompositing() const
 {
-    return IntRect(IntPoint::zero(), m_webPageProxy.viewSize());
+    return m_webPageProxy.preferences().acceleratedCompositingEnabled() && m_webPageProxy.preferences().forceCompositingMode();
 }
 
-void CoordinatedDrawingAreaProxy::dispatchAfterEnsuringDrawing(std::function<void(CallbackBase::Error)> callbackFunction)
+void AcceleratedDrawingAreaProxy::dispatchAfterEnsuringDrawing(std::function<void(CallbackBase::Error)> callbackFunction)
 {
     if (!m_webPageProxy.isValid()) {
         callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
@@ -84,17 +82,17 @@ void CoordinatedDrawingAreaProxy::dispatchAfterEnsuringDrawing(std::function<voi
     });
 }
 
-void CoordinatedDrawingAreaProxy::sizeDidChange()
+void AcceleratedDrawingAreaProxy::sizeDidChange()
 {
     backingStoreStateDidChange(RespondImmediately);
 }
 
-void CoordinatedDrawingAreaProxy::deviceScaleFactorDidChange()
+void AcceleratedDrawingAreaProxy::deviceScaleFactorDidChange()
 {
     backingStoreStateDidChange(RespondImmediately);
 }
 
-void CoordinatedDrawingAreaProxy::visibilityDidChange()
+void AcceleratedDrawingAreaProxy::visibilityDidChange()
 {
     // If we don't have a backing store, go ahead and mark the backing store as being changed so
     // that when paint we'll actually wait for something to paint and not flash white.
@@ -102,12 +100,12 @@ void CoordinatedDrawingAreaProxy::visibilityDidChange()
         backingStoreStateDidChange(DoNotRespondImmediately);
 }
 
-void CoordinatedDrawingAreaProxy::waitForBackingStoreUpdateOnNextPaint()
+void AcceleratedDrawingAreaProxy::waitForBackingStoreUpdateOnNextPaint()
 {
     m_hasReceivedFirstUpdate = true;
 }
 
-void CoordinatedDrawingAreaProxy::didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo& updateInfo, const LayerTreeContext& layerTreeContext)
+void AcceleratedDrawingAreaProxy::didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo& updateInfo, const LayerTreeContext& layerTreeContext)
 {
     ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_nextBackingStoreStateID);
     ASSERT_ARG(backingStoreStateID, backingStoreStateID > m_currentBackingStoreStateID);
@@ -119,24 +117,33 @@ void CoordinatedDrawingAreaProxy::didUpdateBackingStoreState(uint64_t backingSto
     m_webPageProxy.process().responsivenessTimer().stop();
 
     if (layerTreeContext != m_layerTreeContext) {
-        if (!m_layerTreeContext.isEmpty()) {
+        if (layerTreeContext.isEmpty() && !m_layerTreeContext.isEmpty()) {
             exitAcceleratedCompositingMode();
             ASSERT(m_layerTreeContext.isEmpty());
-        }
-
-        if (!layerTreeContext.isEmpty()) {
+        } else if (!layerTreeContext.isEmpty() && m_layerTreeContext.isEmpty()) {
             enterAcceleratedCompositingMode(layerTreeContext);
             ASSERT(layerTreeContext == m_layerTreeContext);
+        } else {
+            updateAcceleratedCompositingMode(layerTreeContext);
+            ASSERT(layerTreeContext == m_layerTreeContext);
         }
     }
 
     if (m_nextBackingStoreStateID != m_currentBackingStoreStateID)
         sendUpdateBackingStoreState(RespondImmediately);
-    else
+    else {
         m_hasReceivedFirstUpdate = true;
+
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
+        if (m_pendingNativeSurfaceHandleForCompositing) {
+            setNativeSurfaceHandleForCompositing(m_pendingNativeSurfaceHandleForCompositing);
+            m_pendingNativeSurfaceHandleForCompositing = 0;
+        }
+#endif
+    }
 }
 
-void CoordinatedDrawingAreaProxy::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
+void AcceleratedDrawingAreaProxy::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
 {
     ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
     if (backingStoreStateID < m_currentBackingStoreStateID)
@@ -145,7 +152,7 @@ void CoordinatedDrawingAreaProxy::enterAcceleratedCompositingMode(uint64_t backi
     enterAcceleratedCompositingMode(layerTreeContext);
 }
 
-void CoordinatedDrawingAreaProxy::exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo& updateInfo)
+void AcceleratedDrawingAreaProxy::exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo& updateInfo)
 {
     ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
     if (backingStoreStateID < m_currentBackingStoreStateID)
@@ -154,7 +161,7 @@ void CoordinatedDrawingAreaProxy::exitAcceleratedCompositingMode(uint64_t backin
     exitAcceleratedCompositingMode();
 }
 
-void CoordinatedDrawingAreaProxy::updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
+void AcceleratedDrawingAreaProxy::updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
 {
     ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
     if (backingStoreStateID < m_currentBackingStoreStateID)
@@ -163,13 +170,13 @@ void CoordinatedDrawingAreaProxy::updateAcceleratedCompositingMode(uint64_t back
     updateAcceleratedCompositingMode(layerTreeContext);
 }
 
-void CoordinatedDrawingAreaProxy::backingStoreStateDidChange(RespondImmediatelyOrNot respondImmediatelyOrNot)
+void AcceleratedDrawingAreaProxy::backingStoreStateDidChange(RespondImmediatelyOrNot respondImmediatelyOrNot)
 {
     ++m_nextBackingStoreStateID;
     sendUpdateBackingStoreState(respondImmediatelyOrNot);
 }
 
-void CoordinatedDrawingAreaProxy::sendUpdateBackingStoreState(RespondImmediatelyOrNot respondImmediatelyOrNot)
+void AcceleratedDrawingAreaProxy::sendUpdateBackingStoreState(RespondImmediatelyOrNot respondImmediatelyOrNot)
 {
     ASSERT(m_currentBackingStoreStateID < m_nextBackingStoreStateID);
 
@@ -194,13 +201,13 @@ void CoordinatedDrawingAreaProxy::sendUpdateBackingStoreState(RespondImmediately
     }
 
     if (m_isWaitingForDidUpdateBackingStoreState && !m_layerTreeContext.isEmpty()) {
-        // Wait for the DidUpdateBackingStoreState message. Normally we do this in CoordinatedDrawingAreaProxy::paint, but that
+        // Wait for the DidUpdateBackingStoreState message. Normally we do this in AcceleratedDrawingAreaProxy::paint, but that
         // function is never called when in accelerated compositing mode.
         waitForAndDispatchDidUpdateBackingStoreState();
     }
 }
 
-void CoordinatedDrawingAreaProxy::waitForAndDispatchDidUpdateBackingStoreState()
+void AcceleratedDrawingAreaProxy::waitForAndDispatchDidUpdateBackingStoreState()
 {
     ASSERT(m_isWaitingForDidUpdateBackingStoreState);
 
@@ -218,20 +225,15 @@ void CoordinatedDrawingAreaProxy::waitForAndDispatchDidUpdateBackingStoreState()
     m_webPageProxy.process().connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateBackingStoreState>(m_webPageProxy.pageID(), std::chrono::milliseconds(500));
 }
 
-void CoordinatedDrawingAreaProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+void AcceleratedDrawingAreaProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
 {
-    ASSERT(!isInAcceleratedCompositingMode());
+    ASSERT(alwaysUseCompositing() || !isInAcceleratedCompositingMode());
 
     m_layerTreeContext = layerTreeContext;
     m_webPageProxy.enterAcceleratedCompositingMode(layerTreeContext);
 }
 
-void CoordinatedDrawingAreaProxy::setVisibleContentsRect(const WebCore::FloatRect& visibleContentsRect, const WebCore::FloatPoint& trajectoryVector)
-{
-    m_coordinatedLayerTreeHostProxy->setVisibleContentsRect(visibleContentsRect, trajectoryVector);
-}
-
-void CoordinatedDrawingAreaProxy::exitAcceleratedCompositingMode()
+void AcceleratedDrawingAreaProxy::exitAcceleratedCompositingMode()
 {
     ASSERT(isInAcceleratedCompositingMode());
 
@@ -239,7 +241,7 @@ void CoordinatedDrawingAreaProxy::exitAcceleratedCompositingMode()
     m_webPageProxy.exitAcceleratedCompositingMode();
 }
 
-void CoordinatedDrawingAreaProxy::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+void AcceleratedDrawingAreaProxy::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
 {
     ASSERT(isInAcceleratedCompositingMode());
 
@@ -247,5 +249,25 @@ void CoordinatedDrawingAreaProxy::updateAcceleratedCompositingMode(const LayerTr
     m_webPageProxy.updateAcceleratedCompositingMode(layerTreeContext);
 }
 
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
+void AcceleratedDrawingAreaProxy::setNativeSurfaceHandleForCompositing(uint64_t handle)
+{
+    if (!m_hasReceivedFirstUpdate) {
+        m_pendingNativeSurfaceHandleForCompositing = handle;
+        return;
+    }
+    m_webPageProxy.process().send(Messages::DrawingArea::SetNativeSurfaceHandleForCompositing(handle), m_webPageProxy.pageID(), IPC::DispatchMessageEvenWhenWaitingForSyncReply);
+}
+
+void AcceleratedDrawingAreaProxy::destroyNativeSurfaceHandleForCompositing()
+{
+    if (m_pendingNativeSurfaceHandleForCompositing) {
+        m_pendingNativeSurfaceHandleForCompositing = 0;
+        return;
+    }
+    bool handled;
+    m_webPageProxy.process().sendSync(Messages::DrawingArea::DestroyNativeSurfaceHandleForCompositing(), Messages::DrawingArea::DestroyNativeSurfaceHandleForCompositing::Reply(handled), m_webPageProxy.pageID());
+}
+#endif
+
 } // namespace WebKit
-#endif // USE(COORDINATED_GRAPHICS)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2016 Igalia S.L.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef CoordinatedDrawingAreaProxy_h
-#define CoordinatedDrawingAreaProxy_h
+#pragma once
 
-#if USE(COORDINATED_GRAPHICS)
-
-#include "BackingStore.h"
 #include "DrawingAreaProxy.h"
 #include "LayerTreeContext.h"
-#include <wtf/RunLoop.h>
-
-namespace WebCore {
-class Region;
-}
 
 namespace WebKit {
 
 class CoordinatedLayerTreeHostProxy;
 
-class CoordinatedDrawingAreaProxy : public DrawingAreaProxy {
+class AcceleratedDrawingAreaProxy : public DrawingAreaProxy {
 public:
-    explicit CoordinatedDrawingAreaProxy(WebPageProxy&);
-    virtual ~CoordinatedDrawingAreaProxy();
+    explicit AcceleratedDrawingAreaProxy(WebPageProxy&);
+    virtual ~AcceleratedDrawingAreaProxy();
 
-    bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
+    bool isInAcceleratedCompositingMode() const { return alwaysUseCompositing() || !m_layerTreeContext.isEmpty(); }
     void visibilityDidChange();
 
-    void setVisibleContentsRect(const WebCore::FloatRect& visibleContentsRect, const WebCore::FloatPoint& trajectory);
-
-    bool hasReceivedFirstUpdate() const { return m_hasReceivedFirstUpdate; }
-
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     CoordinatedLayerTreeHostProxy& coordinatedLayerTreeHostProxy() const { return *m_coordinatedLayerTreeHostProxy.get(); }
+#endif
 
-    WebCore::IntRect viewportVisibleRect() const { return contentsRect(); }
-    WebCore::IntRect contentsRect() const;
-    void updateViewport();
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    void setNativeSurfaceHandleForCompositing(uint64_t);
+    void destroyNativeSurfaceHandleForCompositing();
+#endif
 
-    WebPageProxy& page() { return m_webPageProxy; }
-    
     void dispatchAfterEnsuringDrawing(std::function<void(CallbackBase::Error)>) override;
 
-private:
+protected:
     // DrawingAreaProxy
-    virtual void sizeDidChange();
-    virtual void deviceScaleFactorDidChange();
-
-    virtual void waitForBackingStoreUpdateOnNextPaint();
+    void sizeDidChange() override;
+    void deviceScaleFactorDidChange() override;
+    void waitForBackingStoreUpdateOnNextPaint() override;
 
     // IPC message handlers
-    virtual void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&);
-    virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&);
-    virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&);
-    virtual void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&);
+    void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&) override;
+    void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
+    void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) override;
+    void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
 
     enum RespondImmediatelyOrNot { DoNotRespondImmediately, RespondImmediately };
     void backingStoreStateDidChange(RespondImmediatelyOrNot);
     void sendUpdateBackingStoreState(RespondImmediatelyOrNot);
     void waitForAndDispatchDidUpdateBackingStoreState();
 
-    void enterAcceleratedCompositingMode(const LayerTreeContext&);
+    virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     void exitAcceleratedCompositingMode();
     void updateAcceleratedCompositingMode(const LayerTreeContext&);
 
+    bool alwaysUseCompositing() const;
+
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     std::unique_ptr<CoordinatedLayerTreeHostProxy> m_coordinatedLayerTreeHostProxy;
+#endif
 
     // The state ID corresponding to our current backing store. Updated whenever we allocate
     // a new backing store. Any messages received that correspond to an earlier state are ignored,
     // as they don't apply to our current backing store.
-    uint64_t m_currentBackingStoreStateID;
+    uint64_t m_currentBackingStoreStateID { 0 };
 
     // The next backing store state ID we will request the web process update to. Incremented
     // whenever our state changes in a way that will require a new backing store to be allocated.
-    uint64_t m_nextBackingStoreStateID;
+    uint64_t m_nextBackingStoreStateID { 0 };
 
     // The current layer tree context.
     LayerTreeContext m_layerTreeContext;
 
     // Whether we've sent a UpdateBackingStoreState message and are now waiting for a DidUpdateBackingStoreState message.
     // Used to throttle UpdateBackingStoreState messages so we don't send them faster than the Web process can handle.
-    bool m_isWaitingForDidUpdateBackingStoreState;
+    bool m_isWaitingForDidUpdateBackingStoreState { false };
 
     // For a new Drawing Area don't draw anything until the WebProcess has sent over the first content.
-    bool m_hasReceivedFirstUpdate;
+    bool m_hasReceivedFirstUpdate { false };
+
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    uint64_t m_pendingNativeSurfaceHandleForCompositing { 0 };
+#endif
 };
 
 } // namespace WebKit
 
-#endif // USE(COORDINATED_GRAPHICS)
-#endif // CoordinatedDrawingAreaProxy_h
index e2c6690..6d1afd0 100644 (file)
 
 #include "config.h"
 
-#if USE(COORDINATED_GRAPHICS)
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
 #include "CoordinatedLayerTreeHostProxy.h"
 
-#include "CoordinatedDrawingAreaProxy.h"
 #include "CoordinatedLayerTreeHostMessages.h"
 #include "CoordinatedLayerTreeHostProxyMessages.h"
 #include "WebPageProxy.h"
@@ -34,22 +33,22 @@ namespace WebKit {
 
 using namespace WebCore;
 
-CoordinatedLayerTreeHostProxy::CoordinatedLayerTreeHostProxy(CoordinatedDrawingAreaProxy* drawingAreaProxy)
-    : m_drawingAreaProxy(drawingAreaProxy)
+CoordinatedLayerTreeHostProxy::CoordinatedLayerTreeHostProxy(WebPageProxy& webPageProxy)
+    : m_webPageProxy(webPageProxy)
     , m_scene(adoptRef(new CoordinatedGraphicsScene(this)))
 {
-    m_drawingAreaProxy->page().process().addMessageReceiver(Messages::CoordinatedLayerTreeHostProxy::messageReceiverName(), m_drawingAreaProxy->page().pageID(), *this);
+    m_webPageProxy.process().addMessageReceiver(Messages::CoordinatedLayerTreeHostProxy::messageReceiverName(), m_webPageProxy.pageID(), *this);
 }
 
 CoordinatedLayerTreeHostProxy::~CoordinatedLayerTreeHostProxy()
 {
-    m_drawingAreaProxy->page().process().removeMessageReceiver(Messages::CoordinatedLayerTreeHostProxy::messageReceiverName(), m_drawingAreaProxy->page().pageID());
+    m_webPageProxy.process().removeMessageReceiver(Messages::CoordinatedLayerTreeHostProxy::messageReceiverName(), m_webPageProxy.pageID());
     m_scene->detach();
 }
 
 void CoordinatedLayerTreeHostProxy::updateViewport()
 {
-    m_drawingAreaProxy->updateViewport();
+    m_webPageProxy.setViewNeedsDisplay(IntRect(IntPoint::zero(), m_webPageProxy.viewSize()));
 }
 
 void CoordinatedLayerTreeHostProxy::dispatchUpdate(std::function<void()> function)
@@ -65,9 +64,7 @@ void CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState(const Coordin
     });
 
     updateViewport();
-#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
-    m_drawingAreaProxy->page().didRenderFrame(graphicsState.contentsSize, graphicsState.coveredRect);
-#endif
+    m_webPageProxy.didRenderFrame(graphicsState.contentsSize, graphicsState.coveredRect);
 }
 
 void CoordinatedLayerTreeHostProxy::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
@@ -75,20 +72,20 @@ void CoordinatedLayerTreeHostProxy::setVisibleContentsRect(const FloatRect& rect
     if (rect == m_lastSentVisibleRect && trajectoryVector == m_lastSentTrajectoryVector)
         return;
 
-    m_drawingAreaProxy->page().process().send(Messages::CoordinatedLayerTreeHost::SetVisibleContentsRect(rect, trajectoryVector), m_drawingAreaProxy->page().pageID());
+    m_webPageProxy.process().send(Messages::CoordinatedLayerTreeHost::SetVisibleContentsRect(rect, trajectoryVector), m_webPageProxy.pageID());
     m_lastSentVisibleRect = rect;
     m_lastSentTrajectoryVector = trajectoryVector;
 }
 
 void CoordinatedLayerTreeHostProxy::renderNextFrame()
 {
-    m_drawingAreaProxy->page().process().send(Messages::CoordinatedLayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page().pageID());
+    m_webPageProxy.process().send(Messages::CoordinatedLayerTreeHost::RenderNextFrame(), m_webPageProxy.pageID());
 }
 
 void CoordinatedLayerTreeHostProxy::commitScrollOffset(uint32_t layerID, const IntSize& offset)
 {
-    m_drawingAreaProxy->page().process().send(Messages::CoordinatedLayerTreeHost::CommitScrollOffset(layerID, offset), m_drawingAreaProxy->page().pageID());
+    m_webPageProxy.process().send(Messages::CoordinatedLayerTreeHost::CommitScrollOffset(layerID, offset), m_webPageProxy.pageID());
 }
 
 }
-#endif // USE(COORDINATED_GRAPHICS)
+#endif // USE(COORDINATED_GRAPHICS_MULTIPROCESS)
index 4f38dc5..e447482 100644 (file)
@@ -35,13 +35,13 @@ class IntSize;
 
 namespace WebKit {
 
-class CoordinatedDrawingAreaProxy;
+class WebPageProxy;
 
 class CoordinatedLayerTreeHostProxy : public CoordinatedGraphicsSceneClient, public IPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(CoordinatedLayerTreeHostProxy);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit CoordinatedLayerTreeHostProxy(CoordinatedDrawingAreaProxy*);
+    explicit CoordinatedLayerTreeHostProxy(WebPageProxy&);
     virtual ~CoordinatedLayerTreeHostProxy();
 
     void commitCoordinatedGraphicsState(const WebCore::CoordinatedGraphicsState&);
@@ -60,7 +60,7 @@ protected:
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
 
-    CoordinatedDrawingAreaProxy* m_drawingAreaProxy;
+    WebPageProxy& m_webPageProxy;
     RefPtr<CoordinatedGraphicsScene> m_scene;
     WebCore::FloatRect m_lastSentVisibleRect;
     WebCore::FloatPoint m_lastSentTrajectoryVector;
index 1715657..e8ff7d5 100644 (file)
@@ -22,7 +22,8 @@
 #include "config.h"
 #include "PageViewportController.h"
 
-#include "CoordinatedDrawingAreaProxy.h"
+#include "AcceleratedDrawingAreaProxy.h"
+#include "CoordinatedLayerTreeHostProxy.h"
 #include "PageViewportControllerClient.h"
 #include "WebPageProxy.h"
 #include <WebCore/FloatRect.h>
@@ -263,13 +264,13 @@ void PageViewportController::didChangeContentsVisibility(const FloatPoint& posit
 
 bool PageViewportController::syncVisibleContents(const FloatPoint& trajectoryVector)
 {
-    CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(m_webPageProxy->drawingArea());
+    auto* drawingArea = static_cast<AcceleratedDrawingAreaProxy*>(m_webPageProxy->drawingArea());
     if (!drawingArea || m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
         return false;
 
     FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize());
     visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize));
-    drawingArea->setVisibleContentsRect(visibleContentsRect, trajectoryVector);
+    drawingArea->coordinatedLayerTreeHostProxy().setVisibleContentsRect(visibleContentsRect, trajectoryVector);
 
     if (!m_layerTreeStateIsFrozen)
         m_client.didChangeVisibleContents();
index 2476296..efcab5e 100644 (file)
@@ -41,26 +41,13 @@ using namespace WebCore;
 namespace WebKit {
 
 DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy& webPageProxy)
-    : DrawingAreaProxy(DrawingAreaTypeImpl, webPageProxy)
-    , m_currentBackingStoreStateID(0)
-    , m_nextBackingStoreStateID(0)
-    , m_isWaitingForDidUpdateBackingStoreState(false)
-    , m_hasReceivedFirstUpdate(false)
-    , m_isBackingStoreDiscardable(true)
+    : AcceleratedDrawingAreaProxy(webPageProxy)
     , m_discardBackingStoreTimer(RunLoop::current(), this, &DrawingAreaProxyImpl::discardBackingStore)
 {
 }
 
 DrawingAreaProxyImpl::~DrawingAreaProxyImpl()
 {
-    // Make sure to exit accelerated compositing mode.
-    if (isInAcceleratedCompositingMode())
-        exitAcceleratedCompositingMode();
-}
-
-bool DrawingAreaProxyImpl::alwaysUseCompositing() const
-{
-    return m_webPageProxy.preferences().acceleratedCompositingEnabled() && m_webPageProxy.preferences().forceCompositingMode();
 }
 
 void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect, Region& unpaintedRegion)
@@ -78,8 +65,8 @@ void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context,
 
         // If we haven't yet received our first bits from the WebProcess then don't paint anything.
         if (!m_hasReceivedFirstUpdate)
-            return;        
-        
+            return;
+
         if (m_isWaitingForDidUpdateBackingStoreState) {
             // Wait for a DidUpdateBackingStoreState message that contains the new bits before we paint
             // what's currently in the backing store.
@@ -106,16 +93,6 @@ void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context,
     discardBackingStoreSoon();
 }
 
-void DrawingAreaProxyImpl::sizeDidChange()
-{
-    backingStoreStateDidChange(RespondImmediately);
-}
-
-void DrawingAreaProxyImpl::deviceScaleFactorDidChange()
-{
-    backingStoreStateDidChange(RespondImmediately);
-}
-
 void DrawingAreaProxyImpl::setBackingStoreIsDiscardable(bool isBackingStoreDiscardable)
 {
     if (m_isBackingStoreDiscardable == isBackingStoreDiscardable)
@@ -128,11 +105,6 @@ void DrawingAreaProxyImpl::setBackingStoreIsDiscardable(bool isBackingStoreDisca
         m_discardBackingStoreTimer.stop();
 }
 
-void DrawingAreaProxyImpl::waitForBackingStoreUpdateOnNextPaint()
-{
-    m_hasReceivedFirstUpdate = true;
-}
-
 void DrawingAreaProxyImpl::update(uint64_t backingStoreStateID, const UpdateInfo& updateInfo)
 {
     ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
@@ -147,41 +119,7 @@ void DrawingAreaProxyImpl::update(uint64_t backingStoreStateID, const UpdateInfo
 
 void DrawingAreaProxyImpl::didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo& updateInfo, const LayerTreeContext& layerTreeContext)
 {
-    ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_nextBackingStoreStateID);
-    ASSERT_ARG(backingStoreStateID, backingStoreStateID > m_currentBackingStoreStateID);
-    m_currentBackingStoreStateID = backingStoreStateID;
-
-    m_isWaitingForDidUpdateBackingStoreState = false;
-
-    // Stop the responsiveness timer that was started in sendUpdateBackingStoreState.
-    m_webPageProxy.process().responsivenessTimer().stop();
-
-    if (layerTreeContext != m_layerTreeContext) {
-        if (layerTreeContext.isEmpty() && !m_layerTreeContext.isEmpty()) {
-            exitAcceleratedCompositingMode();
-            ASSERT(m_layerTreeContext.isEmpty());
-        } else if (!layerTreeContext.isEmpty() && m_layerTreeContext.isEmpty()) {
-            enterAcceleratedCompositingMode(layerTreeContext);
-            ASSERT(layerTreeContext == m_layerTreeContext);
-        } else {
-            updateAcceleratedCompositingMode(layerTreeContext);
-            ASSERT(layerTreeContext == m_layerTreeContext);
-        }
-    }
-
-    if (m_nextBackingStoreStateID != m_currentBackingStoreStateID)
-        sendUpdateBackingStoreState(RespondImmediately);
-    else {
-        m_hasReceivedFirstUpdate = true;
-
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
-        if (m_pendingNativeSurfaceHandleForCompositing) {
-            setNativeSurfaceHandleForCompositing(m_pendingNativeSurfaceHandleForCompositing);
-            m_pendingNativeSurfaceHandleForCompositing = 0;
-        }
-#endif
-    }
-
+    AcceleratedDrawingAreaProxy::didUpdateBackingStoreState(backingStoreStateID, updateInfo, layerTreeContext);
     if (isInAcceleratedCompositingMode()) {
         ASSERT(!m_backingStore);
         return;
@@ -193,35 +131,17 @@ void DrawingAreaProxyImpl::didUpdateBackingStoreState(uint64_t backingStoreState
     incorporateUpdate(updateInfo);
 }
 
-void DrawingAreaProxyImpl::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
-{
-    ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
-    if (backingStoreStateID < m_currentBackingStoreStateID)
-        return;
-
-    enterAcceleratedCompositingMode(layerTreeContext);
-}
-
 void DrawingAreaProxyImpl::exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo& updateInfo)
 {
     ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
     if (backingStoreStateID < m_currentBackingStoreStateID)
         return;
 
-    exitAcceleratedCompositingMode();
+    AcceleratedDrawingAreaProxy::exitAcceleratedCompositingMode();
 
     incorporateUpdate(updateInfo);
 }
 
-void DrawingAreaProxyImpl::updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
-{
-    ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
-    if (backingStoreStateID < m_currentBackingStoreStateID)
-        return;
-
-    updateAcceleratedCompositingMode(layerTreeContext);
-}
-
 void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)
 {
     ASSERT(!isInAcceleratedCompositingMode());
@@ -243,115 +163,10 @@ void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)
     m_webPageProxy.setViewNeedsDisplay(damageRegion);
 }
 
-void DrawingAreaProxyImpl::backingStoreStateDidChange(RespondImmediatelyOrNot respondImmediatelyOrNot)
-{
-    ++m_nextBackingStoreStateID;
-    sendUpdateBackingStoreState(respondImmediatelyOrNot);
-}
-
-void DrawingAreaProxyImpl::sendUpdateBackingStoreState(RespondImmediatelyOrNot respondImmediatelyOrNot)
-{
-    ASSERT(m_currentBackingStoreStateID < m_nextBackingStoreStateID);
-
-    if (!m_webPageProxy.isValid())
-        return;
-
-    if (m_isWaitingForDidUpdateBackingStoreState)
-        return;
-
-    if (m_webPageProxy.viewSize().isEmpty() && !m_webPageProxy.useFixedLayout())
-        return;
-
-    m_isWaitingForDidUpdateBackingStoreState = respondImmediatelyOrNot == RespondImmediately;
-
-    m_webPageProxy.process().send(Messages::DrawingArea::UpdateBackingStoreState(m_nextBackingStoreStateID, respondImmediatelyOrNot == RespondImmediately, m_webPageProxy.deviceScaleFactor(), m_size, m_scrollOffset), m_webPageProxy.pageID());
-    m_scrollOffset = IntSize();
-
-    if (m_isWaitingForDidUpdateBackingStoreState) {
-        // Start the responsiveness timer. We will stop it when we hear back from the WebProcess
-        // in didUpdateBackingStoreState.
-        m_webPageProxy.process().responsivenessTimer().start();
-    }
-
-    if (m_isWaitingForDidUpdateBackingStoreState && !m_layerTreeContext.isEmpty()) {
-        // Wait for the DidUpdateBackingStoreState message. Normally we do this in DrawingAreaProxyImpl::paint, but that
-        // function is never called when in accelerated compositing mode.
-        waitForAndDispatchDidUpdateBackingStoreState();
-    }
-}
-
-void DrawingAreaProxyImpl::waitForAndDispatchDidUpdateBackingStoreState()
-{
-    ASSERT(m_isWaitingForDidUpdateBackingStoreState);
-
-    if (!m_webPageProxy.isValid())
-        return;
-    if (m_webPageProxy.process().state() == WebProcessProxy::State::Launching)
-        return;
-
-    // FIXME: waitForAndDispatchImmediately will always return the oldest DidUpdateBackingStoreState message that
-    // hasn't yet been processed. But it might be better to skip ahead to some other DidUpdateBackingStoreState
-    // message, if multiple DidUpdateBackingStoreState messages are waiting to be processed. For instance, we could
-    // choose the most recent one, or the one that is closest to our current size.
-
-    // The timeout we use when waiting for a DidUpdateBackingStoreState message when we're asked to paint is 500 milliseconds.
-    m_webPageProxy.process().connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateBackingStoreState>(m_webPageProxy.pageID(), std::chrono::milliseconds(500));
-}
-
 void DrawingAreaProxyImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
 {
-    ASSERT(alwaysUseCompositing() || !isInAcceleratedCompositingMode());
-
     m_backingStore = nullptr;
-    m_layerTreeContext = layerTreeContext;
-    m_webPageProxy.enterAcceleratedCompositingMode(layerTreeContext);
-}
-
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
-void DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)
-{
-    if (!m_hasReceivedFirstUpdate) {
-        m_pendingNativeSurfaceHandleForCompositing = handle;
-        return;
-    }
-    m_webPageProxy.process().send(Messages::DrawingArea::SetNativeSurfaceHandleForCompositing(handle), m_webPageProxy.pageID(), IPC::DispatchMessageEvenWhenWaitingForSyncReply);
-}
-
-void DrawingAreaProxyImpl::destroyNativeSurfaceHandleForCompositing()
-{
-    if (m_pendingNativeSurfaceHandleForCompositing) {
-        m_pendingNativeSurfaceHandleForCompositing = 0;
-        return;
-    }
-    bool handled;
-    m_webPageProxy.process().sendSync(Messages::DrawingArea::DestroyNativeSurfaceHandleForCompositing(), Messages::DrawingArea::DestroyNativeSurfaceHandleForCompositing::Reply(handled), m_webPageProxy.pageID());
-}
-#endif
-
-void DrawingAreaProxyImpl::dispatchAfterEnsuringDrawing(std::function<void (CallbackBase::Error)> callbackFunction)
-{
-    if (!m_webPageProxy.isValid()) {
-        callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
-        return;
-    }
-
-    RunLoop::main().dispatch([callbackFunction] { callbackFunction(CallbackBase::Error::None); });
-}
-
-void DrawingAreaProxyImpl::exitAcceleratedCompositingMode()
-{
-    ASSERT(isInAcceleratedCompositingMode());
-
-    m_layerTreeContext = LayerTreeContext();
-    m_webPageProxy.exitAcceleratedCompositingMode();
-}
-
-void DrawingAreaProxyImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
-{
-    ASSERT(isInAcceleratedCompositingMode());
-
-    m_layerTreeContext = layerTreeContext;
-    m_webPageProxy.updateAcceleratedCompositingMode(layerTreeContext);
+    AcceleratedDrawingAreaProxy::enterAcceleratedCompositingMode(layerTreeContext);
 }
 
 void DrawingAreaProxyImpl::discardBackingStoreSoon()
index 1ed6d00..011c4ef 100644 (file)
@@ -26,9 +26,9 @@
 #ifndef DrawingAreaProxyImpl_h
 #define DrawingAreaProxyImpl_h
 
+#include "AcceleratedDrawingAreaProxy.h"
 #include "BackingStore.h"
 #include "DrawingAreaProxy.h"
-#include "LayerTreeContext.h"
 #include <wtf/RunLoop.h>
 
 namespace WebCore {
@@ -37,81 +37,32 @@ class Region;
 
 namespace WebKit {
 
-class DrawingAreaProxyImpl : public DrawingAreaProxy {
+class DrawingAreaProxyImpl final : public AcceleratedDrawingAreaProxy {
 public:
     explicit DrawingAreaProxyImpl(WebPageProxy&);
     virtual ~DrawingAreaProxyImpl();
 
     void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
 
-    bool isInAcceleratedCompositingMode() const { return alwaysUseCompositing() || !m_layerTreeContext.isEmpty(); }
-
-    bool hasReceivedFirstUpdate() const { return m_hasReceivedFirstUpdate; }
-
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    void setNativeSurfaceHandleForCompositing(uint64_t);
-    void destroyNativeSurfaceHandleForCompositing();
-#endif
-
-    void dispatchAfterEnsuringDrawing(std::function<void (CallbackBase::Error)>) override;
-
 private:
     // DrawingAreaProxy
-    void sizeDidChange() override;
-    void deviceScaleFactorDidChange() override;
-
     void setBackingStoreIsDiscardable(bool) override;
-    void waitForBackingStoreUpdateOnNextPaint() override;
 
     // IPC message handlers
     void update(uint64_t backingStoreStateID, const UpdateInfo&) override;
     void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&) override;
-    void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
     void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) override;
-    void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
 
     void incorporateUpdate(const UpdateInfo&);
 
-    enum RespondImmediatelyOrNot { DoNotRespondImmediately, RespondImmediately };
-    void backingStoreStateDidChange(RespondImmediatelyOrNot);
-    void sendUpdateBackingStoreState(RespondImmediatelyOrNot);
-    void waitForAndDispatchDidUpdateBackingStoreState();
-
-    void enterAcceleratedCompositingMode(const LayerTreeContext&);
-    void exitAcceleratedCompositingMode();
-    void updateAcceleratedCompositingMode(const LayerTreeContext&);
-    bool alwaysUseCompositing() const;
+    void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
 
     void discardBackingStoreSoon();
     void discardBackingStore();
 
-    // The state ID corresponding to our current backing store. Updated whenever we allocate
-    // a new backing store. Any messages received that correspond to an earlier state are ignored,
-    // as they don't apply to our current backing store.
-    uint64_t m_currentBackingStoreStateID;
-
-    // The next backing store state ID we will request the web process update to. Incremented
-    // whenever our state changes in a way that will require a new backing store to be allocated.
-    uint64_t m_nextBackingStoreStateID;
-
-    // The current layer tree context.
-    LayerTreeContext m_layerTreeContext;
-
-    // Whether we've sent a UpdateBackingStoreState message and are now waiting for a DidUpdateBackingStoreState message.
-    // Used to throttle UpdateBackingStoreState messages so we don't send them faster than the Web process can handle.
-    bool m_isWaitingForDidUpdateBackingStoreState;
-    
-    // For a new Drawing Area don't draw anything until the WebProcess has sent over the first content.
-    bool m_hasReceivedFirstUpdate;
-
-    bool m_isBackingStoreDiscardable;
+    bool m_isBackingStoreDiscardable { true };
     std::unique_ptr<BackingStore> m_backingStore;
-
     RunLoop::Timer<DrawingAreaProxyImpl> m_discardBackingStoreTimer;
-
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
-    uint64_t m_pendingNativeSurfaceHandleForCompositing { 0 };
-#endif
 };
 
 } // namespace WebKit
index a18ac01..d7f7b47 100644 (file)
@@ -29,7 +29,7 @@
 
 #if USE(COORDINATED_GRAPHICS)
 #include "APIPageConfiguration.h"
-#include "CoordinatedDrawingAreaProxy.h"
+#include "AcceleratedDrawingAreaProxy.h"
 #include "CoordinatedGraphicsScene.h"
 #include "CoordinatedLayerTreeHostProxy.h"
 #include "DownloadManagerEfl.h"
@@ -210,7 +210,7 @@ void WebView::setVisible(bool visible)
     m_visible = visible;
     m_page->viewStateDidChange(ViewState::IsVisible);
 
-    if (CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(page()->drawingArea()))
+    if (auto* drawingArea = static_cast<AcceleratedDrawingAreaProxy*>(page()->drawingArea()))
         drawingArea->visibilityDidChange();
 }
 
@@ -368,7 +368,7 @@ AffineTransform WebView::transformToScene() const
 
 CoordinatedGraphicsScene* WebView::coordinatedGraphicsScene()
 {
-    if (CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(page()->drawingArea()))
+    if (auto* drawingArea = static_cast<AcceleratedDrawingAreaProxy*>(page()->drawingArea()))
         return drawingArea->coordinatedLayerTreeHostProxy().coordinatedGraphicsScene();
 
     return nullptr;
@@ -376,12 +376,12 @@ CoordinatedGraphicsScene* WebView::coordinatedGraphicsScene()
 
 void WebView::updateViewportSize()
 {
-    if (CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(page()->drawingArea())) {
+    if (auto* drawingArea = static_cast<AcceleratedDrawingAreaProxy*>(page()->drawingArea())) {
         // Web Process expects sizes in UI units, and not raw device units.
         drawingArea->setSize(roundedIntSize(dipSize()), IntSize(), IntSize());
         FloatRect visibleContentsRect(contentPosition(), visibleContentsSize());
         visibleContentsRect.intersect(FloatRect(FloatPoint(), contentsSize()));
-        drawingArea->setVisibleContentsRect(visibleContentsRect, FloatPoint());
+        drawingArea->coordinatedLayerTreeHostProxy().setVisibleContentsRect(visibleContentsRect, FloatPoint());
     }
 }
 
@@ -406,7 +406,7 @@ WebCore::FloatSize WebView::visibleContentsSize() const
 
 std::unique_ptr<DrawingAreaProxy> WebView::createDrawingAreaProxy()
 {
-    return std::make_unique<CoordinatedDrawingAreaProxy>(*m_page);
+    return std::make_unique<AcceleratedDrawingAreaProxy>(*m_page);
 }
 
 void WebView::setViewNeedsDisplay(const WebCore::Region& region)