⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242199 in webkit


Ignore:
Timestamp:
Feb 28, 2019, 5:17:41 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[CoordinatedGraphics] Unify all LayerTreeHost classes
https://bugs.webkit.org/show_bug.cgi?id=195094

Reviewed by Žan Doberšek.

There's no reason to have 3 classes, since currently LayerTreeHost is only used by coordinated graphics based
ports.

  • PlatformWin.cmake:
  • SourcesGTK.txt:
  • SourcesWPE.txt:
  • WebProcess/WebPage/AcceleratedDrawingArea.cpp:

(WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode):
(WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModeNow):

  • WebProcess/WebPage/AcceleratedDrawingArea.h:
  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: Removed.
  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h: Removed.
  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp.

(WebKit::LayerTreeHost::LayerTreeHost):
(WebKit::LayerTreeHost::~LayerTreeHost):
(WebKit::LayerTreeHost::setLayerFlushSchedulingEnabled):
(WebKit::LayerTreeHost::scheduleLayerFlush):
(WebKit::LayerTreeHost::cancelPendingLayerFlush):
(WebKit::LayerTreeHost::layerFlushTimerFired):
(WebKit::LayerTreeHost::setRootCompositingLayer):
(WebKit::LayerTreeHost::setViewOverlayRootLayer):
(WebKit::LayerTreeHost::invalidate):
(WebKit::LayerTreeHost::scrollNonCompositedContents):
(WebKit::LayerTreeHost::forceRepaint):
(WebKit::LayerTreeHost::forceRepaintAsync):
(WebKit::LayerTreeHost::sizeDidChange):
(WebKit::LayerTreeHost::pauseRendering):
(WebKit::LayerTreeHost::resumeRendering):
(WebKit::LayerTreeHost::graphicsLayerFactory):
(WebKit::LayerTreeHost::contentsSizeChanged):
(WebKit::LayerTreeHost::didChangeViewportAttributes):
(WebKit::LayerTreeHost::didChangeViewport):
(WebKit::LayerTreeHost::setIsDiscardable):
(WebKit::LayerTreeHost::setNativeSurfaceHandleForCompositing):
(WebKit::LayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::LayerTreeHost::createDisplayRefreshMonitor):
(WebKit::LayerTreeHost::didFlushRootLayer):
(WebKit::LayerTreeHost::commitSceneState):
(WebKit::LayerTreeHost::frameComplete):
(WebKit::LayerTreeHost::nativeSurfaceHandleForCompositing):
(WebKit::LayerTreeHost::didDestroyGLContext):
(WebKit::LayerTreeHost::willRenderFrame):
(WebKit::LayerTreeHost::didRenderFrame):
(WebKit::LayerTreeHost::requestDisplayRefreshMonitorUpdate):
(WebKit::LayerTreeHost::handleDisplayRefreshMonitorUpdate):
(WebKit::LayerTreeHost::renderNextFrame):

  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h.
  • WebProcess/WebPage/DrawingAreaImpl.cpp:

(WebKit::DrawingAreaImpl::setNeedsDisplay):
(WebKit::DrawingAreaImpl::setNeedsDisplayInRect):

  • WebProcess/WebPage/LayerTreeHost.cpp: Removed.
  • WebProcess/WebPage/LayerTreeHost.h: Removed.
  • WebPage/win/LayerTreeHost.h: Added.
