VRMessageUtils.h (3543B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_gfx_vr_VRMessageUtils_h 8 #define mozilla_gfx_vr_VRMessageUtils_h 9 10 #include "ipc/EnumSerializer.h" 11 #include "ipc/IPCMessageUtils.h" 12 #include "mozilla/GfxMessageUtils.h" 13 #include "mozilla/dom/GamepadMessageUtils.h" 14 #include "mozilla/ParamTraits_IsEnumCase.h" 15 #include "mozilla/ParamTraits_STL.h" 16 #include "mozilla/ParamTraits_TiedFields.h" 17 18 #include "gfxVR.h" 19 20 namespace IPC { 21 22 template <> 23 struct ParamTraits<mozilla::gfx::VRHMDSensorState> final 24 : public ParamTraits_TiedFields<mozilla::gfx::VRHMDSensorState> {}; 25 template <> 26 struct ParamTraits<mozilla::gfx::VRDisplayInfo> final 27 : public ParamTraits_TiedFields<mozilla::gfx::VRDisplayInfo> {}; 28 template <> 29 struct ParamTraits<mozilla::gfx::VRDisplayState> final 30 : public ParamTraits_TiedFields<mozilla::gfx::VRDisplayState> {}; 31 template <> 32 struct ParamTraits<mozilla::gfx::VRControllerState> final 33 : public ParamTraits_TiedFields<mozilla::gfx::VRControllerState> {}; 34 template <> 35 struct ParamTraits<mozilla::gfx::VRFieldOfView> final 36 : public ParamTraits_TiedFields<mozilla::gfx::VRFieldOfView> {}; 37 template <> 38 struct ParamTraits<mozilla::gfx::Point3D_POD> final 39 : public ParamTraits_TiedFields<mozilla::gfx::Point3D_POD> {}; 40 template <> 41 struct ParamTraits<mozilla::gfx::IntSize_POD> final 42 : public ParamTraits_TiedFields<mozilla::gfx::IntSize_POD> {}; 43 template <> 44 struct ParamTraits<mozilla::gfx::FloatSize_POD> final 45 : public ParamTraits_TiedFields<mozilla::gfx::FloatSize_POD> {}; 46 template <> 47 struct ParamTraits<mozilla::gfx::VRPose> final 48 : public ParamTraits_TiedFields<mozilla::gfx::VRPose> {}; 49 50 // - 51 52 template <> 53 struct ParamTraits<mozilla::gfx::VRControllerType> 54 : ParamTraits_IsEnumCase<mozilla::gfx::VRControllerType> {}; 55 template <> 56 struct ParamTraits<mozilla::gfx::TargetRayMode> 57 : ParamTraits_IsEnumCase<mozilla::gfx::TargetRayMode> {}; 58 template <> 59 struct ParamTraits<mozilla::gfx::GamepadMappingType> 60 : ParamTraits_IsEnumCase<mozilla::gfx::GamepadMappingType> {}; 61 template <> 62 struct ParamTraits<mozilla::gfx::VRDisplayBlendMode> 63 : ParamTraits_IsEnumCase<mozilla::gfx::VRDisplayBlendMode> {}; 64 65 // - 66 67 template <> 68 struct ParamTraits<mozilla::gfx::VRSubmitFrameResultInfo> { 69 typedef mozilla::gfx::VRSubmitFrameResultInfo paramType; 70 71 static void Write(MessageWriter* aWriter, const paramType& aParam) { 72 WriteParam(aWriter, aParam.mBase64Image); 73 WriteParam(aWriter, aParam.mFormat); 74 WriteParam(aWriter, aParam.mWidth); 75 WriteParam(aWriter, aParam.mHeight); 76 WriteParam(aWriter, aParam.mFrameNum); 77 } 78 79 static bool Read(MessageReader* aReader, paramType* aResult) { 80 if (!ReadParam(aReader, &(aResult->mBase64Image)) || 81 !ReadParam(aReader, &(aResult->mFormat)) || 82 !ReadParam(aReader, &(aResult->mWidth)) || 83 !ReadParam(aReader, &(aResult->mHeight)) || 84 !ReadParam(aReader, &(aResult->mFrameNum))) { 85 return false; 86 } 87 88 return true; 89 } 90 }; 91 92 template <> 93 struct ParamTraits<mozilla::gfx::VRDisplayCapabilityFlags> 94 : public BitFlagsEnumSerializer< 95 mozilla::gfx::VRDisplayCapabilityFlags, 96 mozilla::gfx::VRDisplayCapabilityFlags::Cap_All> {}; 97 98 } // namespace IPC 99 100 #endif // mozilla_gfx_vr_VRMessageUtils_h