Skip to content

Commit

Permalink
[GTK][WPE] AsyncScrolling: notify scrolling tree about display refres…
Browse files Browse the repository at this point in the history
…h through ThreadedCompositor client

https://bugs.webkit.org/show_bug.cgi?id=246940

Reviewed by Žan Doberšek.

The threaded compositor is already attached to a WebPage so we can
notify the associated scrolling tree directly instead of iterating all
scrolling trees in the process. Also accessing the WebProcess and
EventDipatcher from ThreadedCompositor was a layering violation.

* Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::sceneUpdateFinished):
* Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::displayDidRefresh):
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:

Canonical link: https://commits.webkit.org/255913@main
  • Loading branch information
carlosgcampos committed Oct 24, 2022
1 parent 1610fc7 commit 8bc5773
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Expand Up @@ -29,9 +29,7 @@
#if USE(COORDINATED_GRAPHICS)

#include "CompositingRunLoop.h"
#include "EventDispatcher.h"
#include "ThreadedDisplayRefreshMonitor.h"
#include "WebProcess.h"
#include <WebCore/PlatformDisplay.h>
#include <WebCore/TransformationMatrix.h>
#include <wtf/SetForScope.h>
Expand Down Expand Up @@ -259,11 +257,11 @@ void ThreadedCompositor::sceneUpdateFinished()
Locker stateLocker { m_compositingRunLoop->stateLock() };

// Schedule the DisplayRefreshMonitor callback, if necessary.
if (shouldDispatchDisplayRefreshCallback)
if (shouldDispatchDisplayRefreshCallback) {
m_displayRefreshMonitor->dispatchDisplayRefreshCallback();

// Always notify the ScrollingTrees to make sure scrolling does not depend on the main thread.
WebProcess::singleton().eventDispatcher().notifyScrollingTreesDisplayWasRefreshed(m_displayRefreshMonitor->displayID());
// Notify the ScrollingTree to make sure scrolling does not depend on the main thread.
m_client.displayDidRefresh(m_displayRefreshMonitor->displayID());
}

// Mark the scene update as completed.
m_compositingRunLoop->updateCompleted(stateLocker);
Expand Down
Expand Up @@ -56,6 +56,7 @@ class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadS
virtual void resize(const WebCore::IntSize&) = 0;
virtual void willRenderFrame() = 0;
virtual void didRenderFrame() = 0;
virtual void displayDidRefresh(WebCore::PlatformDisplayID) = 0;
};

static Ref<ThreadedCompositor> create(Client&, ThreadedDisplayRefreshMonitor::Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, WebCore::TextureMapper::PaintFlags);
Expand Down
Expand Up @@ -34,12 +34,14 @@
#include "DrawingArea.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
#include <WebCore/AsyncScrollingCoordinator.h>
#include <WebCore/Chrome.h>
#include <WebCore/Frame.h>
#include <WebCore/FrameView.h>
#include <WebCore/PageOverlayController.h>
#include <WebCore/RenderLayerBacking.h>
#include <WebCore/RenderView.h>
#include <WebCore/ThreadedScrollingTree.h>

#if USE(GLIB_EVENT_LOOP)
#include <wtf/glib/RunLoopSourcePriority.h>
Expand Down Expand Up @@ -418,6 +420,18 @@ void LayerTreeHost::didRenderFrame()
m_surface->didRenderFrame();
}

void LayerTreeHost::displayDidRefresh(PlatformDisplayID displayID)
{
#if ENABLE(ASYNC_SCROLLING)
if (auto* scrollingCoordinator = m_webPage.scrollingCoordinator()) {
if (auto* scrollingTree = downcast<AsyncScrollingCoordinator>(*scrollingCoordinator).scrollingTree())
downcast<ThreadedScrollingTree>(*scrollingTree).displayDidRefresh(displayID);
}
#else
UNUSED_PARAM(displayID);
#endif
}

void LayerTreeHost::requestDisplayRefreshMonitorUpdate()
{
// Flush layers to cause a repaint. If m_isWaitingForRenderer was true at this point, the layer
Expand Down
Expand Up @@ -124,6 +124,7 @@ class LayerTreeHost
void resize(const WebCore::IntSize&) override;
void willRenderFrame() override;
void didRenderFrame() override;
void displayDidRefresh(WebCore::PlatformDisplayID) override;

// ThreadedDisplayRefreshMonitor::Client
void requestDisplayRefreshMonitorUpdate() override;
Expand Down

0 comments on commit 8bc5773

Please sign in to comment.