Title: [278789] trunk/Source/WebCore
- Revision
- 278789
- Author
- ifernan...@igalia.com
- Date
- 2021-06-11 16:21:14 -0700 (Fri, 11 Jun 2021)
Log Message
Implement Encode/Decode templates for WebXR InputSources
https://bugs.webkit.org/show_bug.cgi?id=226923
Reviewed by Sam Weinig.
Process WebXR InputSources in PlatformXR FrameData Encode/Decode templates.
Tested by WebXR WPT.
* platform/xr/PlatformXR.h:
(PlatformXR::Device::FrameData::InputSourceButton::encode const):
(PlatformXR::Device::FrameData::InputSourceButton::decode):
(PlatformXR::Device::FrameData::InputSourcePose::encode const):
(PlatformXR::Device::FrameData::InputSourcePose::decode):
(PlatformXR::Device::FrameData::InputSource::encode const):
(PlatformXR::Device::FrameData::InputSource::decode):
(PlatformXR::Device::FrameData::encode const):
(PlatformXR::Device::FrameData::decode):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (278788 => 278789)
--- trunk/Source/WebCore/ChangeLog 2021-06-11 23:13:05 UTC (rev 278788)
+++ trunk/Source/WebCore/ChangeLog 2021-06-11 23:21:14 UTC (rev 278789)
@@ -1,3 +1,24 @@
+2021-06-11 Imanol Fernandez <ifernan...@igalia.com>
+
+ Implement Encode/Decode templates for WebXR InputSources
+ https://bugs.webkit.org/show_bug.cgi?id=226923
+
+ Reviewed by Sam Weinig.
+
+ Process WebXR InputSources in PlatformXR FrameData Encode/Decode templates.
+
+ Tested by WebXR WPT.
+
+ * platform/xr/PlatformXR.h:
+ (PlatformXR::Device::FrameData::InputSourceButton::encode const):
+ (PlatformXR::Device::FrameData::InputSourceButton::decode):
+ (PlatformXR::Device::FrameData::InputSourcePose::encode const):
+ (PlatformXR::Device::FrameData::InputSourcePose::decode):
+ (PlatformXR::Device::FrameData::InputSource::encode const):
+ (PlatformXR::Device::FrameData::InputSource::decode):
+ (PlatformXR::Device::FrameData::encode const):
+ (PlatformXR::Device::FrameData::decode):
+
2021-06-11 Chris Dumez <cdu...@apple.com>
Enable more release logging in WebCore for ephemeral sessions
Modified: trunk/Source/WebCore/platform/xr/PlatformXR.h (278788 => 278789)
--- trunk/Source/WebCore/platform/xr/PlatformXR.h 2021-06-11 23:13:05 UTC (rev 278788)
+++ trunk/Source/WebCore/platform/xr/PlatformXR.h 2021-06-11 23:21:14 UTC (rev 278789)
@@ -185,11 +185,17 @@
bool touched { false };
bool pressed { false };
float pressedValue { 0 };
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<InputSourceButton> decode(Decoder&);
};
struct InputSourcePose {
Pose pose;
bool isPositionEmulated { false };
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<InputSourcePose> decode(Decoder&);
};
struct InputSource {
@@ -201,6 +207,9 @@
std::optional<InputSourcePose> gripOrigin;
Vector<InputSourceButton> buttons;
Vector<float> axes;
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<InputSource> decode(Decoder&);
};
bool isTrackingValid { false };
@@ -455,6 +464,82 @@
}
template<class Encoder>
+void Device::FrameData::InputSourceButton::encode(Encoder& encoder) const
+{
+ encoder << touched;
+ encoder << pressed;
+ encoder << pressedValue;
+}
+
+template<class Decoder>
+std::optional<Device::FrameData::InputSourceButton> Device::FrameData::InputSourceButton::decode(Decoder& decoder)
+{
+ PlatformXR::Device::FrameData::InputSourceButton button;
+ if (!decoder.decode(button.touched))
+ return std::nullopt;
+ if (!decoder.decode(button.pressed))
+ return std::nullopt;
+ if (!decoder.decode(button.pressedValue))
+ return std::nullopt;
+ return button;
+}
+
+template<class Encoder>
+void Device::FrameData::InputSourcePose::encode(Encoder& encoder) const
+{
+ encoder << pose;
+ encoder << isPositionEmulated;
+}
+
+template<class Decoder>
+std::optional<Device::FrameData::InputSourcePose> Device::FrameData::InputSourcePose::decode(Decoder& decoder)
+{
+ PlatformXR::Device::FrameData::InputSourcePose inputSourcePose;
+ if (!decoder.decode(inputSourcePose.pose))
+ return std::nullopt;
+ if (!decoder.decode(inputSourcePose.isPositionEmulated))
+ return std::nullopt;
+ return inputSourcePose;
+}
+
+template<class Encoder>
+void Device::FrameData::InputSource::encode(Encoder& encoder) const
+{
+ encoder << handle;
+ encoder << handeness;
+ encoder << targetRayMode;
+ encoder << profiles;
+ encoder << pointerOrigin;
+ encoder << gripOrigin;
+ encoder << buttons;
+ encoder << axes;
+}
+
+template<class Decoder>
+std::optional<Device::FrameData::InputSource> Device::FrameData::InputSource::decode(Decoder& decoder)
+{
+ PlatformXR::Device::FrameData::InputSource source;
+ if (!decoder.decode(source.handle))
+ return std::nullopt;
+ if (!decoder.decode(source.handeness))
+ return std::nullopt;
+ if (!decoder.decode(source.targetRayMode))
+ return std::nullopt;
+ if (!decoder.decode(source.profiles))
+ return std::nullopt;
+ if (!decoder.decode(source.pointerOrigin))
+ return std::nullopt;
+ if (!decoder.decode(source.gripOrigin))
+ return std::nullopt;
+ if (!decoder.decode(source.buttons))
+ return std::nullopt;
+ if (!decoder.decode(source.axes))
+ return std::nullopt;
+ return source;
+}
+
+
+template<class Encoder>
void Device::FrameData::encode(Encoder& encoder) const
{
encoder << isTrackingValid;
@@ -467,6 +552,7 @@
encoder << stageParameters;
encoder << views;
encoder << layers;
+ encoder << inputSources;
}
template<class Decoder>
@@ -493,7 +579,10 @@
return std::nullopt;
if (!decoder.decode(frameData.layers))
return std::nullopt;
+ if (!decoder.decode(frameData.inputSources))
+ return std::nullopt;
+
return frameData;
}
@@ -532,6 +621,24 @@
>;
};
+template<> struct EnumTraits<PlatformXR::XRHandedness> {
+ using values = EnumValues<
+ PlatformXR::XRHandedness,
+ PlatformXR::XRHandedness::None,
+ PlatformXR::XRHandedness::Left,
+ PlatformXR::XRHandedness::Right
+ >;
+};
+
+template<> struct EnumTraits<PlatformXR::XRTargetRayMode> {
+ using values = EnumValues<
+ PlatformXR::XRTargetRayMode,
+ PlatformXR::XRTargetRayMode::Gaze,
+ PlatformXR::XRTargetRayMode::TrackedPointer,
+ PlatformXR::XRTargetRayMode::Screen
+ >;
+};
+
}
#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes