Title: [202855] trunk/Source/WebKit2
Revision
202855
Author
[email protected]
Date
2016-07-06 04:32:07 -0700 (Wed, 06 Jul 2016)

Log Message

Duplicated code in DrawingAreaImpl and CoordinatedDrawingArea
https://bugs.webkit.org/show_bug.cgi?id=159259

Reviewed by Žan Doberšek.

It seems that CoordinatedDrawingArea is just a copy paste of DrawingAreaImpl with non-accelerated code path
removed. There's actually nothing (or very little) specific to coordinated graphics in the
CoordinatedDrawingArea implementation. This patch renames CoordinatedDrawingArea as AcceleratedDrawingArea and
makes DrawingAreaImpl inherit from it, so that in case of accelerated compositing the parent class is used, and
DrawingAreaImpl only adds the non accelerated code path.

* PlatformEfl.cmake:
* PlatformGTK.cmake:
* WebProcess/WebPage/AcceleratedDrawingArea.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp.
(WebKit::AcceleratedDrawingArea::~AcceleratedDrawingArea):
(WebKit::AcceleratedDrawingArea::AcceleratedDrawingArea):
(WebKit::AcceleratedDrawingArea::setNeedsDisplay):
(WebKit::AcceleratedDrawingArea::setNeedsDisplayInRect):
(WebKit::AcceleratedDrawingArea::scroll):
(WebKit::AcceleratedDrawingArea::pageBackgroundTransparencyChanged):
(WebKit::AcceleratedDrawingArea::setLayerTreeStateIsFrozen):
(WebKit::AcceleratedDrawingArea::forceRepaint):
(WebKit::AcceleratedDrawingArea::forceRepaintAsync):
(WebKit::AcceleratedDrawingArea::setPaintingEnabled):
(WebKit::AcceleratedDrawingArea::updatePreferences):
(WebKit::AcceleratedDrawingArea::mainFrameContentSizeChanged):
(WebKit::AcceleratedDrawingArea::layerHostDidFlushLayers):
(WebKit::AcceleratedDrawingArea::graphicsLayerFactory):
(WebKit::AcceleratedDrawingArea::setRootCompositingLayer):
(WebKit::AcceleratedDrawingArea::scheduleCompositingLayerFlush):
(WebKit::AcceleratedDrawingArea::scheduleCompositingLayerFlushImmediately):
(WebKit::AcceleratedDrawingArea::updateBackingStoreState):
(WebKit::AcceleratedDrawingArea::sendDidUpdateBackingStoreState):
(WebKit::AcceleratedDrawingArea::suspendPainting):
(WebKit::AcceleratedDrawingArea::resumePainting):
(WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode):
(WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModeSoon):
(WebKit::AcceleratedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage):
(WebKit::AcceleratedDrawingArea::viewStateDidChange):
(WebKit::AcceleratedDrawingArea::attachViewOverlayGraphicsLayer):
* WebProcess/WebPage/AcceleratedDrawingArea.h: Renamed from Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h.
(WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModePending):
(WebKit::AcceleratedDrawingArea::didUpdateBackingStoreState):
(WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingMode):
* WebProcess/WebPage/DrawingArea.cpp:
(WebKit::DrawingArea::create):
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::DrawingAreaImpl):
(WebKit::DrawingAreaImpl::setNeedsDisplay):
(WebKit::DrawingAreaImpl::setNeedsDisplayInRect):
(WebKit::DrawingAreaImpl::scroll):
(WebKit::DrawingAreaImpl::forceRepaint):
(WebKit::DrawingAreaImpl::setRootCompositingLayer):
(WebKit::DrawingAreaImpl::updateBackingStoreState):
(WebKit::DrawingAreaImpl::didUpdateBackingStoreState):
(WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState):
(WebKit::DrawingAreaImpl::suspendPainting):
(WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode):
(WebKit::DrawingAreaImpl::~DrawingAreaImpl): Deleted.
(WebKit::DrawingAreaImpl::mainFrameContentSizeChanged): Deleted.
(WebKit::DrawingAreaImpl::updatePreferences): Deleted.
(WebKit::DrawingAreaImpl::didUpdate): Deleted.
(WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Deleted.
(WebKit::DrawingAreaImpl::scheduleDisplay): Deleted.
(WebKit::DrawingAreaImpl::displayTimerFired): Deleted.
(WebKit::DrawingAreaImpl::display): Deleted.
(WebKit::shouldPaintBoundsRect): Deleted.
(WebKit::DrawingAreaImpl::setNativeSurfaceHandleForCompositing): Deleted.
* WebProcess/WebPage/DrawingAreaImpl.h:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (202854 => 202855)


--- trunk/Source/WebKit2/ChangeLog	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/ChangeLog	2016-07-06 11:32:07 UTC (rev 202855)
@@ -1,3 +1,75 @@
+2016-07-06  Carlos Garcia Campos  <[email protected]>
+
+        Duplicated code in DrawingAreaImpl and CoordinatedDrawingArea
+        https://bugs.webkit.org/show_bug.cgi?id=159259
+
+        Reviewed by Žan Doberšek.
+
+        It seems that CoordinatedDrawingArea is just a copy paste of DrawingAreaImpl with non-accelerated code path
+        removed. There's actually nothing (or very little) specific to coordinated graphics in the
+        CoordinatedDrawingArea implementation. This patch renames CoordinatedDrawingArea as AcceleratedDrawingArea and
+        makes DrawingAreaImpl inherit from it, so that in case of accelerated compositing the parent class is used, and
+        DrawingAreaImpl only adds the non accelerated code path.
+
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * WebProcess/WebPage/AcceleratedDrawingArea.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp.
+        (WebKit::AcceleratedDrawingArea::~AcceleratedDrawingArea):
+        (WebKit::AcceleratedDrawingArea::AcceleratedDrawingArea):
+        (WebKit::AcceleratedDrawingArea::setNeedsDisplay):
+        (WebKit::AcceleratedDrawingArea::setNeedsDisplayInRect):
+        (WebKit::AcceleratedDrawingArea::scroll):
+        (WebKit::AcceleratedDrawingArea::pageBackgroundTransparencyChanged):
+        (WebKit::AcceleratedDrawingArea::setLayerTreeStateIsFrozen):
+        (WebKit::AcceleratedDrawingArea::forceRepaint):
+        (WebKit::AcceleratedDrawingArea::forceRepaintAsync):
+        (WebKit::AcceleratedDrawingArea::setPaintingEnabled):
+        (WebKit::AcceleratedDrawingArea::updatePreferences):
+        (WebKit::AcceleratedDrawingArea::mainFrameContentSizeChanged):
+        (WebKit::AcceleratedDrawingArea::layerHostDidFlushLayers):
+        (WebKit::AcceleratedDrawingArea::graphicsLayerFactory):
+        (WebKit::AcceleratedDrawingArea::setRootCompositingLayer):
+        (WebKit::AcceleratedDrawingArea::scheduleCompositingLayerFlush):
+        (WebKit::AcceleratedDrawingArea::scheduleCompositingLayerFlushImmediately):
+        (WebKit::AcceleratedDrawingArea::updateBackingStoreState):
+        (WebKit::AcceleratedDrawingArea::sendDidUpdateBackingStoreState):
+        (WebKit::AcceleratedDrawingArea::suspendPainting):
+        (WebKit::AcceleratedDrawingArea::resumePainting):
+        (WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode):
+        (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModeSoon):
+        (WebKit::AcceleratedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage):
+        (WebKit::AcceleratedDrawingArea::viewStateDidChange):
+        (WebKit::AcceleratedDrawingArea::attachViewOverlayGraphicsLayer):
+        * WebProcess/WebPage/AcceleratedDrawingArea.h: Renamed from Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h.
+        (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModePending):
+        (WebKit::AcceleratedDrawingArea::didUpdateBackingStoreState):
+        (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingMode):
+        * WebProcess/WebPage/DrawingArea.cpp:
+        (WebKit::DrawingArea::create):
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::DrawingAreaImpl):
+        (WebKit::DrawingAreaImpl::setNeedsDisplay):
+        (WebKit::DrawingAreaImpl::setNeedsDisplayInRect):
+        (WebKit::DrawingAreaImpl::scroll):
+        (WebKit::DrawingAreaImpl::forceRepaint):
+        (WebKit::DrawingAreaImpl::setRootCompositingLayer):
+        (WebKit::DrawingAreaImpl::updateBackingStoreState):
+        (WebKit::DrawingAreaImpl::didUpdateBackingStoreState):
+        (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState):
+        (WebKit::DrawingAreaImpl::suspendPainting):
+        (WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode):
+        (WebKit::DrawingAreaImpl::~DrawingAreaImpl): Deleted.
+        (WebKit::DrawingAreaImpl::mainFrameContentSizeChanged): Deleted.
+        (WebKit::DrawingAreaImpl::updatePreferences): Deleted.
+        (WebKit::DrawingAreaImpl::didUpdate): Deleted.
+        (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Deleted.
+        (WebKit::DrawingAreaImpl::scheduleDisplay): Deleted.
+        (WebKit::DrawingAreaImpl::displayTimerFired): Deleted.
+        (WebKit::DrawingAreaImpl::display): Deleted.
+        (WebKit::shouldPaintBoundsRect): Deleted.
+        (WebKit::DrawingAreaImpl::setNativeSurfaceHandleForCompositing): Deleted.
+        * WebProcess/WebPage/DrawingAreaImpl.h:
+
 2016-07-06  Youenn Fablet  <[email protected]>
 
         Refactor NetworkResourceLoadParameters

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (202854 => 202855)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2016-07-06 11:32:07 UTC (rev 202855)
@@ -196,11 +196,11 @@
 
     WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
 
+    WebProcess/WebPage/AcceleratedDrawingArea.cpp
     WebProcess/WebPage/DrawingAreaImpl.cpp
 
     WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp
     WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
-    WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp
     WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
     WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp
     WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp

Modified: trunk/Source/WebKit2/PlatformGTK.cmake (202854 => 202855)


--- trunk/Source/WebKit2/PlatformGTK.cmake	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/PlatformGTK.cmake	2016-07-06 11:32:07 UTC (rev 202855)
@@ -339,6 +339,7 @@
 
     WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
 
+    WebProcess/WebPage/AcceleratedDrawingArea.cpp
     WebProcess/WebPage/DrawingAreaImpl.cpp
 
     WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp

Copied: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp (from rev 202854, trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp) (0 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp	2016-07-06 11:32:07 UTC (rev 202855)
@@ -0,0 +1,393 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AcceleratedDrawingArea.h"
+
+#include "DrawingAreaProxyMessages.h"
+#include "LayerTreeHost.h"
+#include "UpdateInfo.h"
+#include "WebPage.h"
+#include "WebPageCreationParameters.h"
+#include "WebPreferencesKeys.h"
+#include <WebCore/MainFrame.h>
+#include <WebCore/Page.h>
+#include <WebCore/PageOverlayController.h>
+#include <WebCore/Settings.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+AcceleratedDrawingArea::~AcceleratedDrawingArea()
+{
+    if (m_layerTreeHost)
+        m_layerTreeHost->invalidate();
+}
+
+AcceleratedDrawingArea::AcceleratedDrawingArea(WebPage& webPage, const WebPageCreationParameters& parameters)
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
+    : DrawingArea(DrawingAreaTypeCoordinated, webPage)
+#else
+    : DrawingArea(DrawingAreaTypeImpl, webPage)
+#endif
+    , m_exitCompositingTimer(RunLoop::main(), this, &AcceleratedDrawingArea::exitAcceleratedCompositingMode)
+{
+    if (!m_webPage.isVisible())
+        suspendPainting();
+}
+
+void AcceleratedDrawingArea::setNeedsDisplay()
+{
+    if (!m_isPaintingEnabled)
+        return;
+
+    if (m_layerTreeHost)
+        m_layerTreeHost->setNonCompositedContentsNeedDisplay();
+}
+
+void AcceleratedDrawingArea::setNeedsDisplayInRect(const IntRect& rect)
+{
+    if (!m_isPaintingEnabled)
+        return;
+
+    if (m_layerTreeHost)
+        m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect);
+}
+
+void AcceleratedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
+{
+    if (!m_isPaintingEnabled)
+        return;
+
+    if (m_layerTreeHost)
+        m_layerTreeHost->scrollNonCompositedContents(scrollRect);
+}
+
+void AcceleratedDrawingArea::pageBackgroundTransparencyChanged()
+{
+    if (m_layerTreeHost)
+        m_layerTreeHost->pageBackgroundTransparencyChanged();
+}
+
+void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen)
+{
+    if (m_layerTreeStateIsFrozen == isFrozen)
+        return;
+
+    m_layerTreeStateIsFrozen = isFrozen;
+
+    if (m_layerTreeHost)
+        m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen);
+
+    if (isFrozen)
+        m_exitCompositingTimer.stop();
+    else if (m_wantsToExitAcceleratedCompositingMode)
+        exitAcceleratedCompositingModeSoon();
+}
+
+void AcceleratedDrawingArea::forceRepaint()
+{
+    setNeedsDisplay();
+
+    m_webPage.layoutIfNeeded();
+
+    if (!m_layerTreeHost)
+        return;
+
+    // FIXME: We need to do the same work as the layerHostDidFlushLayers function here,
+    // but clearly it doesn't make sense to call the function with that name.
+    // Consider refactoring and renaming it.
+    if (m_compositingAccordingToProxyMessages)
+        m_layerTreeHost->forceRepaint();
+    else {
+        // Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to
+        // prevent layerHostDidFlushLayers() from being called a second time.
+        m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
+        layerHostDidFlushLayers();
+    }
+}
+
+bool AcceleratedDrawingArea::forceRepaintAsync(uint64_t callbackID)
+{
+    return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID);
+}
+
+void AcceleratedDrawingArea::setPaintingEnabled(bool paintingEnabled)
+{
+    m_isPaintingEnabled = paintingEnabled;
+}
+
+void AcceleratedDrawingArea::updatePreferences(const WebPreferencesStore& store)
+{
+    m_webPage.corePage()->settings().setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()));
+    if (!m_layerTreeHost)
+        enterAcceleratedCompositingMode(nullptr);
+}
+
+void AcceleratedDrawingArea::mainFrameContentSizeChanged(const IntSize& size)
+{
+    if (m_webPage.useFixedLayout() && m_layerTreeHost)
+        m_layerTreeHost->sizeDidChange(size);
+    m_webPage.mainFrame()->pageOverlayController().didChangeDocumentSize();
+}
+
+void AcceleratedDrawingArea::layerHostDidFlushLayers()
+{
+    ASSERT(m_layerTreeHost);
+    m_layerTreeHost->forceRepaint();
+
+    if (m_shouldSendDidUpdateBackingStoreState && !exitAcceleratedCompositingModePending()) {
+        sendDidUpdateBackingStoreState();
+        return;
+    }
+
+    ASSERT(!m_compositingAccordingToProxyMessages);
+    if (!exitAcceleratedCompositingModePending()) {
+        m_webPage.send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
+        m_compositingAccordingToProxyMessages = true;
+    }
+}
+
+GraphicsLayerFactory* AcceleratedDrawingArea::graphicsLayerFactory()
+{
+    return m_layerTreeHost ? m_layerTreeHost->graphicsLayerFactory() : nullptr;
+}
+
+void AcceleratedDrawingArea::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
+{
+    ASSERT(m_layerTreeHost);
+
+    // FIXME: Instead of using nested if statements, we should keep a compositing state
+    // enum in the AcceleratedDrawingArea object and have a changeAcceleratedCompositingState function
+    // that takes the new state.
+
+    if (graphicsLayer) {
+        // We're already in accelerated compositing mode, but the root compositing layer changed.
+
+        m_exitCompositingTimer.stop();
+        m_wantsToExitAcceleratedCompositingMode = false;
+
+        // If we haven't sent the EnterAcceleratedCompositingMode message, make sure that the
+        // layer tree host calls us back after the next layer flush so we can send it then.
+        if (!m_compositingAccordingToProxyMessages)
+            m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
+    }
+    m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
+}
+
+void AcceleratedDrawingArea::scheduleCompositingLayerFlush()
+{
+    if (m_layerTreeHost)
+        m_layerTreeHost->scheduleLayerFlush();
+}
+
+void AcceleratedDrawingArea::scheduleCompositingLayerFlushImmediately()
+{
+    scheduleCompositingLayerFlush();
+}
+
+void AcceleratedDrawingArea::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const IntSize& size, const IntSize& scrollOffset)
+{
+    ASSERT(!m_inUpdateBackingStoreState);
+    m_inUpdateBackingStoreState = true;
+
+    ASSERT_ARG(stateID, stateID >= m_backingStoreStateID);
+    if (stateID != m_backingStoreStateID) {
+        m_backingStoreStateID = stateID;
+        m_shouldSendDidUpdateBackingStoreState = true;
+
+        m_webPage.setDeviceScaleFactor(deviceScaleFactor);
+        m_webPage.setSize(size);
+        m_webPage.layoutIfNeeded();
+        m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
+
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
+        // Coordinated Graphics sets the size of the root layer to contents size.
+        if (!m_webPage.useFixedLayout())
+            m_layerTreeHost->sizeDidChange(m_webPage.size());
+#else
+        if (m_layerTreeHost)
+            m_layerTreeHost->sizeDidChange(m_webPage.size());
+#endif
+    } else {
+        ASSERT(size == m_webPage.size());
+        if (!m_shouldSendDidUpdateBackingStoreState) {
+            // We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do.
+            m_inUpdateBackingStoreState = false;
+            return;
+        }
+    }
+
+    didUpdateBackingStoreState();
+
+    if (respondImmediately) {
+        // Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just
+        // send back an empty UpdateInfo struct.
+        if (m_isPaintingSuspended)
+            resumePainting();
+
+        sendDidUpdateBackingStoreState();
+    }
+
+    m_inUpdateBackingStoreState = false;
+}
+
+void AcceleratedDrawingArea::sendDidUpdateBackingStoreState()
+{
+    ASSERT(m_shouldSendDidUpdateBackingStoreState);
+
+    m_shouldSendDidUpdateBackingStoreState = false;
+
+    UpdateInfo updateInfo;
+    updateInfo.viewSize = m_webPage.size();
+    updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
+
+    LayerTreeContext layerTreeContext;
+    if (m_layerTreeHost) {
+        layerTreeContext = m_layerTreeHost->layerTreeContext();
+
+        // We don't want the layer tree host to notify after the next scheduled
+        // layer flush because that might end up sending an EnterAcceleratedCompositingMode
+        // message back to the UI process, but the updated layer tree context
+        // will be sent back in the DidUpdateBackingStoreState message.
+        m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
+        m_layerTreeHost->forceRepaint();
+    }
+
+    m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
+    m_compositingAccordingToProxyMessages = !layerTreeContext.isEmpty();
+}
+
+void AcceleratedDrawingArea::suspendPainting()
+{
+    ASSERT(!m_isPaintingSuspended);
+
+    if (m_layerTreeHost)
+        m_layerTreeHost->pauseRendering();
+
+    m_isPaintingSuspended = true;
+
+    m_webPage.corePage()->suspendScriptedAnimations();
+}
+
+void AcceleratedDrawingArea::resumePainting()
+{
+    if (!m_isPaintingSuspended) {
+        // FIXME: We can get a call to resumePainting when painting is not suspended.
+        // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.
+        return;
+    }
+
+    if (m_layerTreeHost)
+        m_layerTreeHost->resumeRendering();
+
+    m_isPaintingSuspended = false;
+
+    // FIXME: We shouldn't always repaint everything here.
+    setNeedsDisplay();
+
+    m_webPage.corePage()->resumeScriptedAnimations();
+}
+
+void AcceleratedDrawingArea::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
+{
+    m_exitCompositingTimer.stop();
+    m_wantsToExitAcceleratedCompositingMode = false;
+
+    m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID));
+
+    ASSERT(!m_layerTreeHost);
+    m_layerTreeHost = LayerTreeHost::create(m_webPage);
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+    if (m_nativeSurfaceHandleForCompositing)
+        m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
+#endif
+    if (!m_inUpdateBackingStoreState)
+        m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
+    if (m_isPaintingSuspended)
+        m_layerTreeHost->pauseRendering();
+
+    m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
+}
+
+void AcceleratedDrawingArea::exitAcceleratedCompositingModeSoon()
+{
+    if (m_layerTreeStateIsFrozen) {
+        m_wantsToExitAcceleratedCompositingMode = true;
+        return;
+    }
+
+    if (exitAcceleratedCompositingModePending())
+        return;
+
+    m_exitCompositingTimer.startOneShot(0);
+}
+
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
+void AcceleratedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
+{
+    m_layerTreeHost->didReceiveCoordinatedLayerTreeHostMessage(connection, decoder);
+}
+#endif
+
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+void AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing(uint64_t handle)
+{
+    m_nativeSurfaceHandleForCompositing = handle;
+    if (m_layerTreeHost) {
+        m_webPage.corePage()->settings().setAcceleratedCompositingEnabled(true);
+        m_layerTreeHost->setNativeSurfaceHandleForCompositing(handle);
+    }
+}
+
+void AcceleratedDrawingArea::destroyNativeSurfaceHandleForCompositing(bool& handled)
+{
+    handled = true;
+    setNativeSurfaceHandleForCompositing(0);
+}
+#endif
+
+void AcceleratedDrawingArea::viewStateDidChange(ViewState::Flags changed, bool, const Vector<uint64_t>&)
+{
+    if (changed & ViewState::IsVisible) {
+        if (m_webPage.isVisible())
+            resumePainting();
+        else
+            suspendPainting();
+    }
+}
+
+void AcceleratedDrawingArea::attachViewOverlayGraphicsLayer(Frame* frame, GraphicsLayer* viewOverlayRootLayer)
+{
+    if (!frame->isMainFrame())
+        return;
+
+    if (m_layerTreeHost)
+        m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
+}
+
+} // namespace WebKit

