Bug 1250244 - Part 6: Replace VRStateValidFlags with VRDisplayCapabilityFlags,r=gw280

MozReview-Commit-ID: 2D4isWasWMz
This commit is contained in:
Kearwood (Kip) Gilbert 2016-04-18 12:12:33 -07:00
Родитель 0fa828c884
Коммит 0fa5a8cb30
5 изменённых файлов: 63 добавлений и 31 удалений

Просмотреть файл

@ -47,10 +47,10 @@ VRDisplay::UpdateVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDevices, nsISupports*
}
if (isNewDevice) {
gfx::VRStateValidFlags sensorBits = proxyDevice->GetDeviceInfo().GetSupportedSensorStateBits();
gfx::VRDisplayCapabilityFlags flags = proxyDevice->GetDeviceInfo().GetCapabilities();
devices.AppendElement(new HMDInfoVRDisplay(aParent, proxyDevice));
if (sensorBits & (gfx::VRStateValidFlags::State_Position |
gfx::VRStateValidFlags::State_Orientation))
if (flags & (gfx::VRDisplayCapabilityFlags::Cap_Position |
gfx::VRDisplayCapabilityFlags::Cap_Orientation))
{
devices.AppendElement(new HMDPositionVRDisplay(aParent, proxyDevice));
}
@ -176,11 +176,11 @@ VRPositionState::VRPositionState(nsISupports* aParent, const gfx::VRHMDSensorSta
{
mTimeStamp = aState.timestamp;
if (aState.flags & gfx::VRStateValidFlags::State_Position) {
if (aState.flags & gfx::VRDisplayCapabilityFlags::Cap_Position) {
mPosition = new DOMPoint(mParent, aState.position[0], aState.position[1], aState.position[2], 0.0);
}
if (aState.flags & gfx::VRStateValidFlags::State_Orientation) {
if (aState.flags & gfx::VRDisplayCapabilityFlags::Cap_Orientation) {
mOrientation = new DOMPoint(mParent, aState.orientation[0], aState.orientation[1], aState.orientation[2], aState.orientation[3]);
}
}

Просмотреть файл

@ -31,14 +31,39 @@ enum class VRHMDType : uint16_t {
NumHMDTypes
};
enum class VRStateValidFlags : uint16_t {
State_None = 0,
State_Position = 1 << 1,
State_Orientation = 1 << 2,
// State_All used for validity checking during IPC serialization
State_All = (1 << 3) - 1
enum class VRDisplayCapabilityFlags : uint16_t {
Cap_None = 0,
/**
* Cap_Position is set if the VRDisplay is capable of tracking its position.
*/
Cap_Position = 1 << 1,
/**
* Cap_Orientation is set if the VRDisplay is capable of tracking its orientation.
*/
Cap_Orientation = 1 << 2,
/**
* Cap_Present is set if the VRDisplay is capable of presenting content to an
* HMD or similar device. Can be used to indicate "magic window" devices that
* are capable of 6DoF tracking but for which requestPresent is not meaningful.
* If false then calls to requestPresent should always fail, and
* getEyeParameters should return null.
*/
Cap_Present = 1 << 3,
/**
* Cap_External is set if the VRDisplay is separate from the device's
* primary display. If presenting VR content will obscure
* other content on the device, this should be un-set. When
* un-set, the application should not attempt to mirror VR content
* or update non-VR UI because that content will not be visible.
*/
Cap_External = 1 << 4,
/**
* Cap_All used for validity checking during IPC serialization
*/
Cap_All = (1 << 5) - 1
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VRStateValidFlags)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VRDisplayCapabilityFlags)
struct VRFieldOfView {
VRFieldOfView() {}
@ -93,7 +118,7 @@ struct VRDisplayInfo
VRHMDType GetType() const { return mType; }
uint32_t GetDeviceID() const { return mDeviceID; }
const nsCString& GetDeviceName() const { return mDeviceName; }
VRStateValidFlags GetSupportedSensorStateBits() const { return mSupportedSensorBits; }
VRDisplayCapabilityFlags GetCapabilities() const { return mCapabilityFlags; }
const VRFieldOfView& GetRecommendedEyeFOV(uint32_t whichEye) const { return mRecommendedEyeFOV[whichEye]; }
const VRFieldOfView& GetMaximumEyeFOV(uint32_t whichEye) const { return mMaximumEyeFOV[whichEye]; }
@ -111,7 +136,7 @@ struct VRDisplayInfo
uint32_t mDeviceID;
VRHMDType mType;
nsCString mDeviceName;
VRStateValidFlags mSupportedSensorBits;
VRDisplayCapabilityFlags mCapabilityFlags;
VRFieldOfView mMaximumEyeFOV[VRDisplayInfo::NumEyes];
VRFieldOfView mRecommendedEyeFOV[VRDisplayInfo::NumEyes];
VRFieldOfView mEyeFOV[VRDisplayInfo::NumEyes];
@ -132,7 +157,7 @@ struct VRDisplayInfo
return mType == other.mType &&
mDeviceID == other.mDeviceID &&
mDeviceName == other.mDeviceName &&
mSupportedSensorBits == other.mSupportedSensorBits &&
mCapabilityFlags == other.mCapabilityFlags &&
mEyeResolution == other.mEyeResolution &&
mScreenRect == other.mScreenRect &&
mIsFakeScreen == other.mIsFakeScreen &&
@ -158,7 +183,7 @@ struct VRDisplayInfo
struct VRHMDSensorState {
double timestamp;
int32_t inputFrameID;
VRStateValidFlags flags;
VRDisplayCapabilityFlags flags;
float orientation[4];
float position[3];
float angularVelocity[3];

Просмотреть файл

@ -212,9 +212,12 @@ HMDInfoOSVR::HMDInfoOSVR(OSVR_ClientContext* context,
MOZ_COUNT_CTOR_INHERITED(HMDInfoOSVR, VRHMDInfo);
mDeviceInfo.mDeviceName.AssignLiteral("OSVR HMD");
mDeviceInfo.mSupportedSensorBits = VRStateValidFlags::State_None;
mDeviceInfo.mSupportedSensorBits =
VRStateValidFlags::State_Orientation | VRStateValidFlags::State_Position;
mDeviceInfo.mCapabilityFlags = VRDisplayCapabilityFlags::Cap_None;
mDeviceInfo.mCapabilityFlags =
VRDisplayCapabilityFlags::Cap_Orientation | VRDisplayCapabilityFlags::Cap_Position;
mDeviceInfo.mCapabilityFlags |= VRDisplayCapabilityFlags::Cap_External;
mDeviceInfo.mCapabilityFlags |= VRDisplayCapabilityFlags::Cap_Present;
// XXX OSVR display topology allows for more than one viewer
// will assume only one viewer for now (most likely stay that way)
@ -337,7 +340,7 @@ HMDInfoOSVR::GetSensorState()
result.timestamp = timestamp.seconds;
if (ret == OSVR_RETURN_SUCCESS) {
result.flags |= VRStateValidFlags::State_Orientation;
result.flags |= VRDisplayCapabilityFlags::Cap_Orientation;
result.orientation[0] = orientation.data[1];
result.orientation[1] = orientation.data[2];
result.orientation[2] = orientation.data[3];
@ -347,7 +350,7 @@ HMDInfoOSVR::GetSensorState()
OSVR_PositionState position;
ret = osvr_GetPositionState(*m_iface, &timestamp, &position);
if (ret == OSVR_RETURN_SUCCESS) {
result.flags |= VRStateValidFlags::State_Position;
result.flags |= VRDisplayCapabilityFlags::Cap_Position;
result.position[0] = position.data[0];
result.position[1] = position.data[1];
result.position[2] = position.data[2];

Просмотреть файл

@ -306,13 +306,15 @@ HMDInfoOculus::HMDInfoOculus(ovrSession aSession)
mDesc = ovr_GetHmdDesc(aSession);
mDeviceInfo.mSupportedSensorBits = VRStateValidFlags::State_None;
mDeviceInfo.mCapabilityFlags = VRDisplayCapabilityFlags::Cap_None;
if (mDesc.AvailableTrackingCaps & ovrTrackingCap_Orientation) {
mDeviceInfo.mSupportedSensorBits |= VRStateValidFlags::State_Orientation;
mDeviceInfo.mCapabilityFlags |= VRDisplayCapabilityFlags::Cap_Orientation;
}
if (mDesc.AvailableTrackingCaps & ovrTrackingCap_Position) {
mDeviceInfo.mSupportedSensorBits |= VRStateValidFlags::State_Position;
mDeviceInfo.mCapabilityFlags |= VRDisplayCapabilityFlags::Cap_Position;
}
mDeviceInfo.mCapabilityFlags |= VRDisplayCapabilityFlags::Cap_External;
mDeviceInfo.mCapabilityFlags |= VRDisplayCapabilityFlags::Cap_Present;
mDeviceInfo.mRecommendedEyeFOV[VRDisplayInfo::Eye_Left] = FromFovPort(mDesc.DefaultEyeFov[ovrEye_Left]);
mDeviceInfo.mRecommendedEyeFOV[VRDisplayInfo::Eye_Right] = FromFovPort(mDesc.DefaultEyeFov[ovrEye_Right]);
@ -440,7 +442,7 @@ HMDInfoOculus::GetSensorState(double timeOffset)
result.timestamp = pose.TimeInSeconds;
if (state.StatusFlags & ovrStatus_OrientationTracked) {
result.flags |= VRStateValidFlags::State_Orientation;
result.flags |= VRDisplayCapabilityFlags::Cap_Orientation;
result.orientation[0] = pose.ThePose.Orientation.x;
result.orientation[1] = pose.ThePose.Orientation.y;
@ -457,7 +459,7 @@ HMDInfoOculus::GetSensorState(double timeOffset)
}
if (state.StatusFlags & ovrStatus_PositionTracked) {
result.flags |= VRStateValidFlags::State_Position;
result.flags |= VRDisplayCapabilityFlags::Cap_Position;
result.position[0] = pose.ThePose.Position.x;
result.position[1] = pose.ThePose.Position.y;
@ -471,6 +473,8 @@ HMDInfoOculus::GetSensorState(double timeOffset)
result.linearAcceleration[1] = pose.LinearAcceleration.y;
result.linearAcceleration[2] = pose.LinearAcceleration.z;
}
result.flags |= VRDisplayCapabilityFlags::Cap_External;
result.flags |= VRDisplayCapabilityFlags::Cap_Present;
return result;
}

Просмотреть файл

@ -22,9 +22,9 @@ struct ParamTraits<mozilla::gfx::VRHMDType> :
mozilla::gfx::VRHMDType(mozilla::gfx::VRHMDType::NumHMDTypes)> {};
template<>
struct ParamTraits<mozilla::gfx::VRStateValidFlags> :
public BitFlagsEnumSerializer<mozilla::gfx::VRStateValidFlags,
mozilla::gfx::VRStateValidFlags::State_All> {};
struct ParamTraits<mozilla::gfx::VRDisplayCapabilityFlags> :
public BitFlagsEnumSerializer<mozilla::gfx::VRDisplayCapabilityFlags,
mozilla::gfx::VRDisplayCapabilityFlags::Cap_All> {};
template <>
struct ParamTraits<mozilla::gfx::VRDisplayUpdate>
@ -78,7 +78,7 @@ struct ParamTraits<mozilla::gfx::VRDisplayInfo>
WriteParam(aMsg, aParam.mType);
WriteParam(aMsg, aParam.mDeviceID);
WriteParam(aMsg, aParam.mDeviceName);
WriteParam(aMsg, aParam.mSupportedSensorBits);
WriteParam(aMsg, aParam.mCapabilityFlags);
WriteParam(aMsg, aParam.mEyeResolution);
WriteParam(aMsg, aParam.mScreenRect);
WriteParam(aMsg, aParam.mIsFakeScreen);
@ -96,7 +96,7 @@ struct ParamTraits<mozilla::gfx::VRDisplayInfo>
if (!ReadParam(aMsg, aIter, &(aResult->mType)) ||
!ReadParam(aMsg, aIter, &(aResult->mDeviceID)) ||
!ReadParam(aMsg, aIter, &(aResult->mDeviceName)) ||
!ReadParam(aMsg, aIter, &(aResult->mSupportedSensorBits)) ||
!ReadParam(aMsg, aIter, &(aResult->mCapabilityFlags)) ||
!ReadParam(aMsg, aIter, &(aResult->mEyeResolution)) ||
!ReadParam(aMsg, aIter, &(aResult->mScreenRect)) ||
!ReadParam(aMsg, aIter, &(aResult->mIsFakeScreen))) {