Changeset 202621 in webkit


Ignore:
Timestamp:
Jun 29, 2016 5:16:41 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

Too much duplicated code in LayerTreeHosts implementations
https://bugs.webkit.org/show_bug.cgi?id=159144

Reviewed by Žan Doberšek.

There's some code common and duplicated in all current LayerTreeHosts implementations (Gtk, Coordinated, and
ThreadedCoordinated). The thing is even worse in the case of ThreadedCoordinated and Coordinated, where the
former is actually a special case of the later, and it seems like code was copy pasted and then modified to add
ThreadedCoordinated specific code. The problem of that approach, apart from the code duplication, is that common
parts end up diverging too. This patch moves the common parts to the base class LayerTreeHost and makes
ThreadedCoordinatedLayerTreeHost inherit from CoordinatedLayerTreeHost, to share the common code and simply add
the specific one.

  • PlatformGTK.cmake:
  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h:
  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:

(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::scheduleLayerFlush):
(WebKit::CoordinatedLayerTreeHost::setViewOverlayRootLayer):
(WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
(WebKit::CoordinatedLayerTreeHost::invalidate):
(WebKit::CoordinatedLayerTreeHost::sizeDidChange):
(WebKit::CoordinatedLayerTreeHost::layerFlushTimerFired):
(WebKit::CoordinatedLayerTreeHost::commitSceneState):
(WebKit::CoordinatedLayerTreeHost::createCoordinatedSurface):
(WebKit::CoordinatedLayerTreeHost::cancelPendingLayerFlush): Deleted.
(WebKit::CoordinatedLayerTreeHost::forceRepaint): Deleted.
(WebKit::CoordinatedLayerTreeHost::forceRepaintAsync): Deleted.
(WebKit::CoordinatedLayerTreeHost::didFlushRootLayer): Deleted.
(WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Deleted.
(WebKit::CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged): Deleted.
(WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory): Deleted.

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
  • WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:

(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost):
(WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange):
(WebKit::ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect):
(WebKit::ThreadedCoordinatedLayerTreeHost::commitSceneState):
(WebKit::ThreadedCoordinatedLayerTreeHost::create): Deleted.
(WebKit::ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents): Deleted.
(WebKit::ThreadedCoordinatedLayerTreeHost::contentsSizeChanged): Deleted.
(WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties): Deleted.
(WebKit::ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged): Deleted.
(WebKit::ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing): Deleted.

  • WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
  • WebProcess/WebPage/DrawingArea.h:

(WebKit::DrawingArea::layerHostDidFlushLayers):

  • WebProcess/WebPage/DrawingAreaImpl.h:
  • WebProcess/WebPage/LayerTreeHost.cpp:

(WebKit::LayerTreeHost::~LayerTreeHost):
(WebKit::LayerTreeHost::setLayerFlushSchedulingEnabled):
(WebKit::LayerTreeHost::pauseRendering):
(WebKit::LayerTreeHost::resumeRendering):
(WebKit::LayerTreeHost::invalidate):

  • WebProcess/WebPage/LayerTreeHost.h:

(WebKit::LayerTreeHost::layerTreeContext):
(WebKit::LayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush):
(WebKit::LayerTreeHost::setNonCompositedContentsNeedDisplay):
(WebKit::LayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
(WebKit::LayerTreeHost::scrollNonCompositedContents):
(WebKit::LayerTreeHost::graphicsLayerFactory):
(WebKit::LayerTreeHost::contentsSizeChanged):
(WebKit::LayerTreeHost::didChangeViewportProperties):
(WebKit::LayerTreeHost::setNativeSurfaceHandleForCompositing):
(WebKit::LayerTreeHost::setViewOverlayRootLayer):
(WebKit::LayerTreeHost::forceRepaintAsync): Deleted.

  • WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:

(WebKit::LayerTreeHostGtk::invalidate):
(WebKit::LayerTreeHostGtk::setViewOverlayRootLayer):
(WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Deleted.
(WebKit::LayerTreeHostGtk::setRootCompositingLayer): Deleted.
(WebKit::LayerTreeHostGtk::setNonCompositedContentsNeedDisplay): Deleted.
(WebKit::LayerTreeHostGtk::scrollNonCompositedContents): Deleted.
(WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Deleted.

  • WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
Location:
trunk/Source/WebKit2
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r202612 r202621  
     12016-06-29  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Too much duplicated code in LayerTreeHosts implementations
     4        https://bugs.webkit.org/show_bug.cgi?id=159144
     5
     6        Reviewed by Žan Doberšek.
     7
     8        There's some code common and duplicated in all current LayerTreeHosts implementations (Gtk, Coordinated, and
     9        ThreadedCoordinated). The thing is even worse in the case of ThreadedCoordinated and Coordinated, where the
     10        former is actually a special case of the later, and it seems like code was copy pasted and then modified to add
     11        ThreadedCoordinated specific code. The problem of that approach, apart from the code duplication, is that common
     12        parts end up diverging too. This patch moves the common parts to the base class LayerTreeHost and makes
     13        ThreadedCoordinatedLayerTreeHost inherit from CoordinatedLayerTreeHost, to share the common code and simply add
     14        the specific one.
     15
     16        * PlatformGTK.cmake:
     17        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h:
     18        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
     19        (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
     20        (WebKit::CoordinatedLayerTreeHost::scheduleLayerFlush):
     21        (WebKit::CoordinatedLayerTreeHost::setViewOverlayRootLayer):
     22        (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
     23        (WebKit::CoordinatedLayerTreeHost::invalidate):
     24        (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
     25        (WebKit::CoordinatedLayerTreeHost::layerFlushTimerFired):
     26        (WebKit::CoordinatedLayerTreeHost::commitSceneState):
     27        (WebKit::CoordinatedLayerTreeHost::createCoordinatedSurface):
     28        (WebKit::CoordinatedLayerTreeHost::cancelPendingLayerFlush): Deleted.
     29        (WebKit::CoordinatedLayerTreeHost::forceRepaint): Deleted.
     30        (WebKit::CoordinatedLayerTreeHost::forceRepaintAsync): Deleted.
     31        (WebKit::CoordinatedLayerTreeHost::didFlushRootLayer): Deleted.
     32        (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Deleted.
     33        (WebKit::CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged): Deleted.
     34        (WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory): Deleted.
     35        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
     36        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
     37        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost):
     38        (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
     39        (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange):
     40        (WebKit::ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect):
     41        (WebKit::ThreadedCoordinatedLayerTreeHost::commitSceneState):
     42        (WebKit::ThreadedCoordinatedLayerTreeHost::create): Deleted.
     43        (WebKit::ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents): Deleted.
     44        (WebKit::ThreadedCoordinatedLayerTreeHost::contentsSizeChanged): Deleted.
     45        (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties): Deleted.
     46        (WebKit::ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged): Deleted.
     47        (WebKit::ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing): Deleted.
     48        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
     49        * WebProcess/WebPage/DrawingArea.h:
     50        (WebKit::DrawingArea::layerHostDidFlushLayers):
     51        * WebProcess/WebPage/DrawingAreaImpl.h:
     52        * WebProcess/WebPage/LayerTreeHost.cpp:
     53        (WebKit::LayerTreeHost::~LayerTreeHost):
     54        (WebKit::LayerTreeHost::setLayerFlushSchedulingEnabled):
     55        (WebKit::LayerTreeHost::pauseRendering):
     56        (WebKit::LayerTreeHost::resumeRendering):
     57        (WebKit::LayerTreeHost::invalidate):
     58        * WebProcess/WebPage/LayerTreeHost.h:
     59        (WebKit::LayerTreeHost::layerTreeContext):
     60        (WebKit::LayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush):
     61        (WebKit::LayerTreeHost::setNonCompositedContentsNeedDisplay):
     62        (WebKit::LayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
     63        (WebKit::LayerTreeHost::scrollNonCompositedContents):
     64        (WebKit::LayerTreeHost::graphicsLayerFactory):
     65        (WebKit::LayerTreeHost::contentsSizeChanged):
     66        (WebKit::LayerTreeHost::didChangeViewportProperties):
     67        (WebKit::LayerTreeHost::setNativeSurfaceHandleForCompositing):
     68        (WebKit::LayerTreeHost::setViewOverlayRootLayer):
     69        (WebKit::LayerTreeHost::forceRepaintAsync): Deleted.
     70        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
     71        (WebKit::LayerTreeHostGtk::invalidate):
     72        (WebKit::LayerTreeHostGtk::setViewOverlayRootLayer):
     73        (WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Deleted.
     74        (WebKit::LayerTreeHostGtk::setRootCompositingLayer): Deleted.
     75        (WebKit::LayerTreeHostGtk::setNonCompositedContentsNeedDisplay): Deleted.
     76        (WebKit::LayerTreeHostGtk::scrollNonCompositedContents): Deleted.
     77        (WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Deleted.
     78        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
     79
    1802016-06-28  Commit Queue  <commit-queue@webkit.org>
    281
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r200621 r202621  
    827827        Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
    828828
     829        WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
    829830        WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
    830831    )
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp

    r202611 r202621  
    349349        return;
    350350
    351     CoordinatedLayerTreeHost* coordinatedLayerTreeHost = static_cast<CoordinatedLayerTreeHost*>(m_layerTreeHost.get());
    352     coordinatedLayerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
     351    m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
    353352}
    354353
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h

    r202611 r202621  
    4242    virtual ~CoordinatedDrawingArea();
    4343
    44     void layerHostDidFlushLayers();
    45 
    4644private:
    4745    // DrawingArea
     
    6967    void viewStateDidChange(WebCore::ViewState::Flags, bool /* wantsDidUpdateViewState */, const Vector<uint64_t>& /* callbackIDs */) override;
    7068    void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
     69
     70    void layerHostDidFlushLayers() override;
    7171
    7272    // IPC message handlers.
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

    r201802 r202621  
    3131#include "CoordinatedLayerTreeHost.h"
    3232
    33 #include "CoordinatedDrawingArea.h"
    34 #include "CoordinatedGraphicsArgumentCoders.h"
    35 #include "CoordinatedLayerTreeHostProxyMessages.h"
    36 #include "GraphicsContext.h"
     33#include "DrawingArea.h"
    3734#include "WebCoordinatedSurface.h"
    38 #include "WebCoreArgumentCoders.h"
    3935#include "WebPage.h"
    4036#include "WebPageProxyMessages.h"
    41 #include <WebCore/Frame.h>
    4237#include <WebCore/FrameView.h>
    4338#include <WebCore/MainFrame.h>
    4439#include <WebCore/PageOverlayController.h>
    45 #include <WebCore/Settings.h>
    46 #include <wtf/CurrentTime.h>
     40
     41#if USE(COORDINATED_GRAPHICS_THREADED)
     42#include "ThreadSafeCoordinatedSurface.h"
     43#elif USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     44#include "CoordinatedGraphicsArgumentCoders.h"
     45#include "CoordinatedLayerTreeHostProxyMessages.h"
     46#include "WebCoreArgumentCoders.h"
     47#endif
    4748
    4849using namespace WebCore;
     
    6162CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage& webPage)
    6263    : LayerTreeHost(webPage)
    63     , m_notifyAfterScheduledLayerFlush(false)
    64     , m_isValid(true)
    65     , m_isSuspended(false)
    66     , m_isWaitingForRenderer(true)
    67     , m_layerFlushTimer(*this, &CoordinatedLayerTreeHost::layerFlushTimerFired)
    68     , m_layerFlushSchedulingEnabled(true)
    69     , m_forceRepaintAsyncCallbackID(0)
    70     , m_viewOverlayRootLayer(nullptr)
    71 {
    72     m_coordinator = std::make_unique<CompositingCoordinator>(m_webPage.corePage(), this);
    73 
     64    , m_coordinator(std::make_unique<CompositingCoordinator>(webPage.corePage(), this))
     65    , m_layerFlushTimer(RunLoop::main(), this, &CoordinatedLayerTreeHost::layerFlushTimerFired)
     66{
    7467    m_coordinator->createRootLayer(m_webPage.size());
     68#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
    7569    m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id();
     70#endif
    7671
    7772    CoordinatedSurface::setFactory(createCoordinatedSurface);
    78 
    79     scheduleLayerFlush();
    80 }
    81 
    82 void CoordinatedLayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
    83 {
    84     if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
    85         return;
    86 
    87     m_layerFlushSchedulingEnabled = layerFlushingEnabled;
    88 
    89     if (m_layerFlushSchedulingEnabled) {
    90         scheduleLayerFlush();
    91         return;
    92     }
    93 
     73    scheduleLayerFlush();
     74}
     75
     76void CoordinatedLayerTreeHost::scheduleLayerFlush()
     77{
     78    if (!m_layerFlushSchedulingEnabled)
     79        return;
     80
     81    if (!m_layerFlushTimer.isActive())
     82        m_layerFlushTimer.startOneShot(0);
     83}
     84
     85void CoordinatedLayerTreeHost::cancelPendingLayerFlush()
     86{
     87    m_layerFlushTimer.stop();
     88}
     89
     90void CoordinatedLayerTreeHost::setViewOverlayRootLayer(GraphicsLayer* viewOverlayRootLayer)
     91{
     92    LayerTreeHost::setViewOverlayRootLayer(viewOverlayRootLayer);
     93    m_coordinator->setViewOverlayRootLayer(viewOverlayRootLayer);
     94}
     95
     96void CoordinatedLayerTreeHost::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
     97{
     98    m_coordinator->setRootCompositingLayer(graphicsLayer);
     99}
     100
     101void CoordinatedLayerTreeHost::invalidate()
     102{
    94103    cancelPendingLayerFlush();
    95 }
    96 
    97 void CoordinatedLayerTreeHost::scheduleLayerFlush()
    98 {
    99     if (!m_layerFlushSchedulingEnabled)
    100         return;
    101 
    102     if (!m_layerFlushTimer.isActive() || m_layerFlushTimer.nextFireInterval() > 0)
    103         m_layerFlushTimer.startOneShot(0);
    104 }
    105 
    106 void CoordinatedLayerTreeHost::cancelPendingLayerFlush()
    107 {
    108     m_layerFlushTimer.stop();
    109 }
    110 
    111 void CoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush)
    112 {
    113     m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush;
    114 }
    115 
    116 void CoordinatedLayerTreeHost::setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverlayRootLayer)
    117 {
    118     m_viewOverlayRootLayer = viewOverlayRootLayer;
    119     m_coordinator->setViewOverlayRootLayer(viewOverlayRootLayer);
    120 }
    121 
    122 void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
    123 {
    124     m_coordinator->setRootCompositingLayer(graphicsLayer);
    125 }
    126 
    127 void CoordinatedLayerTreeHost::invalidate()
    128 {
    129     cancelPendingLayerFlush();
    130 
    131     ASSERT(m_isValid);
     104
    132105    m_coordinator->clearRootLayer();
    133     m_isValid = false;
     106    LayerTreeHost::invalidate();
    134107}
    135108
     
    159132}
    160133
    161 void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)
     134void CoordinatedLayerTreeHost::sizeDidChange(const IntSize& newSize)
    162135{
    163136    m_coordinator->sizeDidChange(newSize);
     
    190163}
    191164
    192 void CoordinatedLayerTreeHost::performScheduledLayerFlush()
     165void CoordinatedLayerTreeHost::layerFlushTimerFired()
    193166{
    194167    if (m_isSuspended || m_isWaitingForRenderer)
     
    208181
    209182    if (m_notifyAfterScheduledLayerFlush && didSync) {
    210         static_cast<CoordinatedDrawingArea*>(m_webPage.drawingArea())->layerHostDidFlushLayers();
     183        m_webPage.drawingArea()->layerHostDidFlushLayers();
    211184        m_notifyAfterScheduledLayerFlush = false;
    212185    }
    213186}
    214187
    215 void CoordinatedLayerTreeHost::layerFlushTimerFired()
    216 {
    217     performScheduledLayerFlush();
    218 }
    219 
    220188void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect&)
    221189{
    222190}
    223191
    224 void CoordinatedLayerTreeHost::commitSceneState(const WebCore::CoordinatedGraphicsState& state)
    225 {
     192void CoordinatedLayerTreeHost::commitSceneState(const CoordinatedGraphicsState& state)
     193{
     194#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
    226195    m_webPage.send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state));
     196#endif
    227197    m_isWaitingForRenderer = true;
    228198}
     
    230200RefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags)
    231201{
     202#if USE(COORDINATED_GRAPHICS_THREADED)
     203    return ThreadSafeCoordinatedSurface::create(size, flags);
     204#elif USE(COORDINATED_GRAPHICS_MULTIPROCESS)
    232205    return WebCoordinatedSurface::create(size, flags);
     206#else
     207    UNUSED_PARAM(size);
     208    UNUSED_PARAM(flags);
     209    return nullptr;
     210#endif
    233211}
    234212
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

    r201802 r202621  
    2424#if USE(COORDINATED_GRAPHICS)
    2525
    26 #include "LayerTreeContext.h"
    2726#include "LayerTreeHost.h"
    2827#include <WebCore/CompositingCoordinator.h>
    29 #include <WebCore/GraphicsLayerFactory.h>
    30 #include <wtf/HashSet.h>
     28#include <wtf/RunLoop.h>
    3129
    3230namespace WebCore {
    3331class CoordinatedSurface;
     32class GraphicsLayerFactory;
    3433}
    3534
     
    4443    virtual ~CoordinatedLayerTreeHost();
    4544
    46     const LayerTreeContext& layerTreeContext() override { return m_layerTreeContext; }
    47     void setLayerFlushSchedulingEnabled(bool) override;
     45protected:
     46    explicit CoordinatedLayerTreeHost(WebPage&);
     47
    4848    void scheduleLayerFlush() override;
    49     void setShouldNotifyAfterNextScheduledLayerFlush(bool) override;
     49    void cancelPendingLayerFlush() override;
    5050    void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
    5151    void invalidate() override;
    5252
    53     void setNonCompositedContentsNeedDisplay() override { }
    54     void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override { }
    55     void scrollNonCompositedContents(const WebCore::IntRect&) override { }
    5653    void forceRepaint() override;
    5754    bool forceRepaintAsync(uint64_t callbackID) override;
    5855    void sizeDidChange(const WebCore::IntSize& newSize) override;
    5956
    60     void pauseRendering() override { m_isSuspended = true; }
    61     void resumeRendering() override { m_isSuspended = false; scheduleLayerFlush(); }
    6257    void deviceOrPageScaleFactorChanged() override;
    6358    void pageBackgroundTransparencyChanged() override;
    6459
    65     void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override;
     60    void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
     61    void renderNextFrame();
     62    void purgeBackingStores();
     63    void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
     64
    6665    WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
    67     WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
    6866
    6967#if ENABLE(REQUEST_ANIMATION_FRAME)
     
    7371    void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
    7472
    75     static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
    76 
    77 protected:
    78     explicit CoordinatedLayerTreeHost(WebPage&);
    79 
    80 private:
    81     // CoordinatedLayerTreeHost
    82     void cancelPendingLayerFlush();
    83     void performScheduledLayerFlush();
    84     void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
    85     void renderNextFrame();
    86     void purgeBackingStores();
    87     void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
    88 
    89     void layerFlushTimerFired();
    90 
    9173    // CompositingCoordinator::Client
    9274    void didFlushRootLayer(const WebCore::FloatRect& visibleContentRect) override;
     
    9577    void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) override;
    9678
     79private:
     80    void layerFlushTimerFired();
     81
     82#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     83    void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override;
     84#endif
     85
     86    static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
     87
    9788    std::unique_ptr<WebCore::CompositingCoordinator> m_coordinator;
    98 
    99     bool m_notifyAfterScheduledLayerFlush;
    100     bool m_isValid;
    101     bool m_isSuspended;
    102     bool m_isWaitingForRenderer;
    103 
    104     LayerTreeContext m_layerTreeContext;
    105 
    106     WebCore::Timer m_layerFlushTimer;
    107     bool m_layerFlushSchedulingEnabled;
    108     uint64_t m_forceRepaintAsyncCallbackID;
    109 
    110     WebCore::GraphicsLayer* m_viewOverlayRootLayer;
     89    bool m_isWaitingForRenderer { true };
     90    uint64_t m_forceRepaintAsyncCallbackID { 0 };
     91    RunLoop::Timer<CoordinatedLayerTreeHost> m_layerFlushTimer;
    11192};
    11293
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp

    r202611 r202621  
    3131
    3232#if USE(COORDINATED_GRAPHICS_THREADED)
    33 
    34 #include "DrawingAreaImpl.h"
    35 #include "NotImplemented.h"
    36 #include "ThreadSafeCoordinatedSurface.h"
    3733#include "WebPage.h"
    38 #include <WebCore/CoordinatedGraphicsLayer.h>
    39 #include <WebCore/CoordinatedGraphicsState.h>
    40 #include <WebCore/Frame.h>
    4134#include <WebCore/FrameView.h>
    42 #include <WebCore/GraphicsContext.h>
    4335#include <WebCore/MainFrame.h>
    44 #include <WebCore/Page.h>
    45 #include <wtf/CurrentTime.h>
    4636
    4737using namespace WebCore;
     
    5949
    6050ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webPage)
    61     : LayerTreeHost(webPage)
    62     , m_forceRepaintAsyncCallbackID(0)
    63     , m_notifyAfterScheduledLayerFlush(false)
    64     , m_isSuspended(false)
    65     , m_isWaitingForRenderer(false)
    66     , m_layerFlushTimer(RunLoop::main(), this, &ThreadedCoordinatedLayerTreeHost::performScheduledLayerFlush)
    67     , m_layerFlushSchedulingEnabled(true)
     51    : CoordinatedLayerTreeHost(webPage)
     52    , m_compositorClient(*this)
     53    , m_compositor(ThreadedCompositor::create(&m_compositorClient))
    6854{
    69     m_coordinator = std::make_unique<CompositingCoordinator>(m_webPage.corePage(), this);
    70 
    71     m_coordinator->createRootLayer(m_webPage.size());
    72 
    73     CoordinatedSurface::setFactory(createCoordinatedSurface);
    74 
    75     m_compositor = ThreadedCompositor::create(this);
    76     scheduleLayerFlush();
    77 }
    78 
    79 RefPtr<CoordinatedSurface> ThreadedCoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags)
    80 {
    81     return ThreadSafeCoordinatedSurface::create(size, flags);
    82 }
    83 
    84 void ThreadedCoordinatedLayerTreeHost::scheduleLayerFlush()
    85 {
    86     if (!m_layerFlushSchedulingEnabled)
    87         return;
    88 
    89     if (!m_layerFlushTimer.isActive())
    90         m_layerFlushTimer.startOneShot(0);
    91 }
    92 
    93 void ThreadedCoordinatedLayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
    94 {
    95     if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
    96         return;
    97 
    98     m_layerFlushSchedulingEnabled = layerFlushingEnabled;
    99 
    100     if (m_layerFlushSchedulingEnabled) {
    101         scheduleLayerFlush();
    102         return;
    103     }
    104 
    105     cancelPendingLayerFlush();
    106 }
    107 
    108 void ThreadedCoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush)
    109 {
    110     m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush;
    111 }
    112 
    113 void ThreadedCoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
    114 {
    115     m_coordinator->setRootCompositingLayer(graphicsLayer);
    116 }
    117 
    118 void ThreadedCoordinatedLayerTreeHost::invalidate()
    119 {
    120     notImplemented();
    12155}
    12256
     
    12559    m_compositor->scrollTo(rect.location());
    12660    scheduleLayerFlush();
    127 }
    128 
    129 void ThreadedCoordinatedLayerTreeHost::forceRepaint()
    130 {
    131     notImplemented();
    132 }
    133 
    134 bool ThreadedCoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
    135 {
    136     // We expect the UI process to not require a new repaint until the previous one has finished.
    137     ASSERT(!m_forceRepaintAsyncCallbackID);
    138     m_forceRepaintAsyncCallbackID = callbackID;
    139     scheduleLayerFlush();
    140     return true;
    14161}
    14262
     
    14868void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
    14969{
    150     m_coordinator->deviceOrPageScaleFactorChanged();
     70    CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged();
    15171    m_compositor->setDeviceScaleFactor(m_webPage.deviceScaleFactor());
    15272}
    15373
    154 void ThreadedCoordinatedLayerTreeHost::pauseRendering()
     74void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
    15575{
    156     m_isSuspended = true;
    157 }
    158 
    159 void ThreadedCoordinatedLayerTreeHost::resumeRendering()
    160 {
    161     m_isSuspended = false;
    162     scheduleLayerFlush();
    163 }
    164 
    165 GraphicsLayerFactory* ThreadedCoordinatedLayerTreeHost::graphicsLayerFactory()
    166 {
    167     return m_coordinator.get();
    168 }
    169 
    170 void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& size)
    171 {
    172     m_coordinator->sizeDidChange(size);
     76    CoordinatedLayerTreeHost::sizeDidChange(size);
    17377    m_compositor->didChangeViewportSize(size);
    17478}
     
    17983}
    18084
    181 void ThreadedCoordinatedLayerTreeHost::compositorDidFlushLayers()
    182 {
    183     static_cast<DrawingAreaImpl*>(m_webPage.drawingArea())->layerHostDidFlushLayers();
    184 }
    185 
    18685void ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged(float scale, const IntPoint& origin)
    18786{
    18887    m_webPage.scalePage(scale, origin);
    189 }
    190 
    191 void ThreadedCoordinatedLayerTreeHost::setViewOverlayRootLayer(GraphicsLayer* graphicsLayer)
    192 {
    193     m_coordinator->setViewOverlayRootLayer(graphicsLayer);
    19488}
    19589
     
    20397#endif
    20498
    205 #if ENABLE(REQUEST_ANIMATION_FRAME)
    206 void ThreadedCoordinatedLayerTreeHost::scheduleAnimation()
    207 {
    208     if (m_isWaitingForRenderer)
    209         return;
    210 
    211     if (m_layerFlushTimer.isActive())
    212         return;
    213 
    214     m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime());
    215     scheduleLayerFlush();
    216 }
    217 #endif
    218 
    21999void ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector, float scale)
    220100{
    221     m_coordinator->setVisibleContentsRect(rect, trajectoryVector);
     101    CoordinatedLayerTreeHost::setVisibleContentsRect(rect, trajectoryVector);
    222102    if (m_lastScrollPosition != roundedIntPoint(rect.location())) {
    223103        m_lastScrollPosition = roundedIntPoint(rect.location());
     
    231111        didScaleFactorChanged(m_lastScaleFactor, m_lastScrollPosition);
    232112    }
    233 
    234     scheduleLayerFlush();
    235 }
    236 
    237 void ThreadedCoordinatedLayerTreeHost::cancelPendingLayerFlush()
    238 {
    239     m_layerFlushTimer.stop();
    240 }
    241 
    242 void ThreadedCoordinatedLayerTreeHost::performScheduledLayerFlush()
    243 {
    244     if (m_isSuspended || m_isWaitingForRenderer)
    245         return;
    246 
    247     m_coordinator->syncDisplayState();
    248     bool didSync = m_coordinator->flushPendingLayerChanges();
    249 
    250     if (m_notifyAfterScheduledLayerFlush && didSync) {
    251         compositorDidFlushLayers();
    252         m_notifyAfterScheduledLayerFlush = false;
    253     }
    254 }
    255 
    256 void ThreadedCoordinatedLayerTreeHost::purgeBackingStores()
    257 {
    258     m_coordinator->purgeBackingStores();
    259 }
    260 
    261 void ThreadedCoordinatedLayerTreeHost::renderNextFrame()
    262 {
    263     m_isWaitingForRenderer = false;
    264     m_coordinator->renderNextFrame();
    265     scheduleLayerFlush();
    266 }
    267 
    268 void ThreadedCoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const IntSize& offset)
    269 {
    270     m_coordinator->commitScrollOffset(layerID, offset);
    271 }
    272 
    273 void ThreadedCoordinatedLayerTreeHost::notifyFlushRequired()
    274 {
    275     scheduleLayerFlush();
    276113}
    277114
    278115void ThreadedCoordinatedLayerTreeHost::commitSceneState(const CoordinatedGraphicsState& state)
    279116{
    280     m_isWaitingForRenderer = true;
     117    CoordinatedLayerTreeHost::commitSceneState(state);
    281118    m_compositor->updateSceneState(state);
    282 }
    283 
    284 void ThreadedCoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect&)
    285 {
    286119}
    287120
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h

    r202611 r202621  
    3131#if USE(COORDINATED_GRAPHICS_THREADED)
    3232
    33 #include "LayerTreeContext.h"
    34 #include "LayerTreeHost.h"
     33#include "CoordinatedLayerTreeHost.h"
    3534#include "ThreadedCompositor.h"
    36 #include <WebCore/CompositingCoordinator.h>
    37 #include <WebCore/FloatPoint.h>
    38 #include <WebCore/FloatRect.h>
    39 #include <WebCore/IntPoint.h>
    40 #include <WebCore/IntRect.h>
    41 #include <WebCore/IntSize.h>
    42 #include <WebCore/PageOverlay.h>
    43 #include <WebCore/Timer.h>
    44 #include <wtf/RunLoop.h>
    45 #include <wtf/Threading.h>
    4635
    4736namespace WebCore {
    48 class CoordinatedSurface;
    4937class GraphicsContext;
    5038class GraphicsLayer;
    51 class GraphicsLayerFactory;
    52 class GraphicsLayerFactory;
    53 struct CoordinatedGraphicsLayerState;
    5439struct CoordinatedGraphicsState;
    5540}
     
    5944class WebPage;
    6045
    61 class ThreadedCoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::CompositingCoordinator::Client, public ThreadedCompositor::Client {
    62     WTF_MAKE_NONCOPYABLE(ThreadedCoordinatedLayerTreeHost); WTF_MAKE_FAST_ALLOCATED;
     46class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost {
    6347public:
    6448    static Ref<ThreadedCoordinatedLayerTreeHost> create(WebPage&);
    6549    virtual ~ThreadedCoordinatedLayerTreeHost();
    6650
    67     const LayerTreeContext& layerTreeContext() override { return m_layerTreeContext; };
     51private:
     52    explicit ThreadedCoordinatedLayerTreeHost(WebPage&);
    6853
    69     void scheduleLayerFlush() override;
    70     void setLayerFlushSchedulingEnabled(bool) override;
    71     void setShouldNotifyAfterNextScheduledLayerFlush(bool) override;
    72     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
    73     void invalidate() override;
    74 
    75     void setNonCompositedContentsNeedDisplay() override { };
    76     void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override { };
    7754    void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;
    78     void forceRepaint() override;
    79     bool forceRepaintAsync(uint64_t /*callbackID*/) override;
    8055    void sizeDidChange(const WebCore::IntSize&) override;
    8156    void deviceOrPageScaleFactorChanged() override;
    82 
    83     void pauseRendering() override;
    84     void resumeRendering() override;
    85 
    86     WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
    87     void pageBackgroundTransparencyChanged() override { };
    8857
    8958    void contentsSizeChanged(const WebCore::IntSize&) override;
     
    9463#endif
    9564
    96 #if ENABLE(REQUEST_ANIMATION_FRAME)
    97     void scheduleAnimation() override;
    98 #endif
     65    class CompositorClient final : public ThreadedCompositor::Client {
     66        WTF_MAKE_NONCOPYABLE(CompositorClient);
     67    public:
     68        CompositorClient(ThreadedCoordinatedLayerTreeHost& layerTreeHost)
     69            : m_layerTreeHost(layerTreeHost)
     70        {
     71        }
    9972
    100     void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
    101     static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
     73    private:
     74        void setVisibleContentsRect(const WebCore::FloatRect& rect, const WebCore::FloatPoint& trajectoryVector, float scale) override
     75        {
     76            m_layerTreeHost.setVisibleContentsRect(rect, trajectoryVector, scale);
     77        }
    10278
    103 protected:
    104     explicit ThreadedCoordinatedLayerTreeHost(WebPage&);
     79        void purgeBackingStores() override
     80        {
     81            m_layerTreeHost.purgeBackingStores();
     82        }
    10583
    106 private:
     84        void renderNextFrame() override
     85        {
     86            m_layerTreeHost.renderNextFrame();
     87        }
    10788
    108     void compositorDidFlushLayers();
     89        void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override
     90        {
     91            m_layerTreeHost.commitScrollOffset(layerID, offset);
     92        }
     93
     94        ThreadedCoordinatedLayerTreeHost& m_layerTreeHost;
     95    };
     96
    10997    void didScaleFactorChanged(float scale, const WebCore::IntPoint& origin);
    11098
    111     void cancelPendingLayerFlush();
    112     void performScheduledLayerFlush();
    113 
    114     WebCore::GraphicsLayer* rootLayer() { return m_coordinator->rootLayer(); }
    115 
    116     // ThreadedCompositor::Client
    117     void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float) override;
    118     void purgeBackingStores() override;
    119     void renderNextFrame() override;
    120     void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override;
     99    void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float);
    121100
    122101    // CompositingCoordinator::Client
    123102    void didFlushRootLayer(const WebCore::FloatRect&) override { }
    124     void notifyFlushRequired() override;
    125103    void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
    126     void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) override;
    127 
    128     LayerTreeContext m_layerTreeContext;
    129     uint64_t m_forceRepaintAsyncCallbackID;
    130104
    131105    WebCore::IntPoint m_prevScrollPosition;
    132 
    133     std::unique_ptr<WebCore::CompositingCoordinator> m_coordinator;
     106    CompositorClient m_compositorClient;
    134107    RefPtr<ThreadedCompositor> m_compositor;
    135 
    136     bool m_notifyAfterScheduledLayerFlush;
    137     bool m_isSuspended;
    138     bool m_isWaitingForRenderer;
    139 
    140     float m_lastScaleFactor;
     108    float m_lastScaleFactor { 1 };
    141109    WebCore::IntPoint m_lastScrollPosition;
    142 
    143     RunLoop::Timer<ThreadedCoordinatedLayerTreeHost> m_layerFlushTimer;
    144     bool m_layerFlushSchedulingEnabled;
    145110};
    146111
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h

    r201441 r202621  
    139139#endif
    140140
     141    virtual void layerHostDidFlushLayers() { };
     142
    141143protected:
    142144    DrawingArea(DrawingAreaType, WebPage&);
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h

    r202611 r202621  
    4646    virtual ~DrawingAreaImpl();
    4747
    48     void layerHostDidFlushLayers();
    49 
    5048private:
    5149    // DrawingArea
     
    7573    void destroyNativeSurfaceHandleForCompositing(bool&) override;
    7674#endif
     75
     76    void layerHostDidFlushLayers() override;
    7777
    7878    // IPC message handlers.
  • trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp

    r201802 r202621  
    6363LayerTreeHost::~LayerTreeHost()
    6464{
     65    ASSERT(!m_isValid);
     66}
     67
     68void LayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
     69{
     70    if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
     71        return;
     72
     73    m_layerFlushSchedulingEnabled = layerFlushingEnabled;
     74
     75    if (m_layerFlushSchedulingEnabled) {
     76        scheduleLayerFlush();
     77        return;
     78    }
     79
     80    cancelPendingLayerFlush();
     81}
     82
     83void LayerTreeHost::pauseRendering()
     84{
     85    m_isSuspended = true;
     86}
     87
     88void LayerTreeHost::resumeRendering()
     89{
     90    m_isSuspended = false;
     91    scheduleLayerFlush();
     92}
     93
     94void LayerTreeHost::invalidate()
     95{
     96    ASSERT(m_isValid);
     97    m_isValid = false;
    6598}
    6699
  • trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h

    r201923 r202621  
    3030
    3131#include "LayerTreeContext.h"
    32 #include <WebCore/Color.h>
    33 #include <wtf/PassRefPtr.h>
     32#include <wtf/Forward.h>
    3433#include <wtf/RefCounted.h>
    3534
     
    4039
    4140namespace WebCore {
    42 class FloatPoint;
    43 class FloatRect;
    4441class IntRect;
    4542class IntSize;
     
    5350namespace WebKit {
    5451
    55 class UpdateInfo;
    5652class WebPage;
    5753
     
    6157    virtual ~LayerTreeHost();
    6258
    63     virtual const LayerTreeContext& layerTreeContext() = 0;
     59    const LayerTreeContext& layerTreeContext() const { return m_layerTreeContext; }
     60    void setLayerFlushSchedulingEnabled(bool);
     61    void setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) { m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush; }
     62
    6463    virtual void scheduleLayerFlush() = 0;
    65     virtual void setLayerFlushSchedulingEnabled(bool) = 0;
    66     virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool) = 0;
     64    virtual void cancelPendingLayerFlush() = 0;
    6765    virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
    68     virtual void invalidate() = 0;
     66    virtual void invalidate();
    6967
    70     virtual void setNonCompositedContentsNeedDisplay() = 0;
    71     virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) = 0;
    72     virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) = 0;
     68    virtual void setNonCompositedContentsNeedDisplay() { };
     69    virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) { };
     70    virtual void scrollNonCompositedContents(const WebCore::IntRect&) { };
    7371    virtual void forceRepaint() = 0;
    7472    virtual bool forceRepaintAsync(uint64_t /*callbackID*/) { return false; }
     
    7775    virtual void pageBackgroundTransparencyChanged() = 0;
    7876
    79     virtual void pauseRendering() { }
    80     virtual void resumeRendering() { }
     77    virtual void pauseRendering();
     78    virtual void resumeRendering();
    8179
    82     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return 0; }
     80    virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return nullptr; }
    8381
    8482#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     
    8785
    8886#if USE(COORDINATED_GRAPHICS_THREADED)
    89     virtual void contentsSizeChanged(const WebCore::IntSize&) = 0;
    90     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) = 0;
     87    virtual void contentsSizeChanged(const WebCore::IntSize&) { };
     88    virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) { };
    9189#endif
    9290
     
    9694
    9795#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
    98     virtual void setNativeSurfaceHandleForCompositing(uint64_t) = 0;
     96    virtual void setNativeSurfaceHandleForCompositing(uint64_t) { };
    9997#endif
    10098
    101     virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer*) = 0;
     99    virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverlayRootLayer) { m_viewOverlayRootLayer = viewOverlayRootLayer; }
    102100
    103101protected:
     
    105103
    106104    WebPage& m_webPage;
     105    LayerTreeContext m_layerTreeContext;
     106    bool m_layerFlushSchedulingEnabled { true };
     107    bool m_notifyAfterScheduledLayerFlush { false };
     108    bool m_isSuspended { false };
     109    bool m_isValid { true };
     110    WebCore::GraphicsLayer* m_viewOverlayRootLayer { nullptr };
    107111};
    108112
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp

    r202611 r202621  
    134134LayerTreeHostGtk::LayerTreeHostGtk(WebPage& webPage)
    135135    : LayerTreeHost(webPage)
    136     , m_isValid(true)
    137     , m_notifyAfterScheduledLayerFlush(false)
    138     , m_layerFlushSchedulingEnabled(true)
    139     , m_viewOverlayRootLayer(nullptr)
    140136    , m_renderFrameScheduler(std::bind(&LayerTreeHostGtk::renderFrame, this))
    141137{
     
    184180LayerTreeHostGtk::~LayerTreeHostGtk()
    185181{
    186     ASSERT(!m_isValid);
    187182    ASSERT(!m_rootLayer);
    188183    cancelPendingLayerFlush();
    189 }
    190 
    191 const LayerTreeContext& LayerTreeHostGtk::layerTreeContext()
    192 {
    193     return m_layerTreeContext;
    194 }
    195 
    196 void LayerTreeHostGtk::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush)
    197 {
    198     m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush;
    199184}
    200185
     
    212197void LayerTreeHostGtk::invalidate()
    213198{
    214     ASSERT(m_isValid);
    215 
    216199    // This can trigger destruction of GL objects so let's make sure that
    217200    // we have the right active context
     
    225208
    226209    m_context = nullptr;
    227     m_isValid = false;
     210    LayerTreeHost::invalidate();
    228211}
    229212
     
    366349    if (m_notifyAfterScheduledLayerFlush) {
    367350        // Let the drawing area know that we've done a flush of the layer changes.
    368         static_cast<DrawingAreaImpl*>(m_webPage.drawingArea())->layerHostDidFlushLayers();
     351        m_webPage.drawingArea()->layerHostDidFlushLayers();
    369352        m_notifyAfterScheduledLayerFlush = false;
    370353    }
     
    379362}
    380363
    381 void LayerTreeHostGtk::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
    382 {
    383     if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
    384         return;
    385 
    386     m_layerFlushSchedulingEnabled = layerFlushingEnabled;
    387 
    388     if (m_layerFlushSchedulingEnabled) {
    389         scheduleLayerFlush();
    390         return;
    391     }
    392 
    393     cancelPendingLayerFlush();
    394 }
    395 
    396364void LayerTreeHostGtk::pageBackgroundTransparencyChanged()
    397365{
     
    404372}
    405373
    406 void LayerTreeHostGtk::setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverlayRootLayer)
    407 {
    408     m_viewOverlayRootLayer = viewOverlayRootLayer;
     374void LayerTreeHostGtk::setViewOverlayRootLayer(GraphicsLayer* viewOverlayRootLayer)
     375{
     376    LayerTreeHost::setViewOverlayRootLayer(viewOverlayRootLayer);
    409377    if (m_viewOverlayRootLayer)
    410378        m_rootLayer->addChild(m_viewOverlayRootLayer);
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h

    r202611 r202621  
    5252    // LayerTreeHost
    5353    void scheduleLayerFlush() override;
    54     void setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) override;
     54    void cancelPendingLayerFlush() override;
    5555    void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
    5656    void invalidate() override;
     
    6060    void deviceOrPageScaleFactorChanged() override;
    6161    void pageBackgroundTransparencyChanged() override;
     62
     63    void setNonCompositedContentsNeedDisplay() override;
     64    void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override;
     65    void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;
     66    void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
    6267
    6368    void setNativeSurfaceHandleForCompositing(uint64_t) override;
     
    8186    };
    8287
    83     // LayerTreeHost
    84     const LayerTreeContext& layerTreeContext() override;
    85     void setShouldNotifyAfterNextScheduledLayerFlush(bool) override;
    86 
    87     void setNonCompositedContentsNeedDisplay() override;
    88     void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override;
    89     void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;
    90     void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
    91 
    9288    // GraphicsLayerClient
    9389    void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect) override;
     
    10197
    10298    void flushAndRenderLayers();
    103     void cancelPendingLayerFlush();
    104 
    10599    bool renderFrame();
    106 
    107100    bool makeContextCurrent();
    108101
    109     LayerTreeContext m_layerTreeContext;
    110     bool m_isValid;
    111     bool m_notifyAfterScheduledLayerFlush;
    112102    std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
    113103    std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
    114104    std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
    115105    std::unique_ptr<WebCore::GLContext> m_context;
    116     bool m_layerFlushSchedulingEnabled;
    117     WebCore::GraphicsLayer* m_viewOverlayRootLayer;
    118106    WebCore::TransformationMatrix m_scaleMatrix;
    119107    RenderFrameScheduler m_renderFrameScheduler;
Note: See TracChangeset for help on using the changeset viewer.