Copied: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h (from rev 202854, trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h) (0 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h	2016-07-06 11:32:07 UTC (rev 202855)
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "DrawingArea.h"
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+class LayerTreeHost;
+
+class AcceleratedDrawingArea : public DrawingArea {
+public:
+    AcceleratedDrawingArea(WebPage&, const WebPageCreationParameters&);
+    virtual ~AcceleratedDrawingArea();
+
+protected:
+    // DrawingArea
+    void setNeedsDisplay() override;
+    void setNeedsDisplayInRect(const WebCore::IntRect&) override;
+    void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
+    void pageBackgroundTransparencyChanged() override;
+    void setLayerTreeStateIsFrozen(bool) override;
+    bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }
+    LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); }
+    void forceRepaint() override;
+    bool forceRepaintAsync(uint64_t callbackID) override;
+
+    void setPaintingEnabled(bool) override;
+    void updatePreferences(const WebPreferencesStore&) override;
+    void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
+
+    WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
+    void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
+    void scheduleCompositingLayerFlush() override;
+    void scheduleCompositingLayerFlushImmediately() override;
+
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
+    void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override;
+#endif
+
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+    void setNativeSurfaceHandleForCompositing(uint64_t) override;
+    void destroyNativeSurfaceHandleForCompositing(bool&) override;
+#endif
+
+    void viewStateDidChange(WebCore::ViewState::Flags, bool /* wantsDidUpdateViewState */, const Vector<uint64_t>& /* callbackIDs */) override;
+    void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
+
+    void layerHostDidFlushLayers() override;
+
+    // IPC message handlers.
+    void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override;
+
+    void exitAcceleratedCompositingModeSoon();
+    bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
+
+    virtual void suspendPainting();
+    virtual void resumePainting();
+
+    virtual void sendDidUpdateBackingStoreState();
+    virtual void didUpdateBackingStoreState() { }
+
+    virtual void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
+    virtual void exitAcceleratedCompositingMode() { }
+
+    uint64_t m_backingStoreStateID { 0 };
+
+    // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.
+    bool m_isPaintingEnabled { true };
+
+    // Whether we're currently processing an UpdateBackingStoreState message.
+    bool m_inUpdateBackingStoreState { false };
+
+    // When true, we should send an UpdateBackingStoreState message instead of any other messages
+    // we normally send to the UI process.
+    bool m_shouldSendDidUpdateBackingStoreState { false };
+
+    // True between sending the 'enter compositing' messages, and the 'exit compositing' message.
+    bool m_compositingAccordingToProxyMessages { false };
+
+    // When true, we maintain the layer tree in its current state by not leaving accelerated compositing mode
+    // and not scheduling layer flushes.
+    bool m_layerTreeStateIsFrozen { false };
+
+    // True when we were asked to exit accelerated compositing mode but couldn't because layer tree
+    // state was frozen.
+    bool m_wantsToExitAcceleratedCompositingMode { false };
+
+    // Whether painting is suspended. We'll still keep track of the dirty region but we
+    // won't paint until painting has resumed again.
+    bool m_isPaintingSuspended { false };
+
+    RunLoop::Timer<AcceleratedDrawingArea> m_exitCompositingTimer;
+
+    // The layer tree host that handles accelerated compositing.
+    RefPtr<LayerTreeHost> m_layerTreeHost;
+};
+
+} // namespace WebKit

