Title: [275640] trunk/Source/WebKit
Revision
275640
Author
[email protected]
Date
2021-04-07 15:55:54 -0700 (Wed, 07 Apr 2021)

Log Message

[WebXR] Introduce XRDeviceIdentifier and XRDeviceInfo to be used to communicate device info
https://bugs.webkit.org/show_bug.cgi?id=224239

Patch by Ada Chan <[email protected]> on 2021-04-07
Reviewed by Tim Horton.

These classes are codable so they can be used in messages across UI/web process boundary.
In a future patch, these classes will be used to create device objects returned from
WebChromeClient::enumerateImmersiveXRDevices().

* Shared/Cocoa/XRDeviceIdentifier.h: Added.
This codable type will be used to identify a device.
* Shared/Cocoa/XRDeviceInfo.h: Added.
* Shared/Cocoa/XRDeviceInfo.mm: Added.
(WebKit::XRDeviceInfo::encode const):
(WebKit::XRDeviceInfo::decode):
* Shared/WebCoreArgumentCoders.h:
Add EnumTraits for PlatformXR::ReferenceSpaceType so we can encode it.
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (275639 => 275640)


--- trunk/Source/WebKit/ChangeLog	2021-04-07 22:46:13 UTC (rev 275639)
+++ trunk/Source/WebKit/ChangeLog	2021-04-07 22:55:54 UTC (rev 275640)
@@ -1,3 +1,25 @@
+2021-04-07  Ada Chan  <[email protected]>
+
+        [WebXR] Introduce XRDeviceIdentifier and XRDeviceInfo to be used to communicate device info
+        https://bugs.webkit.org/show_bug.cgi?id=224239
+
+        Reviewed by Tim Horton.
+
+        These classes are codable so they can be used in messages across UI/web process boundary.
+        In a future patch, these classes will be used to create device objects returned from
+        WebChromeClient::enumerateImmersiveXRDevices().
+
+        * Shared/Cocoa/XRDeviceIdentifier.h: Added.
+        This codable type will be used to identify a device.
+        * Shared/Cocoa/XRDeviceInfo.h: Added.
+        * Shared/Cocoa/XRDeviceInfo.mm: Added.
+        (WebKit::XRDeviceInfo::encode const):
+        (WebKit::XRDeviceInfo::decode):
+        * Shared/WebCoreArgumentCoders.h:
+        Add EnumTraits for PlatformXR::ReferenceSpaceType so we can encode it.
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2021-04-07  Michael Catanzaro  <[email protected]>
 
         [GTK] webkit://gpu should print runtime libwpe and wpebackend-fdo versions

Added: trunk/Source/WebKit/Shared/Cocoa/XRDeviceIdentifier.h (0 => 275640)


--- trunk/Source/WebKit/Shared/Cocoa/XRDeviceIdentifier.h	                        (rev 0)
+++ trunk/Source/WebKit/Shared/Cocoa/XRDeviceIdentifier.h	2021-04-07 22:55:54 UTC (rev 275640)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 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 ENABLE(WEBXR)
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebKit {
+
+enum XRDeviceIdentifierType { };
+using XRDeviceIdentifier = ObjectIdentifier<XRDeviceIdentifierType>;
+
+}
+
+#endif // ENABLE(WEBXR)

Added: trunk/Source/WebKit/Shared/Cocoa/XRDeviceInfo.h (0 => 275640)


--- trunk/Source/WebKit/Shared/Cocoa/XRDeviceInfo.h	                        (rev 0)
+++ trunk/Source/WebKit/Shared/Cocoa/XRDeviceInfo.h	2021-04-07 22:55:54 UTC (rev 275640)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 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 ENABLE(WEBXR)
+
+#include "XRDeviceIdentifier.h"
+#include <WebCore/PlatformXR.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+struct XRDeviceInfo {
+    XRDeviceIdentifier identifier;
+    bool supportsOrientationTracking { false };
+    bool supportsStereoRendering { false };
+    PlatformXR::Device::FeatureList features;
+
+    void encode(IPC::Encoder&) const;
+    static Optional<XRDeviceInfo> decode(IPC::Decoder&);
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WEBXR)

