Title: [274755] trunk/Source/WebCore
Revision
274755
Author
[email protected]
Date
2021-03-22 11:25:00 -0700 (Mon, 22 Mar 2021)

Log Message

Rename WebCore's DisplayRefreshMonitorMac to indicate that it's only used in legacy WebKit
https://bugs.webkit.org/show_bug.cgi?id=223543

Reviewed by Tim Horton.

DisplayRefreshMonitorMac in WebCore is only used for WebKitLegacy; WebProcess doesn't have
WindowServer access so is unable to create CVDisplayLinkRefs.

Rename it to indicate this, and reduce confusion with DisplayRefreshMonitorMac in WebKit2.
Also add an assertion that LegacyDisplayRefreshMonitorMac is not being created in the
WebProcess.

For EmptyPageClients (like the Page used by createPageForSanitizingWebContent()) we need
a DisplayRefreshMonitor implementation that doesn't try to CVDisplayLinkRefs in the
Web Process, so add an EmptyDisplayRefreshMonitor that never fires.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* loader/EmptyClients.cpp:
(WebCore::EmptyDisplayRefreshMonitor::create):
(WebCore::EmptyDisplayRefreshMonitor::EmptyDisplayRefreshMonitor):
(WebCore::EmptyChromeClient::createDisplayRefreshMonitor const):
* loader/EmptyClients.h:
* platform/graphics/DisplayRefreshMonitor.cpp:
(WebCore::DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor):
* platform/graphics/mac/LegacyDisplayRefreshMonitorMac.cpp: Renamed from Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp.
(WebCore::LegacyDisplayRefreshMonitorMac::LegacyDisplayRefreshMonitorMac):
(WebCore::LegacyDisplayRefreshMonitorMac::~LegacyDisplayRefreshMonitorMac):
(WebCore::LegacyDisplayRefreshMonitorMac::stop):
(WebCore::displayLinkCallback):
(WebCore::LegacyDisplayRefreshMonitorMac::requestRefreshCallback):
(WebCore::LegacyDisplayRefreshMonitorMac::displayLinkFired):
* platform/graphics/mac/LegacyDisplayRefreshMonitorMac.h: Renamed from Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h.
(WebCore::LegacyDisplayRefreshMonitorMac::create):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274754 => 274755)


--- trunk/Source/WebCore/ChangeLog	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/ChangeLog	2021-03-22 18:25:00 UTC (rev 274755)
@@ -1,3 +1,40 @@
+2021-03-22  Simon Fraser  <[email protected]>
+
+        Rename WebCore's DisplayRefreshMonitorMac to indicate that it's only used in legacy WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=223543
+
+        Reviewed by Tim Horton.
+
+        DisplayRefreshMonitorMac in WebCore is only used for WebKitLegacy; WebProcess doesn't have
+        WindowServer access so is unable to create CVDisplayLinkRefs.
+
+        Rename it to indicate this, and reduce confusion with DisplayRefreshMonitorMac in WebKit2.
+        Also add an assertion that LegacyDisplayRefreshMonitorMac is not being created in the
+        WebProcess.
+
+        For EmptyPageClients (like the Page used by createPageForSanitizingWebContent()) we need
+        a DisplayRefreshMonitor implementation that doesn't try to CVDisplayLinkRefs in the
+        Web Process, so add an EmptyDisplayRefreshMonitor that never fires.
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/EmptyClients.cpp:
+        (WebCore::EmptyDisplayRefreshMonitor::create):
+        (WebCore::EmptyDisplayRefreshMonitor::EmptyDisplayRefreshMonitor):
+        (WebCore::EmptyChromeClient::createDisplayRefreshMonitor const):
+        * loader/EmptyClients.h:
+        * platform/graphics/DisplayRefreshMonitor.cpp:
+        (WebCore::DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor):
+        * platform/graphics/mac/LegacyDisplayRefreshMonitorMac.cpp: Renamed from Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp.
+        (WebCore::LegacyDisplayRefreshMonitorMac::LegacyDisplayRefreshMonitorMac):
+        (WebCore::LegacyDisplayRefreshMonitorMac::~LegacyDisplayRefreshMonitorMac):
+        (WebCore::LegacyDisplayRefreshMonitorMac::stop):
+        (WebCore::displayLinkCallback):
+        (WebCore::LegacyDisplayRefreshMonitorMac::requestRefreshCallback):
+        (WebCore::LegacyDisplayRefreshMonitorMac::displayLinkFired):
+        * platform/graphics/mac/LegacyDisplayRefreshMonitorMac.h: Renamed from Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h.
+        (WebCore::LegacyDisplayRefreshMonitorMac::create):
+
 2021-03-22  Myles C. Maxfield  <[email protected]>
 
         [GPU Process] Style: Remove unnecessary { }s from case statements in DisplayListItemBuffer.cpp