Deleted: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp (202854 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp	2016-07-06 11:32:07 UTC (rev 202855)
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(COORDINATED_GRAPHICS)
-#include "CoordinatedDrawingArea.h"
-
-#include "CoordinatedLayerTreeHost.h"
-#include "DrawingAreaProxyMessages.h"
-#include "LayerTreeContext.h"
-#include "PageOverlayController.h"
-#include "ShareableBitmap.h"
-#include "UpdateInfo.h"
-#include "WebPage.h"
-#include "WebPageCreationParameters.h"
-#include "WebPreferencesKeys.h"
-#include "WebProcess.h"
-#include <WebCore/GraphicsContext.h>
-#include <WebCore/MainFrame.h>
-#include <WebCore/Page.h>
-#include <WebCore/PageOverlayController.h>
-#include <WebCore/Settings.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-CoordinatedDrawingArea::~CoordinatedDrawingArea()
-{
-    m_layerTreeHost->invalidate();
-}
-
-CoordinatedDrawingArea::CoordinatedDrawingArea(WebPage& webPage, const WebPageCreationParameters& parameters)
-    : DrawingArea(DrawingAreaTypeCoordinated, webPage)
-    , m_backingStoreStateID(0)
-    , m_isPaintingEnabled(true)
-    , m_inUpdateBackingStoreState(false)
-    , m_shouldSendDidUpdateBackingStoreState(false)
-    , m_compositingAccordingToProxyMessages(false)
-    , m_layerTreeStateIsFrozen(false)
-    , m_wantsToExitAcceleratedCompositingMode(false)
-    , m_isPaintingSuspended(false)
-    , m_exitCompositingTimer(RunLoop::main(), this, &CoordinatedDrawingArea::exitAcceleratedCompositingMode)
-{
-    // Always use compositing in CoordinatedGraphics
-    enterAcceleratedCompositingMode(0);
-
-    if (!(parameters.viewState & ViewState::IsVisible))
-        suspendPainting();
-}
-
-void CoordinatedDrawingArea::setNeedsDisplay()
-{
-    if (!m_isPaintingEnabled)
-        return;
-
-    m_layerTreeHost->setNonCompositedContentsNeedDisplay();
-}
-
-void CoordinatedDrawingArea::setNeedsDisplayInRect(const IntRect& rect)
-{
-    if (!m_isPaintingEnabled)
-        return;
-
-    m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect);
-}
-
-void CoordinatedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
-{
-    if (!m_isPaintingEnabled)
-        return;
-
-    m_layerTreeHost->scrollNonCompositedContents(scrollRect);
-}
-
-void CoordinatedDrawingArea::pageBackgroundTransparencyChanged()
-{
-    m_layerTreeHost->pageBackgroundTransparencyChanged();
-}
-
-void CoordinatedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen)
-{
-    if (m_layerTreeStateIsFrozen == isFrozen)
-        return;
-
-    m_layerTreeStateIsFrozen = isFrozen;
-
-    m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen);
-
-    if (isFrozen)
-        m_exitCompositingTimer.stop();
-    else if (m_wantsToExitAcceleratedCompositingMode)
-        exitAcceleratedCompositingModeSoon();
-}
-
-void CoordinatedDrawingArea::forceRepaint()
-{
-    setNeedsDisplay();
-
-    m_webPage.layoutIfNeeded();
-
-    // FIXME: We need to do the same work as the layerHostDidFlushLayers function here,
-    // but clearly it doesn't make sense to call the function with that name.
-    // Consider refactoring and renaming it.
-    if (m_compositingAccordingToProxyMessages)
-        m_layerTreeHost->forceRepaint();
-    else {
-        // Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to
-        // prevent layerHostDidFlushLayers() from being called a second time.
-        m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
-        layerHostDidFlushLayers();
-    }
-}
-
-bool CoordinatedDrawingArea::forceRepaintAsync(uint64_t callbackID)
-{
-    return m_layerTreeHost->forceRepaintAsync(callbackID);
-}
-
-void CoordinatedDrawingArea::setPaintingEnabled(bool paintingEnabled)
-{
-    m_isPaintingEnabled = paintingEnabled;
-}
-
-void CoordinatedDrawingArea::updatePreferences(const WebPreferencesStore& store)
-{
-    m_webPage.corePage()->settings().setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()));
-}
-
-void CoordinatedDrawingArea::mainFrameContentSizeChanged(const WebCore::IntSize& size)
-{
-    if (m_webPage.useFixedLayout())
-        m_layerTreeHost->sizeDidChange(size);
-    m_webPage.mainFrame()->pageOverlayController().didChangeDocumentSize();
-}
-
-void CoordinatedDrawingArea::layerHostDidFlushLayers()
-{
-    m_layerTreeHost->forceRepaint();
-
-    if (m_shouldSendDidUpdateBackingStoreState && !exitAcceleratedCompositingModePending()) {
-        sendDidUpdateBackingStoreState();
-        return;
-    }
-
-    ASSERT(!m_compositingAccordingToProxyMessages);
-    if (!exitAcceleratedCompositingModePending()) {
-        m_webPage.send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
-        m_compositingAccordingToProxyMessages = true;
-    }
-}
-
-GraphicsLayerFactory* CoordinatedDrawingArea::graphicsLayerFactory()
-{
-    return m_layerTreeHost->graphicsLayerFactory();
-}
-
-void CoordinatedDrawingArea::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
-{
-    // FIXME: Instead of using nested if statements, we should keep a compositing state
-    // enum in the CoordinatedDrawingArea object and have a changeAcceleratedCompositingState function
-    // that takes the new state.
-
-    if (graphicsLayer) {
-        // We're already in accelerated compositing mode, but the root compositing layer changed.
-
-        m_exitCompositingTimer.stop();
-        m_wantsToExitAcceleratedCompositingMode = false;
-
-        // If we haven't sent the EnterAcceleratedCompositingMode message, make sure that the
-        // layer tree host calls us back after the next layer flush so we can send it then.
-        if (!m_compositingAccordingToProxyMessages)
-            m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
-    }
-    m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
-}
-
-void CoordinatedDrawingArea::scheduleCompositingLayerFlush()
-{
-    m_layerTreeHost->scheduleLayerFlush();
-}
-
-void CoordinatedDrawingArea::scheduleCompositingLayerFlushImmediately()
-{
-    scheduleCompositingLayerFlush();
-}
-
-void CoordinatedDrawingArea::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)
-{
-    ASSERT(!m_inUpdateBackingStoreState);
-    m_inUpdateBackingStoreState = true;
-
-    ASSERT_ARG(stateID, stateID >= m_backingStoreStateID);
-    if (stateID != m_backingStoreStateID) {
-        m_backingStoreStateID = stateID;
-        m_shouldSendDidUpdateBackingStoreState = true;
-
-        m_webPage.setDeviceScaleFactor(deviceScaleFactor);
-        m_webPage.setSize(size);
-        m_webPage.layoutIfNeeded();
-        m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
-
-        // Coordinated Graphics sets the size of the root layer to contents size.
-        if (!m_webPage.useFixedLayout())
-            m_layerTreeHost->sizeDidChange(m_webPage.size());
-    } else {
-        ASSERT(size == m_webPage.size());
-        if (!m_shouldSendDidUpdateBackingStoreState) {
-            // We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do.
-            m_inUpdateBackingStoreState = false;
-            return;
-        }
-    }
-
-    if (respondImmediately) {
-        // Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just
-        // send back an empty UpdateInfo struct.
-        if (m_isPaintingSuspended)
-            resumePainting();
-
-        sendDidUpdateBackingStoreState();
-    }
-
-    m_inUpdateBackingStoreState = false;
-}
-
-void CoordinatedDrawingArea::sendDidUpdateBackingStoreState()
-{
-    ASSERT(m_shouldSendDidUpdateBackingStoreState);
-
-    m_shouldSendDidUpdateBackingStoreState = false;
-
-    UpdateInfo updateInfo;
-
-    LayerTreeContext layerTreeContext;
-
-    updateInfo.viewSize = m_webPage.size();
-    updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
-
-    layerTreeContext = m_layerTreeHost->layerTreeContext();
-
-    // We don't want the layer tree host to notify after the next scheduled
-    // layer flush because that might end up sending an EnterAcceleratedCompositingMode
-    // message back to the UI process, but the updated layer tree context
-    // will be sent back in the DidUpdateBackingStoreState message.
-    m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
-    m_layerTreeHost->forceRepaint();
-
-    m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
-    m_compositingAccordingToProxyMessages = !layerTreeContext.isEmpty();
-}
-
-void CoordinatedDrawingArea::suspendPainting()
-{
-    ASSERT(!m_isPaintingSuspended);
-
-    m_layerTreeHost->pauseRendering();
-
-    m_isPaintingSuspended = true;
-
-    m_webPage.corePage()->suspendScriptedAnimations();
-}
-
-void CoordinatedDrawingArea::resumePainting()
-{
-    if (!m_isPaintingSuspended) {
-        // FIXME: We can get a call to resumePainting when painting is not suspended.
-        // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.
-        return;
-    }
-
-    m_layerTreeHost->resumeRendering();
-
-    m_isPaintingSuspended = false;
-
-    // FIXME: We shouldn't always repaint everything here.
-    setNeedsDisplay();
-
-    m_webPage.corePage()->resumeScriptedAnimations();
-}
-
-void CoordinatedDrawingArea::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
-{
-    m_exitCompositingTimer.stop();
-    m_wantsToExitAcceleratedCompositingMode = false;
-
-    m_layerTreeHost = LayerTreeHost::create(m_webPage);
-    if (!m_inUpdateBackingStoreState)
-        m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
-
-    m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
-}
-
-void CoordinatedDrawingArea::exitAcceleratedCompositingModeSoon()
-{
-    if (m_layerTreeStateIsFrozen) {
-        m_wantsToExitAcceleratedCompositingMode = true;
-        return;
-    }
-
-    if (exitAcceleratedCompositingModePending())
-        return;
-
-    m_exitCompositingTimer.startOneShot(0);
-}
-
-void CoordinatedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
-{
-    m_layerTreeHost->didReceiveCoordinatedLayerTreeHostMessage(connection, decoder);
-}
-
-void CoordinatedDrawingArea::viewStateDidChange(ViewState::Flags changed, bool, const Vector<uint64_t>&)
-{
-    if (changed & ViewState::IsVisible) {
-        if (m_webPage.isVisible())
-            resumePainting();
-        else
-            suspendPainting();
-    }
-}
-
-void CoordinatedDrawingArea::attachViewOverlayGraphicsLayer(WebCore::Frame* frame, WebCore::GraphicsLayer* viewOverlayRootLayer)
-{
-    if (!frame->isMainFrame())
-        return;
-
-    m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
-}
-
-} // namespace WebKit
-#endif // USE(COORDINATED_GRAPHICS)

