Skip to content

Commit

Permalink
[InteractionRegions] Remove the RSS soft link and move to an SPI header
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259556
<rdar://105775731>

Reviewed by Tim Horton.

Introduce a new RealitySystemSupport SPI for visionOS.

* Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h:
Clean-up the previous (outdated) definitions.

* Source/WebKit/Configurations/WebKit.xcconfig:
Link against RealitySystemSupport on visionOS.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/Platform/spi/visionos/RealitySystemSupportSPI.h: Added.
Add new SPI header.

* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeInteractionRegionLayers.mm:
(WebKit::interactionRegionLayerClass):
(WebKit::interactionRegionEffectUserInfo):
Remove the RSS soft link and use the new SPI header instead.
(WebKit::configureLayerForInteractionRegion):
Remove the unused `LayerSizeMultiplier` user default.
Cast to `RCPGlowEffectLayer` to set the effect group configurator.

Canonical link: https://commits.webkit.org/266363@main
  • Loading branch information
etiennesegonzac committed Jul 27, 2023
1 parent 4232eab commit 5cc3d39
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 47 deletions.
8 changes: 0 additions & 8 deletions Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@
#import <QuartzCore/CAFenceHandle.h>
#endif

#if PLATFORM(VISION)
#import <QuartzCore/CARemoteEffectPrivate.h>
#endif

#endif // __OBJC__

#else
Expand Down Expand Up @@ -157,10 +153,6 @@ typedef struct _CARenderContext CARenderContext;
@property (getter=isSeparated) BOOL separated;
#endif
@property BOOL toneMapToStandardDynamicRange;
#if PLATFORM(VISION)
@property (nonatomic) CGFloat sizeMultiplier;
@property (nonatomic, copy) void (^effectGroupConfigurator)(CARemoteEffectGroup *group);
#endif
@end

#if ENABLE(FILTERS_LEVEL_2)
Expand Down
7 changes: 6 additions & 1 deletion Source/WebKit/Configurations/WebKit.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ WK_NETWORK_EXTENSION_LDFLAGS_watchsimulator = -framework NetworkExtension;
WK_NETWORK_EXTENSION_LDFLAGS_maccatalyst = -framework NetworkExtension;
WK_NETWORK_EXTENSION_LDFLAGS_macosx = -weak_framework NetworkExtension;

// Using PLATFORM_NAME since WK_PLATFORM_NAME folds visionOS to iOS.
WK_REALITYSYSTEMSUPPORT_LDFLAGS = $(WK_REALITYSYSTEMSUPPORT_LDFLAGS_$(PLATFORM_NAME));
WK_REALITYSYSTEMSUPPORT_LDFLAGS_xros = -framework RealitySystemSupport;
WK_REALITYSYSTEMSUPPORT_LDFLAGS_xrsimulator = -framework RealitySystemSupport;

FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork -framework Metal $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_APPLE_PUSH_SERVICE_LDFLAGS) $(WK_BACKBOARD_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CONTACTS_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBNETWORKEXTENSION_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_PROTOTYPE_TOOLS_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS) $(WK_COORDINATOR_LDFLAGS) $(WK_INSTALL_COORDINATION_LDFLAGS) $(WK_APP_STORE_DAEMON_LDFLAGS) $(WK_POWERLOG_LDFLAGS) $(WK_FRONTBOARDSERVICES_LDFLAGS) $(WK_LIBBSM_LDFLAGS) $(WK_NETWORK_EXTENSION_LDFLAGS);

// Prevent C++ standard library basic_stringstream, operator new, delete and their related exception types from being exported as weak symbols.
Expand All @@ -205,7 +210,7 @@ WK_NO_STATIC_INITIALIZERS_Release_NO_ = $(WK_ERROR_WHEN_LINKING_WITH_STATIC_INIT
WK_NO_STATIC_INITIALIZERS_Production__ = $(WK_ERROR_WHEN_LINKING_WITH_STATIC_INITIALIZERS);
WK_NO_STATIC_INITIALIZERS_Production_NO_ = $(WK_ERROR_WHEN_LINKING_WITH_STATIC_INITIALIZERS);

OTHER_LDFLAGS = $(inherited) -iframework $(SDK_DIR)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks $(UNEXPORTED_SYMBOL_LDFLAGS) $(FRAMEWORK_AND_LIBRARY_LDFLAGS) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) $(SOURCE_VERSION_LDFLAGS) $(PROFILE_GENERATE_OR_USE_LDFLAGS) $(WK_NO_STATIC_INITIALIZERS);
OTHER_LDFLAGS = $(inherited) -iframework $(SDK_DIR)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks $(UNEXPORTED_SYMBOL_LDFLAGS) $(FRAMEWORK_AND_LIBRARY_LDFLAGS) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) $(SOURCE_VERSION_LDFLAGS) $(WK_REALITYSYSTEMSUPPORT_LDFLAGS) $(PROFILE_GENERATE_OR_USE_LDFLAGS) $(WK_NO_STATIC_INITIALIZERS);

REEXPORTED_FRAMEWORK_NAMES = WebKitLegacy;
REEXPORTED_FRAMEWORK_NAMES[sdk=macosx*] = $(inherited) WebCore;
Expand Down
60 changes: 60 additions & 0 deletions Source/WebKit/Platform/spi/visionos/RealitySystemSupportSPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2023 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.
*/

#if PLATFORM(VISION)

#if USE(APPLE_INTERNAL_SDK)

#import <RealitySystemSupport/RealitySystemSupport.h>

#else

@interface CALayer ()
@property (copy, nullable) NSArray<CARemoteEffect *> *remoteEffects;
@end

@interface RCPGLowEffectLayer : CALayer
@property (nonatomic, copy) void (^effectGroupConfigurator)(CARemoteEffectGroup *group);
@end

@interface CARemoteEffect ()
@end

@interface CARemoteEffectGroup ()
+ (instancetype)groupWithEffects:(NSArray<CARemoteEffect *> *)effects;
@property (copy, nullable) NSString *groupName;
@property (getter=isMatched) BOOL matched;
@end

typedef NS_OPTIONS(NSUInteger, RCPRemoteEffectInputTypes) {
RCPRemoteEffectInputTypePointer = 1 << 2,
RCPRemoteEffectInputTypesAll = ~0ul
};

NSString * const RCPAllowedInputTypesUserInfoKey = @"RCPAllowedInputTypesUserInfoKey";

#endif // USE(APPLE_INTERNAL_SDK)

#endif // PLATFORM(VISION)
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,11 @@

#import "PlatformCALayerRemote.h"
#import "RemoteLayerTreeHost.h"
#import <QuartzCore/QuartzCore.h>
#import <pal/spi/cocoa/QuartzCoreSPI.h>
#import <wtf/SoftLinking.h>

#if PLATFORM(VISION)
#import <RealitySystemSupport/RealitySystemSupport.h>
#import "RealitySystemSupportSPI.h"
#endif

//// FIXME: rdar://105775731
SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(RealitySystemSupport)
SOFT_LINK_CLASS_OPTIONAL(RealitySystemSupport, RCPGlowEffectLayer)
#if PLATFORM(VISION)
SOFT_LINK_CONSTANT_MAY_FAIL(RealitySystemSupport, RCPAllowedInputTypesUserInfoKey, const NSString *)
#endif

@interface CALayer ()
@property (nonatomic) CGFloat sizeMultiplier;
#if PLATFORM(VISION)
@property (nonatomic, copy) void (^effectGroupConfigurator)(CARemoteEffectGroup *group);
#endif
@end

namespace WebKit {
using namespace WebCore;

Expand All @@ -61,39 +44,31 @@ @interface CALayer ()
#if PLATFORM(VISION)
static Class interactionRegionLayerClass()
{
if (getRCPGlowEffectLayerClass())
return getRCPGlowEffectLayerClass();
return [CALayer class];
return [RCPGlowEffectLayer class];
}

static NSDictionary *interactionRegionEffectUserInfo()
{
static NeverDestroyed<RetainPtr<NSDictionary>> interactionRegionEffectUserInfo;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (canLoadRCPAllowedInputTypesUserInfoKey()) {
RCPRemoteEffectInputTypes allowedInputs = RCPRemoteEffectInputTypesAll ^ RCPRemoteEffectInputTypePointer;
interactionRegionEffectUserInfo.get() = @{ getRCPAllowedInputTypesUserInfoKey(): @(allowedInputs) };
}
RCPRemoteEffectInputTypes allowedInputs = RCPRemoteEffectInputTypesAll ^ RCPRemoteEffectInputTypePointer;
interactionRegionEffectUserInfo.get() = @{ RCPAllowedInputTypesUserInfoKey: @(allowedInputs) };
});
return interactionRegionEffectUserInfo.get().get();
}

