/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
for (uint32_t i = 0; i < tmp->mFrameRequestCallbacks.Length(); ++i) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mFrameRequestCallbacks[i]");
cb.NoteXPCOMChild(tmp->mFrameRequestCallbacks[i].mCallback);
}
bool XRSession::IsImmersive() const { // Only immersive sessions have a VRDisplayClient return mDisplayClient != nullptr;
}
XRVisibilityState XRSession::VisibilityState() const { return XRVisibilityState::Visible; // TODO (Bug 1609771): Implement changing visibility state
}
// https://immersive-web.github.io/webxr/#poses-may-be-reported // Given that an XRSession cannot be requested without explicit consent // by the user, the only necessary check is whether the XRSession's // visiblityState is 'visible'. bool XRSession::CanReportPoses() const { return VisibilityState() == XRVisibilityState::Visible;
}
// https://immersive-web.github.io/webxr/#dom-xrsession-updaterenderstate void XRSession::UpdateRenderState(const XRRenderStateInit& aNewState,
ErrorResult& aRv) { if (mEnded) {
aRv.ThrowInvalidStateError( "UpdateRenderState can not be called on an XRSession that has ended."); return;
} if (aNewState.mBaseLayer.WasPassed() &&
aNewState.mBaseLayer.Value()->mSession != this) {
aRv.ThrowInvalidStateError( "The baseLayer passed in to UpdateRenderState must " "belong to the XRSession that UpdateRenderState is " "being called on."); return;
} if (aNewState.mInlineVerticalFieldOfView.WasPassed() && IsImmersive()) {
aRv.ThrowInvalidStateError( "The inlineVerticalFieldOfView can not be set on an " "XRRenderState for an immersive XRSession."); return;
} if (mPendingRenderState == nullptr) {
mPendingRenderState = new XRRenderState(*mActiveRenderState);
} if (aNewState.mDepthNear.WasPassed()) {
mPendingRenderState->SetDepthNear(aNewState.mDepthNear.Value());
} if (aNewState.mDepthFar.WasPassed()) {
mPendingRenderState->SetDepthFar(aNewState.mDepthFar.Value());
} if (aNewState.mInlineVerticalFieldOfView.WasPassed()) {
mPendingRenderState->SetInlineVerticalFieldOfView(
aNewState.mInlineVerticalFieldOfView.Value());
} if (aNewState.mBaseLayer.WasPassed()) {
mPendingRenderState->SetBaseLayer(aNewState.mBaseLayer.Value());
}
}
if (!mActiveRenderState->GetInlineVerticalFieldOfView().IsNull()) { double verticalFOV =
mActiveRenderState->GetInlineVerticalFieldOfView().Value(); if (verticalFOV < kMinimumInlineVerticalFieldOfView) {
verticalFOV = kMinimumInlineVerticalFieldOfView;
} if (verticalFOV > kMaximumInlineVerticalFieldOfView) {
verticalFOV = kMaximumInlineVerticalFieldOfView;
}
mActiveRenderState->SetInlineVerticalFieldOfView(verticalFOV);
}
// Our minimum near plane value is set to a small value close but not equal to // zero (kEpsilon) The maximum far plane is infinite. constfloat kEpsilon = 0.00001f; double depthNear = mActiveRenderState->DepthNear(); double depthFar = mActiveRenderState->DepthFar(); if (depthNear < 0.0f) {
depthNear = 0.0f;
} if (depthFar < 0.0f) {
depthFar = 0.0f;
} // Ensure at least a small distance between the near and far planes if (fabs(depthFar - depthNear) < kEpsilon) {
depthFar = depthNear + kEpsilon;
}
mActiveRenderState->SetDepthNear(depthNear);
mActiveRenderState->SetDepthFar(depthFar);
XRWebGLLayer* baseLayer = mActiveRenderState->GetBaseLayer(); if (baseLayer) { if (!IsImmersive() && baseLayer->mCompositionDisabled) {
mActiveRenderState->SetCompositionDisabled(true);
mActiveRenderState->SetOutputCanvas(baseLayer->GetCanvas());
} else {
mActiveRenderState->SetCompositionDisabled(false);
mActiveRenderState->SetOutputCanvas(nullptr);
mDisplayPresentation->UpdateXRWebGLLayer(baseLayer);
}
} // if (baseLayer)
}
void XRSession::WillRefresh(mozilla::TimeStamp aTime) { // Inline sessions are driven by nsRefreshDriver directly, // unlike immersive sessions, which are driven VRDisplayClient. if (!IsImmersive() && !mXRSystem->HasActiveImmersiveSession()) { if (nsIGlobalObject* global = GetOwnerGlobal()) { if (JSObject* obj = global->GetGlobalJSObject()) {
js::NotifyAnimationActivity(obj);
}
}
StartFrame();
}
}
if (!mEnabledReferenceSpaceTypes.Contains(aReferenceSpaceType)) {
promise->MaybeRejectWithNotSupportedError(nsLiteralCString( "Requested XRReferenceSpaceType not available for the XRSession.")); return promise.forget();
}
RefPtr<XRReferenceSpace> space;
RefPtr<XRNativeOrigin> nativeOrigin; if (mDisplayClient) { switch (aReferenceSpaceType) { case XRReferenceSpaceType::Viewer:
nativeOrigin = new XRNativeOriginViewer(mDisplayClient); break; case XRReferenceSpaceType::Local:
nativeOrigin = new XRNativeOriginLocal(mDisplayClient); break; case XRReferenceSpaceType::Local_floor: case XRReferenceSpaceType::Bounded_floor:
nativeOrigin = new XRNativeOriginLocalFloor(mDisplayClient); break; default:
nativeOrigin = new XRNativeOriginFixed(gfx::PointDouble3D()); break;
}
} else { // We currently only support XRReferenceSpaceType::Viewer when // there is no XR hardware. In this case, the native origin // will always be at {0, 0, 0} which will always be the same // as the 'tracked' position of the non-existant pose.
MOZ_ASSERT(aReferenceSpaceType == XRReferenceSpaceType::Viewer);
nativeOrigin = new XRNativeOriginFixed(gfx::PointDouble3D());
} if (aReferenceSpaceType == XRReferenceSpaceType::Bounded_floor) {
space = new XRBoundedReferenceSpace(GetParentObject(), this, nativeOrigin);
} else {
space = new XRReferenceSpace(GetParentObject(), this, nativeOrigin,
aReferenceSpaceType);
}
if (mEnded) {
promise->MaybeRejectWithInvalidStateError( "UpdateTargetFrameRate can not be called on an XRSession that has " "ended."); return promise.forget();
}
// https://immersive-web.github.io/webxr/#dom-xrsession-updatetargetframerate // TODO: Validate the rate with the frame rates supported from the device. // We add a no op for now to avoid JS exceptions related to undefined method. // The spec states that user agent MAY use rate to calculate a new display // frame rate, so it's fine to let the default frame rate for now.
void XRSession::LastRelease() { // We don't want to wait for the GC to free up the presentation // for use in other documents, so we do this in LastRelease().
Shutdown();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.