Modified: trunk/Source/WebCore/SourcesCocoa.txt (274754 => 274755)


--- trunk/Source/WebCore/SourcesCocoa.txt	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2021-03-22 18:25:00 UTC (rev 274755)
@@ -414,7 +414,6 @@
 platform/graphics/ios/IconIOS.mm
 platform/graphics/mac/ColorMac.mm
 platform/graphics/mac/ComplexTextControllerCoreText.mm
-platform/graphics/mac/DisplayRefreshMonitorMac.cpp
 platform/graphics/mac/FloatPointMac.mm
 platform/graphics/mac/FloatSizeMac.mm
 platform/graphics/mac/FontCustomPlatformData.cpp
@@ -423,6 +422,7 @@
 platform/graphics/mac/ImageMac.mm
 platform/graphics/mac/IntPointMac.mm
 platform/graphics/mac/IntSizeMac.mm
+platform/graphics/mac/LegacyDisplayRefreshMonitorMac.cpp
 platform/graphics/mac/PDFDocumentImageMac.mm
 platform/graphics/mac/SimpleFontDataCoreText.cpp
 platform/graphics/mac/SwitchingGPUClient.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (274754 => 274755)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-03-22 18:25:00 UTC (rev 274755)
@@ -845,7 +845,7 @@
 		2DAF343D1EA7E0F100382CD3 /* ConstantPropertyMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DAF343B1EA7E0F100382CD3 /* ConstantPropertyMap.h */; };
 		2DC8D39825F2FE9700CFCBAB /* Model.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DC8D39725F2FE9400CFCBAB /* Model.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2DD5A7271EBEE47D009BA597 /* CompositionUnderline.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD5A7261EBEE47D009BA597 /* CompositionUnderline.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		2DE70023192FE82A00B0975C /* DisplayRefreshMonitorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DE70022192FE82A00B0975C /* DisplayRefreshMonitorMac.h */; };
+		2DE70023192FE82A00B0975C /* LegacyDisplayRefreshMonitorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DE70022192FE82A00B0975C /* LegacyDisplayRefreshMonitorMac.h */; };
 		2DF512CE1D873E47001D6780 /* ReplaceRangeWithTextCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DF512CC1D873E47001D6780 /* ReplaceRangeWithTextCommand.h */; };
 		2DFA488F1DB541D000362B99 /* BufferSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DFA488E1DB541C200362B99 /* BufferSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E0888D31148848A00AF4265 /* JSDOMFormData.h */; };
@@ -7242,7 +7242,7 @@
 		2DC8D39625F2FE9300CFCBAB /* Model.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Model.cpp; sourceTree = "<group>"; };
 		2DC8D39725F2FE9400CFCBAB /* Model.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Model.h; sourceTree = "<group>"; };
 		2DD5A7261EBEE47D009BA597 /* CompositionUnderline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompositionUnderline.h; sourceTree = "<group>"; };
-		2DE70022192FE82A00B0975C /* DisplayRefreshMonitorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayRefreshMonitorMac.h; sourceTree = "<group>"; };
+		2DE70022192FE82A00B0975C /* LegacyDisplayRefreshMonitorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyDisplayRefreshMonitorMac.h; sourceTree = "<group>"; };
 		2DF512CB1D873E47001D6780 /* ReplaceRangeWithTextCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReplaceRangeWithTextCommand.cpp; sourceTree = "<group>"; };
 		2DF512CC1D873E47001D6780 /* ReplaceRangeWithTextCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReplaceRangeWithTextCommand.h; sourceTree = "<group>"; };
 		2DFA488E1DB541C200362B99 /* BufferSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BufferSource.h; sourceTree = "<group>"; };
@@ -8327,7 +8327,7 @@
 		49AE2D94134EE5F90072920A /* CalculationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CalculationValue.cpp; sourceTree = "<group>"; };
 		49AE2D95134EE5F90072920A /* CalculationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalculationValue.h; sourceTree = "<group>"; };
 		49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayRefreshMonitor.h; sourceTree = "<group>"; };
-		49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayRefreshMonitorMac.cpp; sourceTree = "<group>"; };
+		49AF2D6B14435D210016A784 /* LegacyDisplayRefreshMonitorMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyDisplayRefreshMonitorMac.cpp; sourceTree = "<group>"; };
 		49C7B9801042D2D30009D447 /* JSWebGLBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLBuffer.cpp; sourceTree = "<group>"; };
 		49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLBuffer.h; sourceTree = "<group>"; };
 		49C7B9841042D2D30009D447 /* JSWebGLFramebuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLFramebuffer.cpp; sourceTree = "<group>"; };
@@ -26633,8 +26633,6 @@
 				EDE3A4FF0C7A430600956A37 /* ColorMac.h */,
 				B275354A0B053814002CE64F /* ColorMac.mm */,
 				37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */,