static void configureLayerForInteractionRegion(CALayer *layer, NSString *groupName)
{
if (auto multiplier = [[NSUserDefaults standardUserDefaults] floatForKey:@"WKInteractionRegionLayerSizeMultiplier"]) {
if ([layer respondsToSelector:@selector(setSizeMultiplier:)])
[layer setSizeMultiplier:multiplier];
}

if ([layer respondsToSelector:@selector(setEffectGroupConfigurator:)]) {
[layer setEffectGroupConfigurator:^void(CARemoteEffectGroup *group)
{
group.groupName = groupName;
group.matched = YES;
group.userInfo = interactionRegionEffectUserInfo();
}];
}
if (![layer isKindOfClass:[RCPGlowEffectLayer class]])
return;

[(RCPGlowEffectLayer *)layer setEffectGroupConfigurator:^void(CARemoteEffectGroup *group)
{
group.groupName = groupName;
group.matched = YES;
group.userInfo = interactionRegionEffectUserInfo();
}];
}

static void configureLayerAsGuard(CALayer *layer, NSString *groupName)
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/WebKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,7 @@
B6544F9F2939457C00034EB0 /* WebExtensionContextAPIEventCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = B6544F9E2939457C00034EB0 /* WebExtensionContextAPIEventCocoa.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
B65DA1D3294BC26300DB503A /* WebExtensionAPIPermissionsCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = B65DA1D2294BC26300DB503A /* WebExtensionAPIPermissionsCocoa.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
B65DA1DD294BDE4700DB503A /* WebExtensionContextAPIPermissionsCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = B65DA1DC294BDE4700DB503A /* WebExtensionContextAPIPermissionsCocoa.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
B65F5A2C2A727B7F00768DAE /* RealitySystemSupportSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = B65F5A2B2A727B7F00768DAE /* RealitySystemSupportSPI.h */; };
B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = B878B613133428DC006888E9 /* CorrectionPanel.h */; };
BC017D0716260FF4007054F5 /* WKDOMDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = BC017CFF16260FF4007054F5 /* WKDOMDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC017D0916260FF4007054F5 /* WKDOMElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC017D0116260FF4007054F5 /* WKDOMElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -6352,6 +6353,7 @@
B65DA1D1294BC25300DB503A /* WebExtensionAPIPermissions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebExtensionAPIPermissions.h; path = WebProcess/Extensions/API/WebExtensionAPIPermissions.h; sourceTree = SOURCE_ROOT; };
B65DA1D2294BC26300DB503A /* WebExtensionAPIPermissionsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebExtensionAPIPermissionsCocoa.mm; sourceTree = "<group>"; };
B65DA1DC294BDE4700DB503A /* WebExtensionContextAPIPermissionsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebExtensionContextAPIPermissionsCocoa.mm; sourceTree = "<group>"; };
B65F5A2B2A727B7F00768DAE /* RealitySystemSupportSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealitySystemSupportSPI.h; sourceTree = "<group>"; };
B878B613133428DC006888E9 /* CorrectionPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorrectionPanel.h; sourceTree = "<group>"; };
B878B614133428DC006888E9 /* CorrectionPanel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CorrectionPanel.mm; sourceTree = "<group>"; };
BC017CFF16260FF4007054F5 /* WKDOMDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDOMDocument.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -13924,6 +13926,7 @@
children = (
E539DFEA2A44A69100769F09 /* MRUIKitSPI.h */,
E539DFEC2A44A78600769F09 /* RealitySimulationServicesSPI.h */,
B65F5A2B2A727B7F00768DAE /* RealitySystemSupportSPI.h */,
);
path = visionos;
sourceTree = "<group>";
Expand Down Expand Up @@ -14618,6 +14621,7 @@
1AEE57252409F142002005D6 /* QuickLookThumbnailLoader.h in Headers */,
93B631F327ABAD8000443A44 /* QuotaIncreaseRequestIdentifier.h in Headers */,
E539DFED2A44A78600769F09 /* RealitySimulationServicesSPI.h in Headers */,
B65F5A2C2A727B7F00768DAE /* RealitySystemSupportSPI.h in Headers */,
5CB6AE442609799C00B6ED5A /* ReasonSPI.h in Headers */,
7BE9326327F5C75A00D5FEFB /* ReceiverMatcher.h in Headers */,
950FECF4285027200002DE4E /* RecurringPaymentRequest.h in Headers */,
Expand Down

0 comments on commit 5cc3d39

Please sign in to comment.