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/. */
6 
7 #ifndef mozilla_dom_XRRenderState_h_
8 #define mozilla_dom_XRRenderState_h_
9 
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/WebXRBinding.h"
12 
13 #include "gfxVR.h"
14 
15 namespace mozilla {
16 namespace dom {
17 class XRWebGLLayer;
18 
19 class XRRenderState final : public nsWrapperCache {
20  public:
21   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRRenderState)
22   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(XRRenderState)
23 
24   explicit XRRenderState(nsISupports* aParent, XRSession* aSession);
25   explicit XRRenderState(const XRRenderState& aOther);
26 
27   void SetDepthNear(double aDepthNear);
28   void SetDepthFar(double aDepthFar);
29   void SetInlineVerticalFieldOfView(double aInlineVerticalFieldOfView);
30   void SetBaseLayer(XRWebGLLayer* aBaseLayer);
31 
32   // WebIDL Boilerplate
GetParentObject()33   nsISupports* GetParentObject() const { return mParent; }
34   JSObject* WrapObject(JSContext* aCx,
35                        JS::Handle<JSObject*> aGivenProto) override;
36 
37   // WebIDL Members
38   double DepthNear();
39   double DepthFar();
40   Nullable<double> GetInlineVerticalFieldOfView();
41   XRWebGLLayer* GetBaseLayer();
42 
43   // Non-WebIDL Members
44   void SetOutputCanvas(HTMLCanvasElement* aCanvas);
45   HTMLCanvasElement* GetOutputCanvas() const;
46   void SetCompositionDisabled(bool aCompositionDisabled);
47   bool IsCompositionDisabled() const;
48   void SessionEnded();
49 
50  protected:
51   virtual ~XRRenderState() = default;
52   nsCOMPtr<nsISupports> mParent;
53   RefPtr<XRSession> mSession;
54   RefPtr<XRWebGLLayer> mBaseLayer;
55   double mDepthNear;
56   double mDepthFar;
57   Nullable<double> mInlineVerticalFieldOfView;
58   // https://immersive-web.github.io/webxr/#xrrenderstate-output-canvas
59   RefPtr<HTMLCanvasElement> mOutputCanvas;
60   // https://immersive-web.github.io/webxr/#xrrenderstate-composition-disabled
61   bool mCompositionDisabled;
62 };
63 
64 }  // namespace dom
65 }  // namespace mozilla
66 
67 #endif  // mozilla_dom_XRRenderState_h_
68