Title: [188700] trunk/Source/WebCore
Revision
188700
Author
[email protected]
Date
2015-08-20 14:19:13 -0700 (Thu, 20 Aug 2015)

Log Message

Stop using cancelCallOnMainThread in DisplayRefreshMonitorMac
https://bugs.webkit.org/show_bug.cgi?id=148241

Reviewed by Tim Horton.

Create a WeakPtrFactory in DisplayRefreshMonitorMac and bind a WeakPtr in the function passed
to callOnMainThread so we can check if the DisplayRefreshMonitorMac has gone away.

* platform/graphics/mac/DisplayRefreshMonitorMac.cpp:
(WebCore::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
(WebCore::DisplayRefreshMonitorMac::displayLinkFired):
(WebCore::DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac):
* platform/graphics/mac/DisplayRefreshMonitorMac.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (188699 => 188700)


--- trunk/Source/WebCore/ChangeLog	2015-08-20 21:09:19 UTC (rev 188699)
+++ trunk/Source/WebCore/ChangeLog	2015-08-20 21:19:13 UTC (rev 188700)
@@ -1,3 +1,19 @@
+2015-08-20  Anders Carlsson  <[email protected]>
+
+        Stop using cancelCallOnMainThread in DisplayRefreshMonitorMac
+        https://bugs.webkit.org/show_bug.cgi?id=148241
+
+        Reviewed by Tim Horton.
+
+        Create a WeakPtrFactory in DisplayRefreshMonitorMac and bind a WeakPtr in the function passed
+        to callOnMainThread so we can check if the DisplayRefreshMonitorMac has gone away.
+
+        * platform/graphics/mac/DisplayRefreshMonitorMac.cpp:
+        (WebCore::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
+        (WebCore::DisplayRefreshMonitorMac::displayLinkFired):
+        (WebCore::DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac):
+        * platform/graphics/mac/DisplayRefreshMonitorMac.h:
+
 2015-08-20  Alex Christensen  <[email protected]>
 
         AppleWin CMake build fix after r188696.

Modified: trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp (188699 => 188700)


--- trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp	2015-08-20 21:09:19 UTC (rev 188699)
+++ trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp	2015-08-20 21:19:13 UTC (rev 188700)
@@ -36,6 +36,7 @@
 
 DisplayRefreshMonitorMac::DisplayRefreshMonitorMac(PlatformDisplayID displayID)
     : DisplayRefreshMonitor(displayID)
+    , m_weakFactory(this)
     , m_displayLink(nullptr)
 {
 }
@@ -47,8 +48,6 @@
         CVDisplayLinkRelease(m_displayLink);
         m_displayLink = nullptr;
     }
-
-    cancelCallOnMainThread(DisplayRefreshMonitor::handleDisplayRefreshedNotificationOnMainThread, this);
 }
 
 static CVReturn displayLinkCallback(CVDisplayLinkRef, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags, CVOptionFlags*, void* data)
@@ -102,7 +101,12 @@
     // FIXME: Should this be using webKitMonotonicNow?
     setMonotonicAnimationStartTime(webKitMonotonicNow + timeUntilOutput);
 
-    callOnMainThread(handleDisplayRefreshedNotificationOnMainThread, this);
+    auto weakPtr = m_weakFactory.createWeakPtr();
+
+    callOnMainThread([weakPtr] {
+        if (auto* monitor = weakPtr.get())
+            handleDisplayRefreshedNotificationOnMainThread(monitor);
+    });
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h (188699 => 188700)


--- trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h	2015-08-20 21:09:19 UTC (rev 188699)
+++ trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h	2015-08-20 21:19:13 UTC (rev 188700)
@@ -29,6 +29,7 @@
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
 
 #include "DisplayRefreshMonitor.h"
+#include <wtf/WeakPtr.h>
 
 typedef struct __CVDisplayLink *CVDisplayLinkRef;
 
@@ -48,6 +49,8 @@
 
 private:
     explicit DisplayRefreshMonitorMac(PlatformDisplayID);
+
+    WeakPtrFactory<DisplayRefreshMonitorMac> m_weakFactory;
     CVDisplayLinkRef m_displayLink;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to