Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / vr / XRRenderState.cpp
blobef5c4ba0e7f709b39583896eea8238141db26339
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/XRRenderState.h"
8 #include "VRLayerChild.h"
9 #include "nsIObserverService.h"
10 #include "nsISupportsPrimitives.h"
12 namespace mozilla::dom {
14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(XRRenderState, mParent, mSession,
15 mBaseLayer, mOutputCanvas)
17 XRRenderState::XRRenderState(nsISupports* aParent, XRSession* aSession)
18 : mParent(aParent),
19 mSession(aSession),
20 mDepthNear(0.1f),
21 mDepthFar(1000.0f),
22 mCompositionDisabled(false) {
23 if (!mSession->IsImmersive()) {
24 mInlineVerticalFieldOfView.SetValue(M_PI * 0.5f);
28 XRRenderState::XRRenderState(const XRRenderState& aOther)
29 : mParent(aOther.mParent),
30 mSession(aOther.mSession),
31 mBaseLayer(aOther.mBaseLayer),
32 mDepthNear(aOther.mDepthNear),
33 mDepthFar(aOther.mDepthFar),
34 mInlineVerticalFieldOfView(aOther.mInlineVerticalFieldOfView),
35 mOutputCanvas(aOther.mOutputCanvas),
36 mCompositionDisabled(aOther.mCompositionDisabled) {}
38 JSObject* XRRenderState::WrapObject(JSContext* aCx,
39 JS::Handle<JSObject*> aGivenProto) {
40 return XRRenderState_Binding::Wrap(aCx, this, aGivenProto);
43 double XRRenderState::DepthNear() { return mDepthNear; }
45 double XRRenderState::DepthFar() { return mDepthFar; }
47 Nullable<double> XRRenderState::GetInlineVerticalFieldOfView() {
48 return mInlineVerticalFieldOfView;
51 void XRRenderState::SetDepthNear(double aDepthNear) { mDepthNear = aDepthNear; }
53 void XRRenderState::SetDepthFar(double aDepthFar) { mDepthFar = aDepthFar; }
55 void XRRenderState::SetInlineVerticalFieldOfView(
56 double aInlineVerticalFieldOfView) {
57 mInlineVerticalFieldOfView.SetValue(aInlineVerticalFieldOfView);
60 XRWebGLLayer* XRRenderState::GetBaseLayer() { return mBaseLayer; }
62 void XRRenderState::SetBaseLayer(XRWebGLLayer* aBaseLayer) {
63 mBaseLayer = aBaseLayer;
66 void XRRenderState::SetOutputCanvas(HTMLCanvasElement* aCanvas) {
67 mOutputCanvas = aCanvas;
70 HTMLCanvasElement* XRRenderState::GetOutputCanvas() const {
71 return mOutputCanvas;
74 void XRRenderState::SetCompositionDisabled(bool aCompositionDisabled) {
75 mCompositionDisabled = aCompositionDisabled;
78 bool XRRenderState::IsCompositionDisabled() const {
79 return mCompositionDisabled;
82 void XRRenderState::SessionEnded() {
83 if (mBaseLayer) {
84 mBaseLayer->SessionEnded();
85 mBaseLayer = nullptr;
87 mOutputCanvas = nullptr;
90 } // namespace mozilla::dom