Diff
Modified: trunk/Source/WTF/wtf/PlatformHave.h (295521 => 295522)
--- trunk/Source/WTF/wtf/PlatformHave.h 2022-06-14 14:10:51 UTC (rev 295521)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2022-06-14 14:53:44 UTC (rev 295522)
@@ -353,6 +353,13 @@
#define HAVE_TASK_IDENTITY_TOKEN 1
#endif
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000) \
+ || ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000) \
+ || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MAX_ALLOWED >= 90000) \
+ || (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 160000)
+#define HAVE_CG_CONTEXT_SET_OWNER_IDENTITY 1
+#endif
+
#if PLATFORM(MAC)
#define HAVE_NS_ACTIVITY 1
#endif
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (295521 => 295522)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2022-06-14 14:10:51 UTC (rev 295521)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2022-06-14 14:53:44 UTC (rev 295522)
@@ -76,6 +76,8 @@
57F1C90A25DCF0CF00E8F6EA /* CryptoKitPrivateSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F1C90825DCF0CF00E8F6EA /* CryptoKitPrivateSoftLink.mm */; };
57FD318A22B3593E008D0E8B /* AppSSOSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57FD318922B3593E008D0E8B /* AppSSOSoftLink.mm */; };
5C7C787423AC3E770065F47E /* ManagedConfigurationSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */; };
+ 7B47F2A328587B9700E793C8 /* CoreGraphicsSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B47F2A128587B9700E793C8 /* CoreGraphicsSoftLink.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7B47F2A428587B9700E793C8 /* CoreGraphicsSoftLink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B47F2A228587B9700E793C8 /* CoreGraphicsSoftLink.cpp */; };
93B38EC025821CD800198E63 /* SpeechSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B38EBF25821CD700198E63 /* SpeechSoftLink.mm */; };
A10826FA1F576292004772AC /* WebPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10826F81F576292004772AC /* WebPanel.mm */; };
A1175B4F1F6B337300C4B9F0 /* PopupMenu.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1175B4D1F6B337300C4B9F0 /* PopupMenu.mm */; };
@@ -885,6 +887,8 @@
71B1141F26823ACD004D6701 /* SystemPreviewSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemPreviewSPI.h; sourceTree = "<group>"; };
7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; };
7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSImageSPI.h; sourceTree = "<group>"; };
+ 7B47F2A128587B9700E793C8 /* CoreGraphicsSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreGraphicsSoftLink.h; sourceTree = "<group>"; };
+ 7B47F2A228587B9700E793C8 /* CoreGraphicsSoftLink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoreGraphicsSoftLink.cpp; sourceTree = "<group>"; };
93468E662714A7CD009983E3 /* FilePortSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePortSPI.h; sourceTree = "<group>"; };
93B38EBD25821CB600198E63 /* SpeechSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeechSoftLink.h; sourceTree = "<group>"; };
93B38EBF25821CD700198E63 /* SpeechSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SpeechSoftLink.mm; sourceTree = "<group>"; };
@@ -1204,6 +1208,7 @@
children = (
0C00CFCC1F68CE2300AAC26D /* avfoundation */,
0CF99CA51F73841C007EE793 /* cf */,
+ 7B47F2A528587D6100E793C8 /* cg */,
1C4876DE1F8D831300CCEEBD /* cocoa */,
1C09D0511E31C41200725F18 /* crypto */,
1CC5E3C12737457D006F6FF4 /* graphics */,
@@ -1535,6 +1540,15 @@
path = mac;
sourceTree = "<group>";
};
+ 7B47F2A528587D6100E793C8 /* cg */ = {
+ isa = PBXGroup;
+ children = (
+ 7B47F2A228587B9700E793C8 /* CoreGraphicsSoftLink.cpp */,
+ 7B47F2A128587B9700E793C8 /* CoreGraphicsSoftLink.h */,
+ );
+ path = cg;
+ sourceTree = "<group>";
+ };
A30D411D1F0DD0AC00B71954 /* text */ = {
isa = PBXGroup;
children = (
@@ -1669,6 +1683,7 @@
DD20DDE027BC90D70093D175 /* CommonCryptoSPI.h in Headers */,
DD20DE6527BC90F90093D175 /* config.h in Headers */,
DD20DDCE27BC90D70093D175 /* CoreAudioSPI.h in Headers */,
+ 7B47F2A328587B9700E793C8 /* CoreGraphicsSoftLink.h in Headers */,
DD20DDD327BC90D70093D175 /* CoreGraphicsSPI.h in Headers */,
DD20DD1627BC90D60093D175 /* CoreMediaSoftLink.h in Headers */,
DD20DDCF27BC90D70093D175 /* CoreMediaSPI.h in Headers */,
@@ -2085,6 +2100,7 @@
416E995323DAE6BE00E871CB /* AudioToolboxSoftLink.cpp in Sources */,
077E87B1226A460200A2AFF0 /* AVFoundationSoftLink.mm in Sources */,
1D2B413425F05E3500A3F70A /* ClockGeneric.cpp in Sources */,
+ 7B47F2A428587B9700E793C8 /* CoreGraphicsSoftLink.cpp in Sources */,
0CF99CA81F738437007EE793 /* CoreMediaSoftLink.cpp in Sources */,
F47221F4276FC2EB00B984C7 /* CoreMLSoftLink.mm in Sources */,
1C77C8C925D7972000635E0C /* CoreTextSoftLink.cpp in Sources */,
Modified: trunk/Source/WebCore/PAL/pal/PlatformMac.cmake (295521 => 295522)
--- trunk/Source/WebCore/PAL/pal/PlatformMac.cmake 2022-06-14 14:10:51 UTC (rev 295521)
+++ trunk/Source/WebCore/PAL/pal/PlatformMac.cmake 2022-06-14 14:53:44 UTC (rev 295522)
@@ -9,6 +9,8 @@
cf/OTSVGTable.h
cf/VideoToolboxSoftLink.h
+ cg/CoreGraphicsSoftLink.h
+
cocoa/AppSSOSoftLink.h
cocoa/AVFoundationSoftLink.h
cocoa/CoreMLSoftLink.h
@@ -159,6 +161,8 @@
cf/OTSVGTable.cpp
cf/VideoToolboxSoftLink.cpp
+ cg/CoreGraphicsSoftLink.cpp
+
cocoa/AppSSOSoftLink.mm
cocoa/AVFoundationSoftLink.mm
cocoa/CoreMLSoftLink.mm
Added: trunk/Source/WebCore/PAL/pal/cg/CoreGraphicsSoftLink.cpp (0 => 295522)
--- trunk/Source/WebCore/PAL/pal/cg/CoreGraphicsSoftLink.cpp (rev 0)
+++ trunk/Source/WebCore/PAL/pal/cg/CoreGraphicsSoftLink.cpp 2022-06-14 14:53:44 UTC (rev 295522)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2022 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. AND ITS CONTRIBUTORS ``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 ITS 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"
+
+#if USE(CG)
+
+#include <pal/spi/cg/CoreGraphicsSPI.h>
+#include <wtf/SoftLinking.h>
+
+#if HAVE(CG_CONTEXT_SET_OWNER_IDENTITY)
+#include <mach/mach_types.h>
+#endif
+
+SOFT_LINK_FRAMEWORK_FOR_SOURCE_WITH_EXPORT(PAL, CoreGraphics, PAL_EXPORT)
+
+#if HAVE(CG_CONTEXT_SET_OWNER_IDENTITY)
+SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreGraphics, CGContextSetOwnerIdentity, void, (CGContextRef context, task_id_token_t owner), (context, owner), PAL_EXPORT)
+#endif
+
+#endif
Added: trunk/Source/WebCore/PAL/pal/cg/CoreGraphicsSoftLink.h (0 => 295522)
--- trunk/Source/WebCore/PAL/pal/cg/CoreGraphicsSoftLink.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/cg/CoreGraphicsSoftLink.h 2022-06-14 14:53:44 UTC (rev 295522)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2022 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. AND ITS CONTRIBUTORS ``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 ITS 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 USE(CG)
+
+#include <pal/spi/cg/CoreGraphicsSPI.h>
+#include <wtf/SoftLinking.h>
+
+#if HAVE(CG_CONTEXT_SET_OWNER_IDENTITY)
+#include <mach/mach_types.h>
+#endif
+
+SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, CoreGraphics)
+
+#if HAVE(CG_CONTEXT_SET_OWNER_IDENTITY)
+SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreGraphics, CGContextSetOwnerIdentity, void, (CGContextRef context, task_id_token_t owner), (context, owner))
+#define CGContextSetOwnerIdentity PAL::softLink_CoreGraphics_CGContextSetOwnerIdentity
+#endif
+
+#endif
Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (295521 => 295522)
--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2022-06-14 14:10:51 UTC (rev 295521)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2022-06-14 14:53:44 UTC (rev 295522)
@@ -29,6 +29,7 @@
#include "DestinationColorSpace.h"
#include "IntSize.h"
+#include "ProcessIdentity.h"
#include <objc/objc.h>
#include <pal/spi/cocoa/IOSurfaceSPI.h>
@@ -46,7 +47,6 @@
class GraphicsContext;
class HostWindow;
class IOSurfacePool;
-class ProcessIdentity;
enum class PixelFormat : uint8_t;
enum class SetNonVolatileResult : uint8_t;
@@ -172,6 +172,7 @@
IntSize m_size;
size_t m_totalBytes;
+ ProcessIdentity m_resourceOwner;
std::unique_ptr<GraphicsContext> m_graphicsContext;
RetainPtr<CGContextRef> m_cgContext;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (295521 => 295522)
--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2022-06-14 14:10:51 UTC (rev 295521)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2022-06-14 14:53:44 UTC (rev 295522)
@@ -40,6 +40,7 @@
#import <wtf/text/TextStream.h>
#import "CoreVideoSoftLink.h"
+#import <pal/cg/CoreGraphicsSoftLink.h>
namespace WebCore {
@@ -348,7 +349,10 @@
#else
UNUSED_PARAM(hostWindow);
#endif
-
+#if HAVE(CG_CONTEXT_SET_OWNER_IDENTITY)
+ if (m_resourceOwner && CGContextSetOwnerIdentity)
+ CGContextSetOwnerIdentity(m_cgContext.get(), m_resourceOwner.taskIdToken());
+#endif
return m_cgContext.get();
}
@@ -504,7 +508,13 @@
void IOSurface::setOwnershipIdentity(const ProcessIdentity& resourceOwner)
{
+ ASSERT(resourceOwner);
+ m_resourceOwner = resourceOwner;
setOwnershipIdentity(m_surface.get(), resourceOwner);
+#if HAVE(CG_CONTEXT_SET_OWNER_IDENTITY)
+ if (m_cgContext && CGContextSetOwnerIdentity)
+ CGContextSetOwnerIdentity(m_cgContext.get(), m_resourceOwner.taskIdToken());
+#endif
}
void IOSurface::setOwnershipIdentity(IOSurfaceRef surface, const ProcessIdentity& resourceOwner)