-				49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */,
-				2DE70022192FE82A00B0975C /* DisplayRefreshMonitorMac.h */,
 				B275354B0B053814002CE64F /* FloatPointMac.mm */,
 				B275354D0B053814002CE64F /* FloatSizeMac.mm */,
 				B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */,
@@ -26645,6 +26643,8 @@
 				B275354E0B053814002CE64F /* ImageMac.mm */,
 				B275354F0B053814002CE64F /* IntPointMac.mm */,
 				B27535510B053814002CE64F /* IntSizeMac.mm */,
+				49AF2D6B14435D210016A784 /* LegacyDisplayRefreshMonitorMac.cpp */,
+				2DE70022192FE82A00B0975C /* LegacyDisplayRefreshMonitorMac.h */,
 				2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */,
 				7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */,
 				163E88F5118A39D200ED9231 /* SimpleFontDataCoreText.cpp */,
@@ -32044,7 +32044,6 @@
 				49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */,
 				2D29ECC6192ECC8300984B78 /* DisplayRefreshMonitorClient.h in Headers */,
 				2D29ECCA192F1F1D00984B78 /* DisplayRefreshMonitorIOS.h in Headers */,
-				2DE70023192FE82A00B0975C /* DisplayRefreshMonitorMac.h in Headers */,
 				2D29ECC8192ECC8300984B78 /* DisplayRefreshMonitorManager.h in Headers */,
 				0F790F432517CE6E009BA034 /* DisplayView.h in Headers */,
 				FD31609112B026F700C1A359 /* Distance.h in Headers */,
@@ -33757,6 +33756,7 @@
 				CDE8B5ED1A69777300B4B66A /* LegacyCDMPrivateClearKey.h in Headers */,
 				CDF4B7121E0087AE00E235A2 /* LegacyCDMSession.h in Headers */,
 				CDE8B5F11A69778B00B4B66A /* LegacyCDMSessionClearKey.h in Headers */,
+				2DE70023192FE82A00B0975C /* LegacyDisplayRefreshMonitorMac.h in Headers */,
 				F44A5F591FED38F2007F5944 /* LegacyNSPasteboardTypes.h in Headers */,
 				A185B42A1E8211A100DC9118 /* LegacyPreviewLoader.h in Headers */,
 				A10DBF4718F92317000D70C6 /* LegacyPreviewLoaderClient.h in Headers */,

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (274754 => 274755)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2021-03-22 18:25:00 UTC (rev 274755)
@@ -125,6 +125,25 @@
 
 #endif // ENABLE(CONTEXT_MENUS)
 