Added: trunk/Source/WebKit/Shared/Cocoa/XRDeviceInfo.mm (0 => 275640)


--- trunk/Source/WebKit/Shared/Cocoa/XRDeviceInfo.mm	                        (rev 0)
+++ trunk/Source/WebKit/Shared/Cocoa/XRDeviceInfo.mm	2021-04-07 22:55:54 UTC (rev 275640)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#import "config.h"
+#import "XRDeviceInfo.h"
+
+#if ENABLE(WEBXR)
+
+#import "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+void XRDeviceInfo::encode(IPC::Encoder& encoder) const
+{
+    encoder << identifier << supportsOrientationTracking << supportsStereoRendering << features;
+}
+
+Optional<XRDeviceInfo> XRDeviceInfo::decode(IPC::Decoder& decoder)
+{
+    XRDeviceInfo deviceFeatures;
+    if (!decoder.decode(deviceFeatures.identifier))
+        return WTF::nullopt;
+
+    if (!decoder.decode(deviceFeatures.supportsOrientationTracking))
+        return WTF::nullopt;
+
+    if (!decoder.decode(deviceFeatures.supportsStereoRendering))
+        return WTF::nullopt;
+
+    if (!decoder.decode(deviceFeatures.features))
+        return WTF::nullopt;
+
+    return deviceFeatures;
+}
+
+}
+
+#endif // ENABLE(WEBXR)

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (275639 => 275640)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2021-04-07 22:46:13 UTC (rev 275639)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2021-04-07 22:55:54 UTC (rev 275640)
@@ -74,6 +74,10 @@
 #include <WebCore/GraphicsTypesGL.h>
 #endif
 
+#if ENABLE(WEBXR)
+#include <WebCore/PlatformXR.h>
+#endif
+
 #if PLATFORM(COCOA)
 namespace WTF {
 class MachSendRight;
@@ -1035,4 +1039,19 @@
 };
 #endif
 
+#if ENABLE(WEBXR)
+
+template<> struct EnumTraits<PlatformXR::ReferenceSpaceType> {
+    using values = EnumValues<
+        PlatformXR::ReferenceSpaceType,
+        PlatformXR::ReferenceSpaceType::Viewer,
+        PlatformXR::ReferenceSpaceType::Local,
+        PlatformXR::ReferenceSpaceType::LocalFloor,
+        PlatformXR::ReferenceSpaceType::BoundedFloor,
+        PlatformXR::ReferenceSpaceType::Unbounded
+    >;
+};
+
+#endif
+
 } // namespace WTF

Modified: trunk/Source/WebKit/SourcesCocoa.txt (275639 => 275640)


--- trunk/Source/WebKit/SourcesCocoa.txt	2021-04-07 22:46:13 UTC (rev 275639)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2021-04-07 22:55:54 UTC (rev 275640)
@@ -180,6 +180,7 @@
 Shared/Cocoa/WKNSURLRequest.mm
 Shared/Cocoa/WKObject.mm
 Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm
+Shared/Cocoa/XRDeviceInfo.mm
 
 Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm
 Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (275639 => 275640)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-04-07 22:46:13 UTC (rev 275639)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-04-07 22:55:54 UTC (rev 275640)
@@ -1096,6 +1096,9 @@
 		51FAEC3A1B0657630009C4E7 /* AuxiliaryProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FAEC371B0657310009C4E7 /* AuxiliaryProcessMessages.h */; };
 		51FAEC3B1B0657680009C4E7 /* AuxiliaryProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FAEC361B0657310009C4E7 /* AuxiliaryProcessMessageReceiver.cpp */; };
 		51FD18B61651FBAD00DBE1CE /* NetworkResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FD18B41651FBAD00DBE1CE /* NetworkResourceLoader.h */; };
+		525080B0261BDE6C00678AEE /* XRDeviceInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 525080AD261BDE6B00678AEE /* XRDeviceInfo.mm */; };
+		525080B1261BDE6C00678AEE /* XRDeviceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 525080AE261BDE6B00678AEE /* XRDeviceIdentifier.h */; };
+		525080B2261BDE6C00678AEE /* XRDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 525080AF261BDE6C00678AEE /* XRDeviceInfo.h */; };
 		5272D4C91E735F0900EB4290 /* WKProtectionSpaceNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 5272D4C71E735F0900EB4290 /* WKProtectionSpaceNS.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		528C37C1195CBB1A00D8B9CC /* WKBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9F28101958F478008CAC72 /* WKBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		52D5A1B01C57495A00DE34A3 /* VideoFullscreenManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A1AA1C57494E00DE34A3 /* VideoFullscreenManagerProxy.h */; };
