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 #ifndef mozilla_dom_XRWebGLLayer_h_
8 #define mozilla_dom_XRWebGLLayer_h_
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/WebXRBinding.h"
12 #include "mozilla/dom/XRSession.h"
13 #include "nsICanvasRenderingContextInternal.h"
14 #include "WebGLTypes.h"
19 class WebGLFramebufferJS
;
20 class ClientWebGLContext
;
25 class WebGLRenderingContextOrWebGL2RenderingContext
;
26 struct XRWebGLLayerInit
;
27 class XRWebGLLayer final
: public nsWrapperCache
{
29 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRWebGLLayer
)
30 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(XRWebGLLayer
)
32 explicit XRWebGLLayer(
33 nsISupports
* aParent
, XRSession
& aSession
, bool aIgnoreDepthValues
,
34 double aFramebufferScaleFactor
,
35 RefPtr
<mozilla::ClientWebGLContext
> aWebGLContext
,
36 RefPtr
<WebGLFramebufferJS
> aFramebuffer
,
37 const Maybe
<const webgl::OpaqueFramebufferOptions
>& aOptions
);
40 JSObject
* WrapObject(JSContext
* aCx
,
41 JS::Handle
<JSObject
*> aGivenProto
) override
;
42 nsISupports
* GetParentObject() const;
45 static already_AddRefed
<XRWebGLLayer
> Constructor(
46 const GlobalObject
& aGlobal
, XRSession
& aSession
,
47 const WebGLRenderingContextOrWebGL2RenderingContext
& aXRWebGLContext
,
48 const XRWebGLLayerInit
& aXRWebGLLayerInitDict
, ErrorResult
& aRv
);
53 bool IgnoreDepthValues();
54 WebGLFramebufferJS
* GetFramebuffer();
55 uint32_t FramebufferWidth();
56 uint32_t FramebufferHeight();
57 already_AddRefed
<XRViewport
> GetViewport(const XRView
& aView
);
58 static double GetNativeFramebufferScaleFactor(const GlobalObject
& aGlobal
,
59 const XRSession
& aSession
);
62 void StartAnimationFrame();
63 void EndAnimationFrame();
64 HTMLCanvasElement
* GetCanvas();
68 void DeleteFramebuffer();
69 virtual ~XRWebGLLayer();
70 nsCOMPtr
<nsISupports
> mParent
;
73 RefPtr
<XRSession
> mSession
;
74 RefPtr
<mozilla::ClientWebGLContext
> mWebGL
;
75 double mFramebufferScaleFactor
;
76 bool mCompositionDisabled
;
79 bool mIgnoreDepthValues
;
80 RefPtr
<WebGLFramebufferJS
> mFramebuffer
;
81 RefPtr
<XRViewport
> mLeftViewport
;
82 RefPtr
<XRViewport
> mRightViewport
;
83 Maybe
<const webgl::OpaqueFramebufferOptions
> mFramebufferOptions
;
87 } // namespace mozilla
89 #endif // mozilla_dom_XRWebGLLayer_h_