Deleted: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h (202854 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h	2016-07-06 11:32:07 UTC (rev 202855)
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CoordinatedDrawingArea_h
-#define CoordinatedDrawingArea_h
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include "DrawingArea.h"
-#include "LayerTreeHost.h"
-#include <WebCore/Region.h>
-#include <wtf/RunLoop.h>
-
-namespace WebKit {
-
-class CoordinatedDrawingArea : public DrawingArea {
-public:
-    CoordinatedDrawingArea(WebPage&, const WebPageCreationParameters&);
-    virtual ~CoordinatedDrawingArea();
-
-private:
-    // DrawingArea
-    void setNeedsDisplay() override;
-    void setNeedsDisplayInRect(const WebCore::IntRect&) override;
-    void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
-    void pageBackgroundTransparencyChanged() override;
-    void setLayerTreeStateIsFrozen(bool) override;
-    bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }
-    LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); }
-    void forceRepaint() override;
-    bool forceRepaintAsync(uint64_t callbackID) override;
-
-    void setPaintingEnabled(bool) override;
-    void updatePreferences(const WebPreferencesStore&) override;
-    void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
-
-    WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
-    void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
-    void scheduleCompositingLayerFlush() override;
-    void scheduleCompositingLayerFlushImmediately() override;
-
-    void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override;
-
-    void viewStateDidChange(WebCore::ViewState::Flags, bool /* wantsDidUpdateViewState */, const Vector<uint64_t>& /* callbackIDs */) override;
-    void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
-
-    void layerHostDidFlushLayers() override;
-
-    // IPC message handlers.
-    void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override;
-    virtual void suspendPainting();
-    virtual void resumePainting();
-
-    void sendDidUpdateBackingStoreState();
-
-    void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
-    void exitAcceleratedCompositingModeSoon();
-    bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
-    void exitAcceleratedCompositingMode() { }
-
-    uint64_t m_backingStoreStateID;
-
-    // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.
-    bool m_isPaintingEnabled;
-
-    // Whether we're currently processing an UpdateBackingStoreState message.
-    bool m_inUpdateBackingStoreState;
-
-    // When true, we should send an UpdateBackingStoreState message instead of any other messages
-    // we normally send to the UI process.
-    bool m_shouldSendDidUpdateBackingStoreState;
-
-    // True between sending the 'enter compositing' messages, and the 'exit compositing' message.
-    bool m_compositingAccordingToProxyMessages;
-
-    // When true, we maintain the layer tree in its current state by not leaving accelerated compositing mode
-    // and not scheduling layer flushes.
-    bool m_layerTreeStateIsFrozen;
-
-    // True when we were asked to exit accelerated compositing mode but couldn't because layer tree
-    // state was frozen.
-    bool m_wantsToExitAcceleratedCompositingMode;
-
-    // Whether painting is suspended. We'll still keep track of the dirty region but we
-    // won't paint until painting has resumed again.
-    bool m_isPaintingSuspended;
-
-    RunLoop::Timer<CoordinatedDrawingArea> m_exitCompositingTimer;
-
-    // The layer tree host that handles accelerated compositing.
-    RefPtr<LayerTreeHost> m_layerTreeHost;
-};
-
-} // namespace WebKit
-
-#endif // USE(COORDINATED_GRAPHICS)
-
-#endif // CoordinatedDrawingArea_h

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp (202854 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp	2016-07-06 11:32:07 UTC (rev 202855)
@@ -39,7 +39,7 @@
 #include "TiledCoreAnimationDrawingArea.h"
 #else
 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
-#include "CoordinatedDrawingArea.h"
+#include "AcceleratedDrawingArea.h"
 #else
 #include "DrawingAreaImpl.h"
 #endif
@@ -62,7 +62,7 @@
 #else
 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     case DrawingAreaTypeCoordinated:
-        return std::make_unique<CoordinatedDrawingArea>(webPage, parameters);
+        return std::make_unique<AcceleratedDrawingArea>(webPage, parameters);
 #else
     case DrawingAreaTypeImpl:
         return std::make_unique<DrawingAreaImpl>(webPage, parameters);
@@ -76,9 +76,6 @@
 DrawingArea::DrawingArea(DrawingAreaType type, WebPage& webPage)
     : m_type(type)
     , m_webPage(webPage)
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
-    , m_nativeSurfaceHandleForCompositing(0)
-#endif
 {
     WebProcess::singleton().addMessageReceiver(Messages::DrawingArea::messageReceiverName(), m_webPage.pageID(), *this);
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (202854 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2016-07-06 11:32:07 UTC (rev 202855)
@@ -146,8 +146,8 @@
     DrawingAreaType m_type;
     WebPage& m_webPage;
 
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
-    uint64_t m_nativeSurfaceHandleForCompositing;
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+    uint64_t m_nativeSurfaceHandleForCompositing { 0 };
 #endif
 
 private:

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (202854 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp	2016-07-06 11:32:07 UTC (rev 202855)
@@ -27,15 +27,13 @@
 #include "DrawingAreaImpl.h"
 
 #include "DrawingAreaProxyMessages.h"
-#include "LayerTreeContext.h"
+#include "LayerTreeHost.h"
 #include "ShareableBitmap.h"
 #include "UpdateInfo.h"
 #include "WebPage.h"
 #include "WebPageCreationParameters.h"
 #include "WebPreferencesKeys.h"
-#include "WebProcess.h"
 #include <WebCore/GraphicsContext.h>
-#include <WebCore/MainFrame.h>
 #include <WebCore/Page.h>
 #include <WebCore/Settings.h>
 
@@ -45,39 +43,19 @@
 
 DrawingAreaImpl::~DrawingAreaImpl()
 {
-    if (m_layerTreeHost)
-        m_layerTreeHost->invalidate();
 }
 
 DrawingAreaImpl::DrawingAreaImpl(WebPage& webPage, const WebPageCreationParameters& parameters)
-#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
-    : DrawingArea(DrawingAreaTypeCoordinated, webPage)
-#else
-    : DrawingArea(DrawingAreaTypeImpl, webPage)
-#endif
-    , m_backingStoreStateID(0)
-    , m_isPaintingEnabled(true)
-    , m_inUpdateBackingStoreState(false)
-    , m_shouldSendDidUpdateBackingStoreState(false)
-    , m_isWaitingForDidUpdate(false)
-    , m_compositingAccordingToProxyMessages(false)
-    , m_layerTreeStateIsFrozen(false)
-    , m_wantsToExitAcceleratedCompositingMode(false)
-    , m_isPaintingSuspended(!(parameters.viewState & ViewState::IsVisible))
-    , m_alwaysUseCompositing(false)
+    : AcceleratedDrawingArea(webPage, parameters)
     , m_displayTimer(RunLoop::main(), this, &DrawingAreaImpl::displayTimerFired)
-    , m_exitCompositingTimer(RunLoop::main(), this, &DrawingAreaImpl::exitAcceleratedCompositingMode)
 {
 }
 
 void DrawingAreaImpl::setNeedsDisplay()
 {
-    if (!m_isPaintingEnabled)
-        return;
-
     if (m_layerTreeHost) {
         ASSERT(m_dirtyRegion.isEmpty());
-        m_layerTreeHost->setNonCompositedContentsNeedDisplay();
+        AcceleratedDrawingArea::setNeedsDisplay();
         return;
     }
 
@@ -86,18 +64,17 @@
 
 void DrawingAreaImpl::setNeedsDisplayInRect(const IntRect& rect)
 {
-    if (!m_isPaintingEnabled)
-        return;
-
     if (m_layerTreeHost) {
         ASSERT(m_dirtyRegion.isEmpty());
-        m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect);
+        AcceleratedDrawingArea::setNeedsDisplayInRect(rect);
         return;
     }
-    
+
+    if (!m_isPaintingEnabled)
+        return;
+
     IntRect dirtyRect = rect;
     dirtyRect.intersect(m_webPage.bounds());
-
     if (dirtyRect.isEmpty())
         return;
 
@@ -107,18 +84,17 @@
 
 void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
 {
-    if (!m_isPaintingEnabled)
-        return;
-
     if (m_layerTreeHost) {
         ASSERT(m_scrollRect.isEmpty());
         ASSERT(m_scrollOffset.isEmpty());
         ASSERT(m_dirtyRegion.isEmpty());
-
-        m_layerTreeHost->scrollNonCompositedContents(scrollRect);
+        AcceleratedDrawingArea::scroll(scrollRect, scrollDelta);
         return;
     }
 
+    if (!m_isPaintingEnabled)
+        return;
+
     if (scrollRect.isEmpty())
         return;
 
@@ -151,8 +127,8 @@
 
         // And add them back.
         m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
-    } 
-    
+    }
+
     // Compute the scroll repaint region.
     Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta));
 
@@ -163,28 +139,6 @@
     m_scrollOffset += scrollDelta;
 }
 
-void DrawingAreaImpl::pageBackgroundTransparencyChanged()
-{
-    if (m_layerTreeHost)
-        m_layerTreeHost->pageBackgroundTransparencyChanged();
-}
-
-void DrawingAreaImpl::setLayerTreeStateIsFrozen(bool isFrozen)
-{
-    if (m_layerTreeStateIsFrozen == isFrozen)
-        return;
-
-    m_layerTreeStateIsFrozen = isFrozen;
-
-    if (m_layerTreeHost)
-        m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen);
-
-    if (isFrozen)
-        m_exitCompositingTimer.stop();
-    else if (m_wantsToExitAcceleratedCompositingMode)
-        exitAcceleratedCompositingModeSoon();
-}
-
 void DrawingAreaImpl::forceRepaint()
 {
     if (m_inUpdateBackingStoreState) {
@@ -191,41 +145,19 @@
         m_forceRepaintAfterBackingStoreStateUpdate = true;
         return;
     }
-
     m_forceRepaintAfterBackingStoreStateUpdate = false;
-    setNeedsDisplay();
 
-    m_webPage.layoutIfNeeded();
-
     if (m_layerTreeHost) {
-        // FIXME: We need to do the same work as the layerHostDidFlushLayers function here,
-        // but clearly it doesn't make sense to call the function with that name.
-        // Consider refactoring and renaming it.
-        if (m_compositingAccordingToProxyMessages)
-            m_layerTreeHost->forceRepaint();
-        else {
-            // Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to 
-            // prevent layerHostDidFlushLayers() from being called a second time.
-            m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
-            layerHostDidFlushLayers();
-        }
+        AcceleratedDrawingArea::forceRepaint();
         return;
     }
 
+    setNeedsDisplay();
+    m_webPage.layoutIfNeeded();
     m_isWaitingForDidUpdate = false;
     display();
 }
 
