Title: [294322] trunk/Source/WebKit
Revision
294322
Author
[email protected]
Date
2022-05-17 06:22:50 -0700 (Tue, 17 May 2022)

Log Message

[WPE] Use new libwpe API to synchronise display refreshes fully to the screen refresh rate
https://bugs.webkit.org/show_bug.cgi?id=240453

Reviewed by Adrian Perez de Castro.

Use new libwpe API to track the target refresh rate and use it in
ThreadedDisplayRefreshMonitor for DisplayUpdate objects.

* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::targetRefreshRateDidChange):
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp:
(WebKit::ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor):
(WebKit::ThreadedDisplayRefreshMonitor::setTargetRefreshRate):
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h:
* UIProcess/API/wpe/WPEView.cpp:
(WKWPE::m_backend):
* UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
(WebKit::DrawingAreaProxyCoordinatedGraphics::targetRefreshRateDidChange):
* UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h:
* UIProcess/DrawingAreaProxy.h:
* WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
(WebKit::DrawingAreaCoordinatedGraphics::targetRefreshRateDidChange):
* WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h:
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::targetRefreshRateDidChange):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::targetRefreshRateDidChange):
* WebProcess/WebPage/DrawingArea.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (294321 => 294322)


--- trunk/Source/WebKit/ChangeLog	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/ChangeLog	2022-05-17 13:22:50 UTC (rev 294322)
@@ -1,3 +1,36 @@
+2022-05-17  Chris Lord  <[email protected]>
+
+        [WPE] Use new libwpe API to synchronise display refreshes fully to the screen refresh rate
+        https://bugs.webkit.org/show_bug.cgi?id=240453
+
+        Reviewed by Adrian Perez de Castro.
+
+        Use new libwpe API to track the target refresh rate and use it in
+        ThreadedDisplayRefreshMonitor for DisplayUpdate objects.
+
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::targetRefreshRateDidChange):
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp:
+        (WebKit::ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor):
+        (WebKit::ThreadedDisplayRefreshMonitor::setTargetRefreshRate):
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h:
+        * UIProcess/API/wpe/WPEView.cpp:
+        (WKWPE::m_backend):
+        * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
+        (WebKit::DrawingAreaProxyCoordinatedGraphics::targetRefreshRateDidChange):
+        * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h:
+        * UIProcess/DrawingAreaProxy.h:
+        * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
+        (WebKit::DrawingAreaCoordinatedGraphics::targetRefreshRateDidChange):
+        * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h:
+        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
+        (WebKit::LayerTreeHost::targetRefreshRateDidChange):
+        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::targetRefreshRateDidChange):
+        * WebProcess/WebPage/DrawingArea.messages.in:
+
 2022-05-17  Kimmo Kinnunen  <[email protected]>
 
         ImageBufferIOSurfaceBackend context setup and teardown functions are redundant and error-prone

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (294321 => 294322)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2022-05-17 13:22:50 UTC (rev 294322)
@@ -310,5 +310,11 @@
     sceneUpdateFinished();
 }
 
+void ThreadedCompositor::targetRefreshRateDidChange(unsigned rate)
+{
+    ASSERT(!RunLoop::isMain());
+    m_displayRefreshMonitor->setTargetRefreshRate(rate);
 }
+
+}
 #endif // USE(COORDINATED_GRAPHICS)

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (294321 => 294322)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2022-05-17 13:22:50 UTC (rev 294322)
@@ -76,6 +76,7 @@
     RefPtr<WebCore::DisplayRefreshMonitor> displayRefreshMonitor(WebCore::PlatformDisplayID);
 
     void frameComplete();
+    void targetRefreshRateDidChange(unsigned);
 
     void suspend();
     void resume();

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp (294321 => 294322)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp	2022-05-17 13:22:50 UTC (rev 294322)
@@ -37,14 +37,14 @@
 
 namespace WebKit {
 
-// FIXME: Use the correct frame rate.
-constexpr WebCore::FramesPerSecond DefaultFramesPerSecond = 60;
+constexpr unsigned defaultRefreshRate = 60000;
 
 ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID displayID, Client& client)
     : WebCore::DisplayRefreshMonitor(displayID)
     , m_displayRefreshTimer(RunLoop::main(), this, &ThreadedDisplayRefreshMonitor::displayRefreshCallback)
     , m_client(&client)
-    , m_currentUpdate({ 0, DefaultFramesPerSecond })
+    , m_targetRefreshRate(defaultRefreshRate)
+    , m_currentUpdate({ 0, m_targetRefreshRate / 1000 })
 {
 #if USE(GLIB_EVENT_LOOP)
     m_displayRefreshTimer.setPriority(RunLoopSourcePriority::DisplayRefreshMonitorTimer);
@@ -133,6 +133,16 @@
         m_client->handleDisplayRefreshMonitorUpdate(hasBeenRescheduled);
 }
 
+void ThreadedDisplayRefreshMonitor::setTargetRefreshRate(unsigned rate)
+{
+    if (!rate)
+        rate = defaultRefreshRate;
+    if (m_targetRefreshRate != rate) {
+        m_targetRefreshRate = rate;
+        m_currentUpdate = { 0, m_targetRefreshRate / 1000 };
+    }
+}
+
 } // namespace WebKit
 
 #endif // USE(COORDINATED_GRAPHICS)

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h (294321 => 294322)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h	2022-05-17 13:22:50 UTC (rev 294322)
@@ -54,6 +54,8 @@
     void dispatchDisplayRefreshCallback();
     void invalidate();
 
+    void setTargetRefreshRate(unsigned);
+
 private:
     ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID, Client&);
 
