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