-bool DrawingAreaImpl::forceRepaintAsync(uint64_t callbackID)
-{
-    return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID);
-}
-
-void DrawingAreaImpl::setPaintingEnabled(bool paintingEnabled)
-{
-    m_isPaintingEnabled = paintingEnabled;
-}
-
 void DrawingAreaImpl::mainFrameContentSizeChanged(const WebCore::IntSize& newSize)
 {
 #if USE(COORDINATED_GRAPHICS_THREADED)
@@ -253,115 +185,44 @@
         enterAcceleratedCompositingMode(nullptr);
 }
 
-void DrawingAreaImpl::layerHostDidFlushLayers()
+void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
 {
-    ASSERT(m_layerTreeHost);
+    if (m_layerTreeHost) {
+        AcceleratedDrawingArea::setRootCompositingLayer(graphicsLayer);
 
-    m_layerTreeHost->forceRepaint();
-
-    if (m_shouldSendDidUpdateBackingStoreState && !exitAcceleratedCompositingModePending()) {
-        sendDidUpdateBackingStoreState();
+        if (!graphicsLayer && !m_alwaysUseCompositing) {
+            // We'll exit accelerated compositing mode on a timer, to avoid re-entering
+            // compositing code via display() and layout.
+            // If we're leaving compositing mode because of a setSize, it is safe to
+            // exit accelerated compositing mode right away.
+            if (m_inUpdateBackingStoreState)
+                exitAcceleratedCompositingMode();
+            else
+                exitAcceleratedCompositingModeSoon();
+        }
         return;
     }
 
-    if (!m_layerTreeHost)
+    if (!graphicsLayer)
         return;
 
-    ASSERT(!m_compositingAccordingToProxyMessages);
-    if (!exitAcceleratedCompositingModePending()) {
-        m_webPage.send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
-        m_compositingAccordingToProxyMessages = true;
-    }
+    // We're actually entering accelerated compositing mode.
+    enterAcceleratedCompositingMode(graphicsLayer);
 }
 
-GraphicsLayerFactory* DrawingAreaImpl::graphicsLayerFactory()
+void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)
 {
-    if (m_layerTreeHost)
-        return m_layerTreeHost->graphicsLayerFactory();
+    bool shouldUpdateDirtyRegion = stateID != m_backingStoreStateID && !m_layerTreeHost;
+    AcceleratedDrawingArea::updateBackingStoreState(stateID, respondImmediately, deviceScaleFactor, size, scrollOffset);
+    if (shouldUpdateDirtyRegion)
+        m_dirtyRegion = m_webPage.bounds();
 
-    return 0;
+    if (m_forceRepaintAfterBackingStoreStateUpdate)
+        forceRepaint();
 }
 