@@ -63,6 +65,7 @@
     void displayRefreshCallback();
     RunLoop::Timer<ThreadedDisplayRefreshMonitor> m_displayRefreshTimer;
     Client* m_client;
+    unsigned m_targetRefreshRate;
     WebCore::DisplayUpdate m_currentUpdate;
 };
 

Modified: trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp (294321 => 294322)


--- trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp	2022-05-17 13:22:50 UTC (rev 294322)
@@ -121,13 +121,23 @@
             auto& view = *reinterpret_cast<View*>(data);
             view.page().setIntrinsicDeviceScaleFactor(scale);
         },
+#if WPE_CHECK_VERSION(1, 13, 2)
+        // target_refresh_rate_changed
+        [](void* data, uint32_t rate)
+        {
+            auto& view = *reinterpret_cast<View*>(data);
+            if (view.page().drawingArea())
+                view.page().drawingArea()->targetRefreshRateDidChange(rate);
+        },
 #else
         // padding
         nullptr,
+#endif // WPE_CHECK_VERSION(1, 13, 0)
+#else
+        // padding
         nullptr,
+        nullptr
 #endif // WPE_CHECK_VERSION(1, 3, 0)
-        // padding
-        nullptr
     };
     wpe_view_backend_set_backend_client(m_backend, &s_backendClient, this);
 

Modified: trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp (294321 => 294322)


--- trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp	2022-05-17 13:22:50 UTC (rev 294322)
@@ -239,6 +239,11 @@
     updateAcceleratedCompositingMode(layerTreeContext);
 }
 
+void DrawingAreaProxyCoordinatedGraphics::targetRefreshRateDidChange(unsigned rate)
+{
+    send(Messages::DrawingArea::TargetRefreshRateDidChange(rate));
+}
+
 #if !PLATFORM(WPE)
 void DrawingAreaProxyCoordinatedGraphics::incorporateUpdate(const UpdateInfo& updateInfo)
 {

Modified: trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h (294321 => 294322)


--- trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h	2022-05-17 13:22:50 UTC (rev 294322)
@@ -68,6 +68,7 @@
     void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
     void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) override;
     void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
+    void targetRefreshRateDidChange(unsigned) override;
 
 #if !PLATFORM(WPE)
     void incorporateUpdate(const UpdateInfo&);

Modified: trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h (294321 => 294322)


--- trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h	2022-05-17 13:22:50 UTC (rev 294322)
@@ -79,6 +79,7 @@
 #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
     // The timeout we use when waiting for a DidUpdateGeometry message.
     static constexpr Seconds didUpdateBackingStoreStateTimeout() { return Seconds::fromMilliseconds(500); }
+    virtual void targetRefreshRateDidChange(unsigned) { }
 #endif
 
     virtual void colorSpaceDidChange() { }

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (294321 => 294322)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp	2022-05-17 13:22:50 UTC (rev 294322)
@@ -461,6 +461,15 @@
         forceRepaint();
 }
 
+void DrawingAreaCoordinatedGraphics::targetRefreshRateDidChange(unsigned rate)
+{
+    UNUSED_PARAM(rate);
+#if !USE(GRAPHICS_LAYER_TEXTURE_MAPPER)
+    if (m_layerTreeHost)
+        m_layerTreeHost->targetRefreshRateDidChange(rate);
+#endif
+}
+
 void DrawingAreaCoordinatedGraphics::didUpdate()
 {
     // We might get didUpdate messages from the UI process even after we've

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h (294321 => 294322)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h	2022-05-17 13:22:50 UTC (rev 294322)
@@ -82,6 +82,7 @@
 
     // IPC message handlers.
     void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override;
+    void targetRefreshRateDidChange(unsigned rate) override;
     void didUpdate() override;
 
 #if PLATFORM(GTK)

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp (294321 => 294322)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp	2022-05-17 13:22:50 UTC (rev 294322)
@@ -249,6 +249,11 @@
     didChangeViewport();
 }
 
+void LayerTreeHost::targetRefreshRateDidChange(uint32_t rate)
+{
+    m_compositor->targetRefreshRateDidChange(rate);
+}
+
 void LayerTreeHost::pauseRendering()
 {
     m_isSuspended = true;

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h (294321 => 294322)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h	2022-05-17 13:22:50 UTC (rev 294322)
@@ -83,6 +83,7 @@
     void forceRepaint();
     void forceRepaintAsync(CompletionHandler<void()>&&);
     void sizeDidChange(const WebCore::IntSize& newSize);
+    void targetRefreshRateDidChange(unsigned);
 
     void pauseRendering();
     void resumeRendering();

Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h (294321 => 294322)


--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2022-05-17 13:22:50 UTC (rev 294322)
@@ -175,6 +175,7 @@
 #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
     virtual void updateBackingStoreState(uint64_t /*backingStoreStateID*/, bool /*respondImmediately*/, float /*deviceScaleFactor*/, const WebCore::IntSize& /*size*/,
                                          const WebCore::IntSize& /*scrollOffset*/) { }
+    virtual void targetRefreshRateDidChange(unsigned /*rate*/) { }
 #endif
     virtual void didUpdate() { }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in (294321 => 294322)


--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in	2022-05-17 13:22:01 UTC (rev 294321)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in	2022-05-17 13:22:50 UTC (rev 294322)
@@ -23,6 +23,7 @@
 messages -> DrawingArea NotRefCounted {
 #if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
     UpdateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, WebCore::IntSize size, WebCore::IntSize scrollOffset)
+    TargetRefreshRateDidChange(unsigned rate)
 #endif
 
     DidUpdate()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to