Title: [231818] trunk/Source/WebKit
Revision
231818
Author
[email protected]
Date
2018-05-15 16:06:28 -0700 (Tue, 15 May 2018)

Log Message

Pause display links when window is not visible.
https://bugs.webkit.org/show_bug.cgi?id=185627
<rdar://problem/39401106>

Reviewed by Simon Fraser.

Pause/resume display links created in the UI process when the window is hidden/shown.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchActivityStateChange):
* UIProcess/mac/DisplayLink.cpp:
(WebKit::DisplayLink::pause):
(WebKit::DisplayLink::resume):
* UIProcess/mac/DisplayLink.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (231817 => 231818)


--- trunk/Source/WebKit/ChangeLog	2018-05-15 23:01:14 UTC (rev 231817)
+++ trunk/Source/WebKit/ChangeLog	2018-05-15 23:06:28 UTC (rev 231818)
@@ -1,3 +1,20 @@
+2018-05-15  Per Arne Vollan  <[email protected]>
+
+        Pause display links when window is not visible.
+        https://bugs.webkit.org/show_bug.cgi?id=185627
+        <rdar://problem/39401106>
+
+        Reviewed by Simon Fraser.
+
+        Pause/resume display links created in the UI process when the window is hidden/shown.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::dispatchActivityStateChange):
+        * UIProcess/mac/DisplayLink.cpp:
+        (WebKit::DisplayLink::pause):
+        (WebKit::DisplayLink::resume):
+        * UIProcess/mac/DisplayLink.h:
+
 2018-05-15  Dean Jackson  <[email protected]>
 
         Provide UIView and UIImage for zoom transition

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (231817 => 231818)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-05-15 23:01:14 UTC (rev 231817)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-05-15 23:06:28 UTC (rev 231818)
@@ -1586,8 +1586,13 @@
 #endif
 
     if (changed & ActivityState::IsVisible) {
-        if (isViewVisible())
+        if (isViewVisible()) {
             m_visiblePageToken = m_process->visiblePageToken();
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+            if (m_displayLink)
+                m_displayLink->resume();
+#endif
+        }
         else {
             m_visiblePageToken = nullptr;
 
@@ -1595,6 +1600,10 @@
             // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we
             // stop the unresponsiveness timer here.
             m_process->responsivenessTimer().stop();
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+            if (m_displayLink)
+                m_displayLink->pause();
+#endif
         }
     }
 

Modified: trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp (231817 => 231818)


--- trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2018-05-15 23:01:14 UTC (rev 231817)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2018-05-15 23:06:28 UTC (rev 231818)
@@ -81,6 +81,20 @@
     return !m_observers.isEmpty();
 }
 
+void DisplayLink::pause()
+{
+    if (!CVDisplayLinkIsRunning(m_displayLink))
+        return;
+    CVDisplayLinkStop(m_displayLink);
+}
+
+void DisplayLink::resume()
+{
+    if (CVDisplayLinkIsRunning(m_displayLink))
+        return;
+    CVDisplayLinkStart(m_displayLink);
+}
+
 CVReturn DisplayLink::displayLinkCallback(CVDisplayLinkRef displayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data)
 {
     WebPageProxy* webPageProxy = reinterpret_cast<WebPageProxy*>(data);

Modified: trunk/Source/WebKit/UIProcess/mac/DisplayLink.h (231817 => 231818)


--- trunk/Source/WebKit/UIProcess/mac/DisplayLink.h	2018-05-15 23:01:14 UTC (rev 231817)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayLink.h	2018-05-15 23:06:28 UTC (rev 231818)
@@ -45,6 +45,9 @@
     void removeObserver(unsigned observerID);
     bool hasObservers() const;
 
+    void pause();
+    void resume();
+    
 private:
     static CVReturn displayLinkCallback(CVDisplayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data);
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to