tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

XRWebGLLayer.h (2893B)


      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_XRWebGLLayer_h_
      8 #define mozilla_dom_XRWebGLLayer_h_
      9 
     10 #include "WebGLTypes.h"
     11 #include "gfxVR.h"
     12 #include "mozilla/DOMEventTargetHelper.h"
     13 #include "mozilla/dom/WebXRBinding.h"
     14 #include "mozilla/dom/XRSession.h"
     15 #include "nsICanvasRenderingContextInternal.h"
     16 
     17 namespace mozilla {
     18 class WebGLFramebufferJS;
     19 class ClientWebGLContext;
     20 namespace dom {
     21 class XRSession;
     22 class XRView;
     23 class XRViewport;
     24 class WebGLRenderingContextOrWebGL2RenderingContext;
     25 struct XRWebGLLayerInit;
     26 class XRWebGLLayer final : public nsWrapperCache {
     27 public:
     28  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRWebGLLayer)
     29  NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(XRWebGLLayer)
     30 
     31  explicit XRWebGLLayer(
     32      nsISupports* aParent, XRSession& aSession, bool aIgnoreDepthValues,
     33      double aFramebufferScaleFactor,
     34      RefPtr<mozilla::ClientWebGLContext> aWebGLContext,
     35      RefPtr<WebGLFramebufferJS> aFramebuffer,
     36      const Maybe<const webgl::OpaqueFramebufferOptions>& aOptions);
     37 
     38  // WebIDL Boilerplate
     39  JSObject* WrapObject(JSContext* aCx,
     40                       JS::Handle<JSObject*> aGivenProto) override;
     41  nsISupports* GetParentObject() const;
     42 
     43  // WebIDL Members
     44  static already_AddRefed<XRWebGLLayer> Constructor(
     45      const GlobalObject& aGlobal, XRSession& aSession,
     46      const WebGLRenderingContextOrWebGL2RenderingContext& aXRWebGLContext,
     47      const XRWebGLLayerInit& aXRWebGLLayerInitDict, ErrorResult& aRv);
     48  bool Depth();
     49  bool Stencil();
     50  bool Alpha();
     51  bool Antialias();
     52  bool IgnoreDepthValues();
     53  WebGLFramebufferJS* GetFramebuffer();
     54  uint32_t FramebufferWidth();
     55  uint32_t FramebufferHeight();
     56  already_AddRefed<XRViewport> GetViewport(const XRView& aView);
     57  static double GetNativeFramebufferScaleFactor(const GlobalObject& aGlobal,
     58                                                const XRSession& aSession);
     59 
     60  // Non-WebIDL Members
     61  void StartAnimationFrame();
     62  void EndAnimationFrame();
     63  HTMLCanvasElement* GetCanvas();
     64  void SessionEnded();
     65 
     66 private:
     67  void DeleteFramebuffer();
     68  virtual ~XRWebGLLayer();
     69  nsCOMPtr<nsISupports> mParent;
     70 
     71 public:
     72  RefPtr<XRSession> mSession;
     73  RefPtr<mozilla::ClientWebGLContext> mWebGL;
     74  double mFramebufferScaleFactor;
     75  bool mCompositionDisabled;
     76 
     77 private:
     78  bool mIgnoreDepthValues;
     79  RefPtr<WebGLFramebufferJS> mFramebuffer;
     80  RefPtr<XRViewport> mLeftViewport;
     81  RefPtr<XRViewport> mRightViewport;
     82  Maybe<const webgl::OpaqueFramebufferOptions> mFramebufferOptions;
     83 };
     84 
     85 }  // namespace dom
     86 }  // namespace mozilla
     87 
     88 #endif  // mozilla_dom_XRWebGLLayer_h_