-void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
+void DrawingAreaImpl::didUpdateBackingStoreState()
 {
-    // FIXME: Instead of using nested if statements, we should keep a compositing state
-    // enum in the DrawingAreaImpl object and have a changeAcceleratedCompositingState function
-    // that takes the new state.
-
-    if (graphicsLayer) {
-        if (!m_layerTreeHost) {
-            // We're actually entering accelerated compositing mode.
-            enterAcceleratedCompositingMode(graphicsLayer);
-        } else {
-            // We're already in accelerated compositing mode, but the root compositing layer changed.
-
-            m_exitCompositingTimer.stop();
-            m_wantsToExitAcceleratedCompositingMode = false;
-
-            // If we haven't sent the EnterAcceleratedCompositingMode message, make sure that the
-            // layer tree host calls us back after the next layer flush so we can send it then.
-            if (!m_compositingAccordingToProxyMessages)
-                m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
-
-            m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
-        }
-    } else {
-        if (m_layerTreeHost) {
-            m_layerTreeHost->setRootCompositingLayer(0);
-            if (!m_alwaysUseCompositing) {
-                // We'll exit accelerated compositing mode on a timer, to avoid re-entering
-                // compositing code via display() and layout.
-                // If we're leaving compositing mode because of a setSize, it is safe to
-                // exit accelerated compositing mode right away.
-                if (m_inUpdateBackingStoreState)
-                    exitAcceleratedCompositingMode();
-                else
-                    exitAcceleratedCompositingModeSoon();
-            }
-        }
-    }
-}
-
-void DrawingAreaImpl::scheduleCompositingLayerFlush()
-{
-    if (!m_layerTreeHost)
-        return;
-    m_layerTreeHost->scheduleLayerFlush();
-}
-
-void DrawingAreaImpl::scheduleCompositingLayerFlushImmediately()
-{
-    scheduleCompositingLayerFlush();
-}
-
-void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)
-{
-    ASSERT(!m_inUpdateBackingStoreState);
-    m_inUpdateBackingStoreState = true;
-
-    ASSERT_ARG(stateID, stateID >= m_backingStoreStateID);
-    if (stateID != m_backingStoreStateID) {
-        m_backingStoreStateID = stateID;
-        m_shouldSendDidUpdateBackingStoreState = true;
-
-        m_webPage.setDeviceScaleFactor(deviceScaleFactor);
-        m_webPage.setSize(size);
-        m_webPage.layoutIfNeeded();
-        m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
-
-        if (m_layerTreeHost)
-            m_layerTreeHost->sizeDidChange(m_webPage.size());
-        else
-            m_dirtyRegion = m_webPage.bounds();
-    } else {
-        ASSERT(size == m_webPage.size());
-        if (!m_shouldSendDidUpdateBackingStoreState) {
-            // We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do.
-            m_inUpdateBackingStoreState = false;
-            return;
-        }
-    }
-
     // The UI process has updated to a new backing store state. Any Update messages we sent before
     // this point will be ignored. We wait to set this to false until after updating the page's
     // size so that any displays triggered by the relayout will be ignored. If we're supposed to
@@ -368,19 +229,6 @@
     // respond to the UpdateBackingStoreState message immediately, we'll do a display anyway in
     // sendDidUpdateBackingStoreState; otherwise we shouldn't do one right now.
     m_isWaitingForDidUpdate = false;
-
-    if (respondImmediately) {
-        // Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just
-        // send back an empty UpdateInfo struct.
-        if (m_isPaintingSuspended)
-            resumePainting();
-
-        sendDidUpdateBackingStoreState();
-    }
-
-    m_inUpdateBackingStoreState = false;
-    if (m_forceRepaintAfterBackingStoreStateUpdate)
-        forceRepaint();
 }
 
 void DrawingAreaImpl::sendDidUpdateBackingStoreState()