+
+class EmptyDisplayRefreshMonitor : public DisplayRefreshMonitor {
+public:
+    static Ref<EmptyDisplayRefreshMonitor> create(PlatformDisplayID displayID)
+    {
+        return adoptRef(*new EmptyDisplayRefreshMonitor(displayID));
+    }
+
+    void displayLinkFired() final { }
+    bool requestRefreshCallback() final { return false; }
+    void stop() final { }
+
+private:
+    explicit EmptyDisplayRefreshMonitor(PlatformDisplayID displayID)
+        : DisplayRefreshMonitor(displayID)
+    {
+    }
+};
+
 class EmptyDatabaseProvider final : public DatabaseProvider {
 #if ENABLE(INDEXED_DATABASE)
     struct EmptyIDBConnectionToServerDeletegate final : public IDBClient::IDBConnectionToServerDelegate {
@@ -511,6 +530,11 @@
 }
 #endif
 
+RefPtr<DisplayRefreshMonitor> EmptyChromeClient::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
+{
+    return EmptyDisplayRefreshMonitor::create(displayID);
+}
+
 void EmptyChromeClient::runOpenPanel(Frame&, FileChooser&)
 {
 }

Modified: trunk/Source/WebCore/loader/EmptyClients.h (274754 => 274755)


--- trunk/Source/WebCore/loader/EmptyClients.h	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2021-03-22 18:25:00 UTC (rev 274755)
@@ -149,6 +149,8 @@
     void storeAppHighlight(AppHighlight&&) const final;
 #endif
 
+    RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const final;
+
     void runOpenPanel(Frame&, FileChooser&) final;
     void showShareSheet(ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&) final;
     void loadIconForFiles(const Vector<String>&, FileIconLoader&) final { }

Modified: trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp (274754 => 274755)


--- trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp	2021-03-22 18:25:00 UTC (rev 274755)
@@ -33,7 +33,7 @@
 #if PLATFORM(IOS_FAMILY)
 #include "DisplayRefreshMonitorIOS.h"
 #elif PLATFORM(MAC)
-#include "DisplayRefreshMonitorMac.h"
+#include "LegacyDisplayRefreshMonitorMac.h"
 #elif PLATFORM(GTK)
 #include "DisplayRefreshMonitorGtk.h"
 #elif PLATFORM(WIN)
@@ -45,7 +45,7 @@
 RefPtr<DisplayRefreshMonitor> DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor(PlatformDisplayID displayID)
 {
 #if PLATFORM(MAC)
-    return DisplayRefreshMonitorMac::create(displayID);
+    return LegacyDisplayRefreshMonitorMac::create(displayID);
 #endif
 #if PLATFORM(IOS_FAMILY)
     return DisplayRefreshMonitorIOS::create(displayID);

Deleted: trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp (274754 => 274755)


--- trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp	2021-03-22 18:25:00 UTC (rev 274755)
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "config.h"
-#include "DisplayRefreshMonitorMac.h"
-
-#if PLATFORM(MAC)
-
-#include <QuartzCore/QuartzCore.h>
-#include <wtf/RunLoop.h>
-
-namespace WebCore {
-
-DisplayRefreshMonitorMac::DisplayRefreshMonitorMac(PlatformDisplayID displayID)
-    : DisplayRefreshMonitor(displayID)
-{
-}
-
-DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac()
-{
-    ASSERT(!m_displayLink);
-}
-
-void DisplayRefreshMonitorMac::stop()
-{
-    if (!m_displayLink)
-        return;
-
-    CVDisplayLinkStop(m_displayLink);
-    CVDisplayLinkRelease(m_displayLink);
-    m_displayLink = nullptr;
-}
-
-static CVReturn displayLinkCallback(CVDisplayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data)
-{
-    DisplayRefreshMonitorMac* monitor = static_cast<DisplayRefreshMonitorMac*>(data);
-    monitor->displayLinkFired();
-    return kCVReturnSuccess;
-}
-
-bool DisplayRefreshMonitorMac::requestRefreshCallback()
-{
-    if (!isActive())
-        return false;
-
-    if (!m_displayLink) {
-        setIsActive(false);
-        CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID(), &m_displayLink);
-        if (error)
-            return false;
-
-        error = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this);
-        if (error)
-            return false;
-
-        error = CVDisplayLinkStart(m_displayLink);
-        if (error)
-            return false;
-
-        setIsActive(true);
-    }
-
-    LockHolder lock(mutex());
-    setIsScheduled(true);
-    return true;
-}
-
-void DisplayRefreshMonitorMac::displayLinkFired()
-{
-    LockHolder lock(mutex());
-    if (!isPreviousFrameDone())
-        return;
-
-    setIsPreviousFrameDone(false);
-
-    RunLoop::main().dispatch([this, protectedThis = makeRef(*this)] {
-        if (m_displayLink)
-            handleDisplayRefreshedNotificationOnMainThread(this);
-    });
-}
-
-}
-
-#endif // PLATFORM(MAC)

Deleted: trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h (274754 => 274755)


--- trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h	2021-03-22 18:15:53 UTC (rev 274754)
+++ trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h	2021-03-22 18:25:00 UTC (rev 274755)
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#pragma once
-
-#if PLATFORM(MAC)
-
-#include "DisplayRefreshMonitor.h"
-#include <wtf/WeakPtr.h>
-
-typedef struct __CVDisplayLink *CVDisplayLinkRef;
-
-namespace WebCore {
-
-class DisplayRefreshMonitorMac : public DisplayRefreshMonitor {
-public:
-    static Ref<DisplayRefreshMonitorMac> create(PlatformDisplayID displayID)
-    {
-        return adoptRef(*new DisplayRefreshMonitorMac(displayID));
-    }
-    
-    virtual ~DisplayRefreshMonitorMac();
-
-    void displayLinkFired() final;
-    bool requestRefreshCallback() final;
-    void stop() final;
-
-private:
-    explicit DisplayRefreshMonitorMac(PlatformDisplayID);
-
-    CVDisplayLinkRef m_displayLink { nullptr };
-};
-
-}
-
-#endif // PLATFORM(MAC)