@@ -4152,6 +4155,9 @@
 		51FB0902163A3B1C00EC324A /* NetworkProcessConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = NetworkProcessConnection.messages.in; path = Network/NetworkProcessConnection.messages.in; sourceTree = "<group>"; };
 		51FD18B31651FBAD00DBE1CE /* NetworkResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkResourceLoader.cpp; sourceTree = "<group>"; };
 		51FD18B41651FBAD00DBE1CE /* NetworkResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkResourceLoader.h; sourceTree = "<group>"; };
+		525080AD261BDE6B00678AEE /* XRDeviceInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = XRDeviceInfo.mm; sourceTree = "<group>"; };
+		525080AE261BDE6B00678AEE /* XRDeviceIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XRDeviceIdentifier.h; sourceTree = "<group>"; };
+		525080AF261BDE6C00678AEE /* XRDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XRDeviceInfo.h; sourceTree = "<group>"; };
 		5272D4C71E735F0900EB4290 /* WKProtectionSpaceNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKProtectionSpaceNS.h; path = mac/WKProtectionSpaceNS.h; sourceTree = "<group>"; };
 		5272D4C81E735F0900EB4290 /* WKProtectionSpaceNS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKProtectionSpaceNS.mm; path = mac/WKProtectionSpaceNS.mm; sourceTree = "<group>"; };
 		52D5A1AA1C57494E00DE34A3 /* VideoFullscreenManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenManagerProxy.h; sourceTree = "<group>"; };
@@ -6070,10 +6076,10 @@
 				5742A2F72535613F00B7BA14 /* com.apple.WebKit.WebAuthn.xpc */,
 				372EBB462017E64300085064 /* com.apple.WebKit.WebContent.Development.xpc */,
 				BC3DE46615A91763008D26FC /* com.apple.WebKit.WebContent.xpc */,
+				CD95493526159004008372D9 /* libWebKitSwift.dylib */,
 				A16E66002581930800EE1749 /* MediaFormatReader.bundle */,
 				1AC25FB012A48EA700BD2671 /* PluginProcessShim.dylib */,
 				8DC2EF5B0486A6940098B216 /* WebKit.framework */,
-				CD95493526159004008372D9 /* libWebKitSwift.dylib */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -8240,6 +8246,9 @@
 				C14D306524B794E700480387 /* XPCEndpoint.mm */,
 				C14D306824B794E700480387 /* XPCEndpointClient.h */,
 				C14D306624B794E700480387 /* XPCEndpointClient.mm */,
+				525080AE261BDE6B00678AEE /* XRDeviceIdentifier.h */,
+				525080AF261BDE6C00678AEE /* XRDeviceInfo.h */,
+				525080AD261BDE6B00678AEE /* XRDeviceInfo.mm */,
 			);
 			name = cocoa;
 			path = Cocoa;
@@ -12956,6 +12965,8 @@
 				C15E6CB324B7BE6F00E501A2 /* XPCEndpoint.h in Headers */,
 				C15E6CB424B7BE7600E501A2 /* XPCEndpointClient.h in Headers */,
 				BCBECDE816B6416800047A1A /* XPCServiceEntryPoint.h in Headers */,
+				525080B1261BDE6C00678AEE /* XRDeviceIdentifier.h in Headers */,
+				525080B2261BDE6C00678AEE /* XRDeviceInfo.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -14425,6 +14436,7 @@
 				CE212160240EE571006ED443 /* WKTextPlaceholder.mm in Sources */,
 				C14D306924B79BE000480387 /* XPCEndpoint.mm in Sources */,
 				C14D306A24B79BE400480387 /* XPCEndpointClient.mm in Sources */,
+				525080B0261BDE6C00678AEE /* XRDeviceInfo.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to