Location:
trunk/Source/WebKit
Files:
1 added
5 deleted
8 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r242196 r242199  
     12019-02-28  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [CoordinatedGraphics] Unify all LayerTreeHost classes
     4        https://bugs.webkit.org/show_bug.cgi?id=195094
     5
     6        Reviewed by Žan Doberšek.
     7
     8        There's no reason to have 3 classes, since currently LayerTreeHost is only used by coordinated graphics based
     9        ports.
     10
     11        * PlatformWin.cmake:
     12        * SourcesGTK.txt:
     13        * SourcesWPE.txt:
     14        * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
     15        (WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode):
     16        (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModeNow):
     17        * WebProcess/WebPage/AcceleratedDrawingArea.h:
     18        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: Removed.
     19        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h: Removed.
     20        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp.
     21        (WebKit::LayerTreeHost::LayerTreeHost):
     22        (WebKit::LayerTreeHost::~LayerTreeHost):
     23        (WebKit::LayerTreeHost::setLayerFlushSchedulingEnabled):
     24        (WebKit::LayerTreeHost::scheduleLayerFlush):
     25        (WebKit::LayerTreeHost::cancelPendingLayerFlush):
     26        (WebKit::LayerTreeHost::layerFlushTimerFired):
     27        (WebKit::LayerTreeHost::setRootCompositingLayer):
     28        (WebKit::LayerTreeHost::setViewOverlayRootLayer):
     29        (WebKit::LayerTreeHost::invalidate):
     30        (WebKit::LayerTreeHost::scrollNonCompositedContents):
     31        (WebKit::LayerTreeHost::forceRepaint):
     32        (WebKit::LayerTreeHost::forceRepaintAsync):
     33        (WebKit::LayerTreeHost::sizeDidChange):
     34        (WebKit::LayerTreeHost::pauseRendering):
     35        (WebKit::LayerTreeHost::resumeRendering):
     36        (WebKit::LayerTreeHost::graphicsLayerFactory):
     37        (WebKit::LayerTreeHost::contentsSizeChanged):
     38        (WebKit::LayerTreeHost::didChangeViewportAttributes):
     39        (WebKit::LayerTreeHost::didChangeViewport):
     40        (WebKit::LayerTreeHost::setIsDiscardable):
     41        (WebKit::LayerTreeHost::setNativeSurfaceHandleForCompositing):
     42        (WebKit::LayerTreeHost::deviceOrPageScaleFactorChanged):
     43        (WebKit::LayerTreeHost::createDisplayRefreshMonitor):
     44        (WebKit::LayerTreeHost::didFlushRootLayer):
     45        (WebKit::LayerTreeHost::commitSceneState):
     46        (WebKit::LayerTreeHost::frameComplete):
     47        (WebKit::LayerTreeHost::nativeSurfaceHandleForCompositing):
     48        (WebKit::LayerTreeHost::didDestroyGLContext):
     49        (WebKit::LayerTreeHost::willRenderFrame):
     50        (WebKit::LayerTreeHost::didRenderFrame):
     51        (WebKit::LayerTreeHost::requestDisplayRefreshMonitorUpdate):
     52        (WebKit::LayerTreeHost::handleDisplayRefreshMonitorUpdate):
     53        (WebKit::LayerTreeHost::renderNextFrame):
     54        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h.
     55        * WebProcess/WebPage/DrawingAreaImpl.cpp:
     56        (WebKit::DrawingAreaImpl::setNeedsDisplay):
     57        (WebKit::DrawingAreaImpl::setNeedsDisplayInRect):
     58        * WebProcess/WebPage/LayerTreeHost.cpp: Removed.
     59        * WebProcess/WebPage/LayerTreeHost.h: Removed.
     60        * WebPage/win/LayerTreeHost.h: Added.
     61
    1622019-02-28  Justin Fan  <justin_fan@apple.com>
    263
  • trunk/Source/WebKit/PlatformWin.cmake

    r240683 r242199  
    8282    WebProcess/WebPage/AcceleratedSurface.cpp
    8383    WebProcess/WebPage/DrawingAreaImpl.cpp
    84     WebProcess/WebPage/LayerTreeHost.cpp
    8584
    8685    WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
    87     WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
    88     WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
     86    WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
    8987
    9088    WebProcess/WebPage/win/WebInspectorUIWin.cpp
  • trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h

    r235111 r242199  
    2626#pragma once
    2727
     28#include <WebCore/DisplayRefreshMonitor.h>
     29
    2830#if USE(COORDINATED_GRAPHICS_THREADED) && USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    29 
    30 #include <WebCore/DisplayRefreshMonitor.h>
    3131#include <wtf/RunLoop.h>
    3232
  • trunk/Source/WebKit/SourcesGTK.txt

    r241790 r242199  
    404404WebProcess/WebPage/AcceleratedDrawingArea.cpp
    405405WebProcess/WebPage/AcceleratedSurface.cpp
    406 WebProcess/WebPage/LayerTreeHost.cpp
    407406WebProcess/WebPage/ViewGestureGeometryCollector.cpp
    408407
    409408WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
    410 WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
    411 WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
     409WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
    412410
    413411WebProcess/WebPage/DrawingAreaImpl.cpp
  • trunk/Source/WebKit/SourcesWPE.txt

    r242082 r242199  
    244244WebProcess/WebPage/AcceleratedDrawingArea.cpp
    245245WebProcess/WebPage/AcceleratedSurface.cpp
    246 WebProcess/WebPage/LayerTreeHost.cpp
    247246
    248247WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
    249 WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
    250 WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
     248WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
    251249
    252250WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp
  • trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp

    r242082 r242199  
    6767}
    6868
    69 void AcceleratedDrawingArea::setNeedsDisplay()
    70 {
    71     if (!m_isPaintingEnabled)
    72         return;
    73 
    74     if (m_layerTreeHost)
    75         m_layerTreeHost->setNonCompositedContentsNeedDisplay();
    76 }
    77 
    78 void AcceleratedDrawingArea::setNeedsDisplayInRect(const IntRect& rect)
    79 {
    80     if (!m_isPaintingEnabled)
    81         return;
    82 
    83     if (m_layerTreeHost)
    84         m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect);
    85 }
    86 
    8769void AcceleratedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
    8870{
     
    344326    ASSERT(!m_layerTreeHost);
    345327    if (m_previousLayerTreeHost) {
    346 #if USE(COORDINATED_GRAPHICS)
    347328        m_layerTreeHost = WTFMove(m_previousLayerTreeHost);
    348329        m_layerTreeHost->setIsDiscardable(false);
     
    351332        if (!m_layerTreeStateIsFrozen)
    352333            m_layerTreeHost->setLayerFlushSchedulingEnabled(true);
     334    } else {
     335#if USE(COORDINATED_GRAPHICS_THREADED)
     336        m_layerTreeHost = std::make_unique<LayerTreeHost>(m_webPage);
    353337#else
    354         ASSERT_NOT_REACHED();
    355 #endif
    356     } else {
    357         m_layerTreeHost = LayerTreeHost::create(m_webPage);
    358 
     338        m_layerTreeHost = nullptr;
     339#endif
     340       
    359341        if (!m_layerTreeHost)
    360342            return;
     
    394376    m_wantsToExitAcceleratedCompositingMode = false;
    395377
    396 #if USE(COORDINATED_GRAPHICS)
    397378    ASSERT(m_layerTreeHost);
    398379    m_previousLayerTreeHost = WTFMove(m_layerTreeHost);
     
    401382    m_previousLayerTreeHost->setLayerFlushSchedulingEnabled(false);
    402383    m_discardPreviousLayerTreeHostTimer.startOneShot(5_s);
    403 #else
    404     m_layerTreeHost = nullptr;
    405 #endif
    406384}
    407385
  • trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h

    r242082 r242199  
    4141protected:
    4242    // DrawingArea
    43     void setNeedsDisplay() override;
    44     void setNeedsDisplayInRect(const WebCore::IntRect&) override;
     43    void setNeedsDisplay() override { };
     44    void setNeedsDisplayInRect(const WebCore::IntRect&) override { };
    4545    void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
    4646    void setLayerTreeStateIsFrozen(bool) override;
     
    129129
    130130    // The layer tree host that handles accelerated compositing.
    131     RefPtr<LayerTreeHost> m_layerTreeHost;
     131    std::unique_ptr<LayerTreeHost> m_layerTreeHost;
    132132
    133     RefPtr<LayerTreeHost> m_previousLayerTreeHost;
     133    std::unique_ptr<LayerTreeHost> m_previousLayerTreeHost;
    134134    RunLoop::Timer<AcceleratedDrawingArea> m_discardPreviousLayerTreeHostTimer;
    135135};
  • trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp

    r242198 r242199  
    33 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44 * Copyright (C) 2012 Company 100, Inc.
    5  * Copyright (C) 2014 Igalia S.L.
     5 * Copyright (C) 2014-2019 Igalia S.L.
    66 *
    77 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#include "config.h"
    30 #include "ThreadedCoordinatedLayerTreeHost.h"
     30#include "LayerTreeHost.h"
    3131
    3232#if USE(COORDINATED_GRAPHICS_THREADED)
    3333
    34 #include "AcceleratedSurface.h"
     34#include "DrawingArea.h"
    3535#include "WebPage.h"
     36#include "WebPageProxyMessages.h"
    3637#include <WebCore/Frame.h>
    3738#include <WebCore/FrameView.h>
     39#include <WebCore/PageOverlayController.h>
     40
     41#if USE(GLIB_EVENT_LOOP)
     42#include <wtf/glib/RunLoopSourcePriority.h>
     43#endif
    3844
    3945namespace WebKit {
     
    4753#endif
    4854
    49 Ref<ThreadedCoordinatedLayerTreeHost> ThreadedCoordinatedLayerTreeHost::create(WebPage& webPage)
    50 {
    51     return adoptRef(*new ThreadedCoordinatedLayerTreeHost(webPage));
    52 }
    53 
    54 ThreadedCoordinatedLayerTreeHost::~ThreadedCoordinatedLayerTreeHost()
    55 {
    56 }
    57 
    58 ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webPage)
    59     : CoordinatedLayerTreeHost(webPage)
     55LayerTreeHost::LayerTreeHost(WebPage& webPage)
     56    : m_webPage(webPage)
     57    , m_coordinator(webPage.corePage(), *this)
    6058    , m_compositorClient(*this)
    6159    , m_surface(AcceleratedSurface::create(webPage, *this))
    6260    , m_viewportController(webPage.size())
    63 {
     61    , m_layerFlushTimer(RunLoop::main(), this, &LayerTreeHost::layerFlushTimerFired)
     62{
     63#if USE(GLIB_EVENT_LOOP)
     64    m_layerFlushTimer.setPriority(RunLoopSourcePriority::LayerFlushTimer);
     65    m_layerFlushTimer.setName("[WebKit] LayerTreeHost");
     66#endif
     67    m_coordinator.createRootLayer(m_webPage.size());
     68    scheduleLayerFlush();
     69
    6470    if (FrameView* frameView = m_webPage.mainFrameView()) {
    6571        auto contentsSize = frameView->contentsSize();
     
    8894}
    8995
    90 void ThreadedCoordinatedLayerTreeHost::invalidate()
    91 {
     96LayerTreeHost::~LayerTreeHost()
     97{
     98    ASSERT(!m_isValid);
     99}
     100
     101void LayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
     102{
     103    if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
     104        return;
     105
     106    m_layerFlushSchedulingEnabled = layerFlushingEnabled;
     107
     108    if (m_layerFlushSchedulingEnabled) {
     109        scheduleLayerFlush();
     110        return;
     111    }
     112
     113    cancelPendingLayerFlush();
     114}
     115
     116void LayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush)
     117{
     118    m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush;
     119}
     120
     121void LayerTreeHost::scheduleLayerFlush()
     122{
     123    if (!m_layerFlushSchedulingEnabled)
     124        return;
     125
     126    if (m_isWaitingForRenderer) {
     127        m_scheduledWhileWaitingForRenderer = true;
     128        return;
     129    }
     130
     131    if (!m_layerFlushTimer.isActive())
     132        m_layerFlushTimer.startOneShot(0_s);
     133}
     134
     135void LayerTreeHost::cancelPendingLayerFlush()
     136{
     137    m_layerFlushTimer.stop();
     138}
     139
     140void LayerTreeHost::layerFlushTimerFired()
     141{
     142    if (m_isSuspended || m_isWaitingForRenderer)
     143        return;
     144
     145    m_coordinator.syncDisplayState();
     146    m_webPage.flushPendingEditorStateUpdate();
     147    m_webPage.willDisplayPage();
     148
     149    if (!m_isValid || !m_coordinator.rootCompositingLayer())
     150        return;
     151
     152    // If a force-repaint callback was registered, we should force a 'frame sync' that
     153    // will guarantee us a call to renderNextFrame() once the update is complete.
     154    if (m_forceRepaintAsync.callbackID)
     155        m_coordinator.forceFrameSync();
     156
     157    bool didSync = m_coordinator.flushPendingLayerChanges();
     158
     159    if (m_notifyAfterScheduledLayerFlush && didSync) {
     160        m_webPage.drawingArea()->layerHostDidFlushLayers();
     161        m_notifyAfterScheduledLayerFlush = false;
     162    }
     163}
     164
     165void LayerTreeHost::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
     166{
     167    m_coordinator.setRootCompositingLayer(graphicsLayer);
     168}
     169
     170void LayerTreeHost::setViewOverlayRootLayer(GraphicsLayer* viewOverlayRootLayer)
     171{
     172    m_viewOverlayRootLayer = viewOverlayRootLayer;
     173    m_coordinator.setViewOverlayRootLayer(viewOverlayRootLayer);
     174}
     175
     176void LayerTreeHost::invalidate()
     177{
     178    ASSERT(m_isValid);
     179    m_isValid = false;
     180
     181    cancelPendingLayerFlush();
     182
     183    m_coordinator.invalidate();
    92184    m_compositor->invalidate();
    93     CoordinatedLayerTreeHost::invalidate();
    94185    m_surface = nullptr;
    95186}
    96187
    97 void ThreadedCoordinatedLayerTreeHost::forceRepaint()
    98 {
    99     CoordinatedLayerTreeHost::forceRepaint();
    100     m_compositor->forceRepaint();
    101 }
    102 
    103 void ThreadedCoordinatedLayerTreeHost::frameComplete()
    104 {
    105     m_compositor->frameComplete();
    106 }
    107 
    108 void ThreadedCoordinatedLayerTreeHost::requestDisplayRefreshMonitorUpdate()
    109 {
    110     // Flush layers to cause a repaint. If m_isWaitingForRenderer was true at this point, the layer
    111     // flush won't do anything, but that means there's a painting ongoing that will send the
    112     // display refresh notification when it's done.
    113     flushLayersAndForceRepaint();
    114 }
    115 
    116 void ThreadedCoordinatedLayerTreeHost::handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled)
    117 {
    118     // Call renderNextFrame. If hasBeenRescheduled is true, the layer flush will force a repaint
    119     // that will cause the display refresh notification to come.
    120     renderNextFrame(hasBeenRescheduled);
    121     m_compositor->handleDisplayRefreshMonitorUpdate();
    122 }
    123 
    124 uint64_t ThreadedCoordinatedLayerTreeHost::nativeSurfaceHandleForCompositing()
    125 {
    126     if (!m_surface)
    127         return m_layerTreeContext.contextID;
    128 
    129     m_surface->initialize();
    130     return m_surface->window();
    131 }
    132 
    133 void ThreadedCoordinatedLayerTreeHost::didDestroyGLContext()
    134 {
    135     if (m_surface)
    136         m_surface->finalize();
    137 }
    138 
    139 void ThreadedCoordinatedLayerTreeHost::willRenderFrame()
    140 {
    141     if (m_surface)
    142         m_surface->willRenderFrame();
    143 }
    144 
    145 void ThreadedCoordinatedLayerTreeHost::didRenderFrame()
    146 {
    147     if (m_surface)
    148         m_surface->didRenderFrame();
    149 }
    150 
    151 void ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents(const IntRect& rect)
    152 {
    153     FrameView* frameView = m_webPage.mainFrameView();
     188void LayerTreeHost::scrollNonCompositedContents(const IntRect& rect)
     189{
     190    auto* frameView = m_webPage.mainFrameView();
    154191    if (!frameView || !frameView->delegatesScrolling())
    155192        return;
     
    162199}
    163200
    164 void ThreadedCoordinatedLayerTreeHost::contentsSizeChanged(const IntSize& newSize)
     201void LayerTreeHost::forceRepaint()
     202{
     203    // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
     204    // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed.
     205    m_coordinator.syncDisplayState();
     206
     207    // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush.
     208    scheduleLayerFlush();
     209
     210    if (!m_isWaitingForRenderer)
     211        m_coordinator.flushPendingLayerChanges();
     212    m_compositor->forceRepaint();
     213}
     214
     215bool LayerTreeHost::forceRepaintAsync(CallbackID callbackID)
     216{
     217    scheduleLayerFlush();
     218
     219    // We want a clean repaint, meaning that if we're currently waiting for the renderer
     220    // to finish an update, we'll have to schedule another flush when it's done.
     221    ASSERT(!m_forceRepaintAsync.callbackID);
     222    m_forceRepaintAsync.callbackID = OptionalCallbackID(callbackID);
     223    m_forceRepaintAsync.needsFreshFlush = m_scheduledWhileWaitingForRenderer;
     224    return true;
     225}
     226
     227void LayerTreeHost::sizeDidChange(const IntSize& size)
     228{
     229    if (m_isDiscardable) {
     230        m_discardableSyncActions.add(DiscardableSyncActions::UpdateSize);
     231        m_viewportController.didChangeViewportSize(size);
     232        return;
     233    }
     234
     235    if (m_surface && m_surface->hostResize(size))
     236        m_layerTreeContext.contextID = m_surface->surfaceID();
     237
     238    m_coordinator.sizeDidChange(size);
     239    scheduleLayerFlush();
     240
     241    m_viewportController.didChangeViewportSize(size);
     242    IntSize scaledSize(size);
     243    scaledSize.scale(m_webPage.deviceScaleFactor());
     244    m_compositor->setViewportSize(scaledSize, m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
     245    didChangeViewport();
     246}
     247
     248void LayerTreeHost::pauseRendering()
     249{
     250    m_isSuspended = true;
     251}
     252
     253void LayerTreeHost::resumeRendering()
     254{
     255    m_isSuspended = false;
     256    scheduleLayerFlush();
     257}
     258
     259GraphicsLayerFactory* LayerTreeHost::graphicsLayerFactory()
     260{
     261    return &m_coordinator;
     262}
     263
     264void LayerTreeHost::contentsSizeChanged(const IntSize& newSize)
    165265{
    166266    m_viewportController.didChangeContentsSize(newSize);
     
    171271}
    172272
    173 void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
    174 {
    175     if (m_isDiscardable) {
    176         m_discardableSyncActions.add(DiscardableSyncActions::UpdateScale);
    177         return;
    178     }
    179 
    180     if (m_surface && m_surface->hostResize(m_webPage.size()))
    181         m_layerTreeContext.contextID = m_surface->surfaceID();
    182 
    183     CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged();
    184     m_compositor->setScaleFactor(m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
    185 }
    186 
    187 void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
    188 {
    189     if (m_isDiscardable) {
    190         m_discardableSyncActions.add(DiscardableSyncActions::UpdateSize);
    191         m_viewportController.didChangeViewportSize(size);
    192         return;
    193     }
    194 
    195     if (m_surface && m_surface->hostResize(size))
    196         m_layerTreeContext.contextID = m_surface->surfaceID();
    197 
    198     CoordinatedLayerTreeHost::sizeDidChange(size);
    199     m_viewportController.didChangeViewportSize(size);
    200     IntSize scaledSize(size);
    201     scaledSize.scale(m_webPage.deviceScaleFactor());
    202     m_compositor->setViewportSize(scaledSize, m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
    203     didChangeViewport();
    204 }
    205 
    206 void ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes(ViewportAttributes&& attr)
     273void LayerTreeHost::didChangeViewportAttributes(ViewportAttributes&& attr)
    207274{
    208275    m_viewportController.didChangeViewportAttributes(WTFMove(attr));
     
    213280}
    214281
    215 #if PLATFORM(GTK) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    216 void ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing(uint64_t handle)
    217 {
    218     m_layerTreeContext.contextID = handle;
    219     m_compositor->setNativeSurfaceHandleForCompositing(handle);
    220     scheduleLayerFlush();
    221 }
    222 #endif
    223 
    224 void ThreadedCoordinatedLayerTreeHost::didChangeViewport()
     282void LayerTreeHost::didChangeViewport()
    225283{
    226284    FloatRect visibleRect(m_viewportController.visibleContentsRect());
     
    239297        visibleRect.expand(0, scrollbar->height());
    240298
    241     CoordinatedLayerTreeHost::setVisibleContentsRect(visibleRect);
     299    m_coordinator.setVisibleContentsRect(visibleRect);
     300    scheduleLayerFlush();
    242301
    243302    float pageScale = m_viewportController.pageScaleFactor();
     
    257316}
    258317
    259 void ThreadedCoordinatedLayerTreeHost::commitSceneState(const CoordinatedGraphicsState& state)
    260 {
    261     CoordinatedLayerTreeHost::commitSceneState(state);
    262     m_compositor->updateSceneState(state);
    263 }
    264 
    265 void ThreadedCoordinatedLayerTreeHost::setIsDiscardable(bool discardable)
     318void LayerTreeHost::setIsDiscardable(bool discardable)
    266319{
    267320    m_isDiscardable = discardable;
     
    289342}
    290343
     344#if PLATFORM(GTK) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
     345void LayerTreeHost::setNativeSurfaceHandleForCompositing(uint64_t handle)
     346{
     347    m_layerTreeContext.contextID = handle;
     348    m_compositor->setNativeSurfaceHandleForCompositing(handle);
     349    scheduleLayerFlush();
     350}
     351#endif
     352
     353void LayerTreeHost::deviceOrPageScaleFactorChanged()
     354{
     355    if (m_isDiscardable) {
     356        m_discardableSyncActions.add(DiscardableSyncActions::UpdateScale);
     357        return;
     358    }
     359
     360    if (m_surface && m_surface->hostResize(m_webPage.size()))
     361        m_layerTreeContext.contextID = m_surface->surfaceID();
     362
     363    m_coordinator.deviceOrPageScaleFactorChanged();
     364    m_webPage.corePage()->pageOverlayController().didChangeDeviceScaleFactor();
     365    m_compositor->setScaleFactor(m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
     366}
     367
    291368#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    292 RefPtr<WebCore::DisplayRefreshMonitor> ThreadedCoordinatedLayerTreeHost::createDisplayRefreshMonitor(PlatformDisplayID displayID)
     369RefPtr<DisplayRefreshMonitor> LayerTreeHost::createDisplayRefreshMonitor(PlatformDisplayID displayID)
    293370{
    294371    return m_compositor->displayRefreshMonitor(displayID);
     
    296373#endif
    297374
     375void LayerTreeHost::didFlushRootLayer(const FloatRect& visibleContentRect)
     376{
     377    // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually.
     378    if (m_viewOverlayRootLayer)
     379        m_viewOverlayRootLayer->flushCompositingState(visibleContentRect);
     380}
     381
     382void LayerTreeHost::commitSceneState(const CoordinatedGraphicsState& state)
     383{
     384    m_isWaitingForRenderer = true;
     385    m_compositor->updateSceneState(state);
     386}
     387
     388void LayerTreeHost::frameComplete()
     389{
     390    m_compositor->frameComplete();
     391}
     392
     393uint64_t LayerTreeHost::nativeSurfaceHandleForCompositing()
     394{
     395    if (!m_surface)
     396        return m_layerTreeContext.contextID;
     397
     398    m_surface->initialize();
     399    return m_surface->window();
     400}
     401
     402void LayerTreeHost::didDestroyGLContext()
     403{
     404    if (m_surface)
     405        m_surface->finalize();
     406}
     407
     408void LayerTreeHost::willRenderFrame()
     409{
     410    if (m_surface)
     411        m_surface->willRenderFrame();
     412}
     413
     414void LayerTreeHost::didRenderFrame()
     415{
     416    if (m_surface)
     417        m_surface->didRenderFrame();
     418}
     419
     420void LayerTreeHost::requestDisplayRefreshMonitorUpdate()
     421{
     422    // Flush layers to cause a repaint. If m_isWaitingForRenderer was true at this point, the layer
     423    // flush won't do anything, but that means there's a painting ongoing that will send the
     424    // display refresh notification when it's done.
     425    m_coordinator.forceFrameSync();
     426    scheduleLayerFlush();
     427}
     428
     429void LayerTreeHost::handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled)
     430{
     431    // Call renderNextFrame. If hasBeenRescheduled is true, the layer flush will force a repaint
     432    // that will cause the display refresh notification to come.
     433    renderNextFrame(hasBeenRescheduled);
     434    m_compositor->handleDisplayRefreshMonitorUpdate();
     435}
     436
     437void LayerTreeHost::renderNextFrame(bool forceRepaint)
     438{
     439    m_isWaitingForRenderer = false;
     440    bool scheduledWhileWaitingForRenderer = std::exchange(m_scheduledWhileWaitingForRenderer, false);
     441    m_coordinator.renderNextFrame();
     442
     443    if (m_forceRepaintAsync.callbackID) {
     444        // If the asynchronous force-repaint needs a separate fresh flush, it was due to
     445        // the force-repaint request being registered while CoordinatedLayerTreeHost was
     446        // waiting for the renderer to finish an update.
     447        ASSERT(!m_forceRepaintAsync.needsFreshFlush || scheduledWhileWaitingForRenderer);
     448
     449        // Execute the callback if another layer flush and the subsequent state update
     450        // aren't needed. If they are, the callback will be executed when this function
     451        // is called after the next update.
     452        if (!m_forceRepaintAsync.needsFreshFlush) {
     453            m_webPage.send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsync.callbackID.callbackID()));
     454            m_forceRepaintAsync.callbackID = OptionalCallbackID();
     455        }
     456        m_forceRepaintAsync.needsFreshFlush = false;
     457    }
     458
     459    if (scheduledWhileWaitingForRenderer || m_layerFlushTimer.isActive() || forceRepaint) {
     460        m_layerFlushTimer.stop();
     461        if (forceRepaint)
     462            m_coordinator.forceFrameSync();
     463        layerFlushTimerFired();
     464    }
     465}
     466
    298467} // namespace WebKit
    299468
  • trunk/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp

    r242082 r242199  
    6262    if (m_layerTreeHost) {
    6363        ASSERT(m_dirtyRegion.isEmpty());
    64         AcceleratedDrawingArea::setNeedsDisplay();
    6564        return;
    6665    }
     
    7372    if (m_layerTreeHost) {
    7473        ASSERT(m_dirtyRegion.isEmpty());
    75         AcceleratedDrawingArea::setNeedsDisplayInRect(rect);
    7674        return;
    7775    }
Note: See TracChangeset for help on using the changeset viewer.