@@ -388,33 +236,20 @@
     ASSERT(!m_isWaitingForDidUpdate);
     ASSERT(m_shouldSendDidUpdateBackingStoreState);
 
-    m_shouldSendDidUpdateBackingStoreState = false;
-
-    UpdateInfo updateInfo;
-
-    if (!m_isPaintingSuspended && !m_layerTreeHost)
+    if (!m_isPaintingSuspended && !m_layerTreeHost) {
+        UpdateInfo updateInfo;
         display(updateInfo);
+        if (!m_layerTreeHost) {
+            m_shouldSendDidUpdateBackingStoreState = false;
 
-    LayerTreeContext layerTreeContext;
-
-    if (m_isPaintingSuspended || m_layerTreeHost) {
-        updateInfo.viewSize = m_webPage.size();
-        updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
-
-        if (m_layerTreeHost) {
-            layerTreeContext = m_layerTreeHost->layerTreeContext();
-
-            // We don't want the layer tree host to notify after the next scheduled
-            // layer flush because that might end up sending an EnterAcceleratedCompositingMode
-            // message back to the UI process, but the updated layer tree context
-            // will be sent back in the DidUpdateBackingStoreState message.
-            m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
-            m_layerTreeHost->forceRepaint();
+            LayerTreeContext layerTreeContext;
+            m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
+            m_compositingAccordingToProxyMessages = false;
+            return;
         }
     }
 
-    m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
-    m_compositingAccordingToProxyMessages = !layerTreeContext.isEmpty();
+    AcceleratedDrawingArea::sendDidUpdateBackingStoreState();
 }
 
 void DrawingAreaImpl::didUpdate()
@@ -432,51 +267,14 @@
 
 void DrawingAreaImpl::suspendPainting()
 {
-    ASSERT(!m_isPaintingSuspended);
-
-    if (m_layerTreeHost)
-        m_layerTreeHost->pauseRendering();
-
-    m_isPaintingSuspended = true;
+    AcceleratedDrawingArea::suspendPainting();
     m_displayTimer.stop();
 }
 
-void DrawingAreaImpl::resumePainting()
-{
-    if (!m_isPaintingSuspended) {
-        // FIXME: We can get a call to resumePainting when painting is not suspended.
-        // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.
-        return;
-    }
-    
-    if (m_layerTreeHost)
-        m_layerTreeHost->resumeRendering();
-        
-    m_isPaintingSuspended = false;
-
-    // FIXME: We shouldn't always repaint everything here.
-    setNeedsDisplay();
-}
-
 void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
 {
-    m_exitCompositingTimer.stop();
-    m_wantsToExitAcceleratedCompositingMode = false;
+    AcceleratedDrawingArea::enterAcceleratedCompositingMode(graphicsLayer);
 
-    m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID));
-
-    ASSERT(!m_layerTreeHost);
-
-    m_layerTreeHost = LayerTreeHost::create(m_webPage);
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
-    if (m_nativeSurfaceHandleForCompositing)
-        m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
-#endif
-    if (!m_inUpdateBackingStoreState)
-        m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
-
-    m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
-    
     // Non-composited content will now be handled exclusively by the layer tree host.
     m_dirtyRegion = Region();
     m_scrollRect = IntRect();