Copied: trunk/Source/WebCore/platform/graphics/mac/LegacyDisplayRefreshMonitorMac.cpp (from rev 274754, trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp) (0 => 274755)


--- trunk/Source/WebCore/platform/graphics/mac/LegacyDisplayRefreshMonitorMac.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/mac/LegacyDisplayRefreshMonitorMac.cpp	2021-03-22 18:25:00 UTC (rev 274755)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "LegacyDisplayRefreshMonitorMac.h"
+
+#if PLATFORM(MAC)
+
+#include "RuntimeApplicationChecks.h"
+#include <QuartzCore/QuartzCore.h>
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+LegacyDisplayRefreshMonitorMac::LegacyDisplayRefreshMonitorMac(PlatformDisplayID displayID)
+    : DisplayRefreshMonitor(displayID)
+{
+    ASSERT(!isInWebProcess());
+}
+
+LegacyDisplayRefreshMonitorMac::~LegacyDisplayRefreshMonitorMac()
+{
+    ASSERT(!m_displayLink);
+}
+
+void LegacyDisplayRefreshMonitorMac::stop()
+{
+    if (!m_displayLink)
+        return;
+
+    CVDisplayLinkStop(m_displayLink);
+    CVDisplayLinkRelease(m_displayLink);
+    m_displayLink = nullptr;
+}
+
+static CVReturn displayLinkCallback(CVDisplayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data)
+{
+    LegacyDisplayRefreshMonitorMac* monitor = static_cast<LegacyDisplayRefreshMonitorMac*>(data);
+    monitor->displayLinkFired();
+    return kCVReturnSuccess;
+}
+
+bool LegacyDisplayRefreshMonitorMac::requestRefreshCallback()
+{
+    if (!isActive())
+        return false;
+
+    if (!m_displayLink) {
+        setIsActive(false);
+        CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID(), &m_displayLink);
+        if (error)
+            return false;
+
+        error = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this);
+        if (error)
+            return false;
+
+        error = CVDisplayLinkStart(m_displayLink);
+        if (error)
+            return false;
+
+        setIsActive(true);
+    }
+
+    LockHolder lock(mutex());
+    setIsScheduled(true);
+    return true;
+}
+
+void LegacyDisplayRefreshMonitorMac::displayLinkFired()
+{
+    LockHolder lock(mutex());
+    if (!isPreviousFrameDone())
+        return;
+
+    setIsPreviousFrameDone(false);
+
+    RunLoop::main().dispatch([this, protectedThis = makeRef(*this)] {
+        if (m_displayLink)
+            handleDisplayRefreshedNotificationOnMainThread(this);
+    });
+}
+
+}
+
+#endif // PLATFORM(MAC)

Copied: trunk/Source/WebCore/platform/graphics/mac/LegacyDisplayRefreshMonitorMac.h (from rev 274754, trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h) (0 => 274755)


--- trunk/Source/WebCore/platform/graphics/mac/LegacyDisplayRefreshMonitorMac.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/mac/LegacyDisplayRefreshMonitorMac.h	2021-03-22 18:25:00 UTC (rev 274755)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#if PLATFORM(MAC)
+
+#include "DisplayRefreshMonitor.h"
+#include <wtf/WeakPtr.h>
+
+typedef struct __CVDisplayLink *CVDisplayLinkRef;
+
+namespace WebCore {
+
+class LegacyDisplayRefreshMonitorMac : public DisplayRefreshMonitor {
+public:
+    static Ref<LegacyDisplayRefreshMonitorMac> create(PlatformDisplayID displayID)
+    {
+        return adoptRef(*new LegacyDisplayRefreshMonitorMac(displayID));
+    }
+    
+    virtual ~LegacyDisplayRefreshMonitorMac();
+
+    void displayLinkFired() final;
+    bool requestRefreshCallback() final;
+    void stop() final;
+
+private:
+    explicit LegacyDisplayRefreshMonitorMac(PlatformDisplayID);
+
+    CVDisplayLinkRef m_displayLink { nullptr };
+};
+
+}
+
+#endif // PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to