Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / canvas / XRWebGLLayer.h
blob49d4c7e770106c2c0e4bf47061b1d22f086986fd
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"
16 #include "gfxVR.h"
18 namespace mozilla {
19 class WebGLFramebufferJS;
20 class ClientWebGLContext;
21 namespace dom {
22 class XRSession;
23 class XRView;
24 class XRViewport;
25 class WebGLRenderingContextOrWebGL2RenderingContext;
26 struct XRWebGLLayerInit;
27 class XRWebGLLayer final : public nsWrapperCache {
28 public:
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);
39 // WebIDL Boilerplate
40 JSObject* WrapObject(JSContext* aCx,
41 JS::Handle<JSObject*> aGivenProto) override;
42 nsISupports* GetParentObject() const;
44 // WebIDL Members
45 static already_AddRefed<XRWebGLLayer> Constructor(
46 const GlobalObject& aGlobal, XRSession& aSession,
47 const WebGLRenderingContextOrWebGL2RenderingContext& aXRWebGLContext,
48 const XRWebGLLayerInit& aXRWebGLLayerInitDict, ErrorResult& aRv);
49 bool Depth();
50 bool Stencil();
51 bool Alpha();
52 bool Antialias();
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);
61 // Non-WebIDL Members
62 void StartAnimationFrame();
63 void EndAnimationFrame();
64 HTMLCanvasElement* GetCanvas();
65 void SessionEnded();
67 private:
68 void DeleteFramebuffer();
69 virtual ~XRWebGLLayer();
70 nsCOMPtr<nsISupports> mParent;
72 public:
73 RefPtr<XRSession> mSession;
74 RefPtr<mozilla::ClientWebGLContext> mWebGL;
75 double mFramebufferScaleFactor;
76 bool mCompositionDisabled;
78 private:
79 bool mIgnoreDepthValues;
80 RefPtr<WebGLFramebufferJS> mFramebuffer;
81 RefPtr<XRViewport> mLeftViewport;
82 RefPtr<XRViewport> mRightViewport;
83 Maybe<const webgl::OpaqueFramebufferOptions> mFramebufferOptions;
86 } // namespace dom
87 } // namespace mozilla
89 #endif // mozilla_dom_XRWebGLLayer_h_