@@ -528,19 +326,6 @@
     }
 }
 
-void DrawingAreaImpl::exitAcceleratedCompositingModeSoon()
-{
-    if (m_layerTreeStateIsFrozen) {
-        m_wantsToExitAcceleratedCompositingMode = true;
-        return;
-    }
-
-    if (exitAcceleratedCompositingModePending())
-        return;
-
-    m_exitCompositingTimer.startOneShot(0);
-}
-
 void DrawingAreaImpl::scheduleDisplay()
 {
     ASSERT(!m_layerTreeHost);
@@ -681,33 +466,4 @@
     m_displayTimer.stop();
 }
 
-void DrawingAreaImpl::attachViewOverlayGraphicsLayer(WebCore::Frame* frame, WebCore::GraphicsLayer* viewOverlayRootLayer)
-{
-    if (!frame->isMainFrame())
-        return;
-
-    if (!m_layerTreeHost)
-        return;
-
-    m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
-}
-
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
-void DrawingAreaImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)
-{
-    m_nativeSurfaceHandleForCompositing = handle;
-
-    if (m_layerTreeHost) {
-        m_webPage.corePage()->settings().setAcceleratedCompositingEnabled(true);
-        m_layerTreeHost->setNativeSurfaceHandleForCompositing(handle);
-    }
-}
-
-void DrawingAreaImpl::destroyNativeSurfaceHandleForCompositing(bool& handled)
-{
-    handled = true;
-    setNativeSurfaceHandleForCompositing(0);
-}
-#endif
-
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h (202854 => 202855)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h	2016-07-06 09:48:01 UTC (rev 202854)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h	2016-07-06 11:32:07 UTC (rev 202855)
@@ -23,16 +23,13 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DrawingAreaImpl_h
-#define DrawingAreaImpl_h
+#pragma once
 
-#include "DrawingArea.h"
-#include "LayerTreeHost.h"
+#include "AcceleratedDrawingArea.h"
 #include <WebCore/Region.h>
-#include <wtf/RunLoop.h>
 
 namespace WebCore {
-    class GraphicsContext;
+class GraphicsContext;
 }
 
 namespace WebKit {
@@ -40,7 +37,7 @@
 class ShareableBitmap;
 class UpdateInfo;
 
-class DrawingAreaImpl : public DrawingArea {
+class DrawingAreaImpl final : public AcceleratedDrawingArea {
 public:
     DrawingAreaImpl(WebPage&, const WebPageCreationParameters&);
     virtual ~DrawingAreaImpl();
@@ -50,94 +47,42 @@
     void setNeedsDisplay() override;
     void setNeedsDisplayInRect(const WebCore::IntRect&) override;
     void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
-    void pageBackgroundTransparencyChanged() override;
-    void setLayerTreeStateIsFrozen(bool) override;
-    bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }
-    LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); }
     void forceRepaint() override;
-    bool forceRepaintAsync(uint64_t callbackID) override;
 
-    void setPaintingEnabled(bool) override;
     void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
     void updatePreferences(const WebPreferencesStore&) override;
 
-    WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
-    void scheduleCompositingLayerFlush() override;
-    void scheduleCompositingLayerFlushImmediately() override;
 
-    void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
-
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
-    void setNativeSurfaceHandleForCompositing(uint64_t) override;
-    void destroyNativeSurfaceHandleForCompositing(bool&) override;
-#endif
-
-    void layerHostDidFlushLayers() override;
-
     // IPC message handlers.
     void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override;
     void didUpdate() override;
-    virtual void suspendPainting();
-    virtual void resumePainting();
-    
-    void sendDidUpdateBackingStoreState();
 
-    void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
-    void exitAcceleratedCompositingModeSoon();
-    bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
-    void exitAcceleratedCompositingMode();
+    // AcceleratedDrawingArea
+    void suspendPainting() override;
+    void sendDidUpdateBackingStoreState() override;
+    void didUpdateBackingStoreState() override;
 
+    void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*) override;
+    void exitAcceleratedCompositingMode() override;
+
     void scheduleDisplay();
     void displayTimerFired();
     void display();
     void display(UpdateInfo&);
 
-    uint64_t m_backingStoreStateID;
-
     WebCore::Region m_dirtyRegion;
     WebCore::IntRect m_scrollRect;
     WebCore::IntSize m_scrollOffset;
 
-    // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.
-    bool m_isPaintingEnabled;
-
-    // Whether we're currently processing an UpdateBackingStoreState message.
-    bool m_inUpdateBackingStoreState;
-
-    // When true, we should send an UpdateBackingStoreState message instead of any other messages
-    // we normally send to the UI process.
-    bool m_shouldSendDidUpdateBackingStoreState;
-
     // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the 
     // web process won't paint more frequent than the UI process can handle.
-    bool m_isWaitingForDidUpdate;
-    
-    // True between sending the 'enter compositing' messages, and the 'exit compositing' message.
-    bool m_compositingAccordingToProxyMessages;
+    bool m_isWaitingForDidUpdate { false };
 
-    // When true, we maintain the layer tree in its current state by not leaving accelerated compositing mode
-    // and not scheduling layer flushes.
-    bool m_layerTreeStateIsFrozen;
-
-    // True when we were asked to exit accelerated compositing mode but couldn't because layer tree
-    // state was frozen.
-    bool m_wantsToExitAcceleratedCompositingMode;
-
-    // Whether painting is suspended. We'll still keep track of the dirty region but we 
-    // won't paint until painting has resumed again.
-    bool m_isPaintingSuspended;
-    bool m_alwaysUseCompositing;
-
+    bool m_alwaysUseCompositing {false };
     bool m_forceRepaintAfterBackingStoreStateUpdate { false };
 
     RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
-    RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer;
-
-    // The layer tree host that handles accelerated compositing.
-    RefPtr<LayerTreeHost> m_layerTreeHost;
 };
 
 } // namespace WebKit
-
-#endif // DrawingAreaImpl_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to