tor-browser

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

VRLayerChild.h (2158B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef GFX_VR_LAYERCHILD_H
      8 #define GFX_VR_LAYERCHILD_H
      9 
     10 #include "VRManagerChild.h"
     11 
     12 #include "mozilla/RefPtr.h"
     13 #include "mozilla/gfx/PVRLayerChild.h"
     14 #include "gfxVR.h"
     15 
     16 class nsICanvasRenderingContextInternal;
     17 
     18 namespace mozilla {
     19 class WebGLContext;
     20 class WebGLFramebufferJS;
     21 namespace dom {
     22 class HTMLCanvasElement;
     23 }
     24 namespace layers {
     25 class SharedSurfaceTextureClient;
     26 }
     27 namespace gl {
     28 class SurfaceFactory;
     29 }
     30 namespace gfx {
     31 
     32 class VRLayerChild : public PVRLayerChild {
     33  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRLayerChild)
     34 
     35 public:
     36  static PVRLayerChild* CreateIPDLActor();
     37  static bool DestroyIPDLActor(PVRLayerChild* actor);
     38 
     39  void Initialize(dom::HTMLCanvasElement* aCanvasElement,
     40                  const gfx::Rect& aLeftEyeRect,
     41                  const gfx::Rect& aRightEyeRect);
     42  void SetXRFramebuffer(WebGLFramebufferJS*);
     43  void SubmitFrame(const VRDisplayInfo& aDisplayInfo);
     44  bool IsIPCOpen();
     45 
     46 private:
     47  VRLayerChild();
     48  virtual ~VRLayerChild();
     49  void ClearSurfaces();
     50  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
     51 
     52  RefPtr<dom::HTMLCanvasElement> mCanvasElement;
     53  bool mIPCOpen = false;
     54 
     55  // AddIPDLReference and ReleaseIPDLReference are only to be called by
     56  // CreateIPDLActor and DestroyIPDLActor, respectively. We intentionally make
     57  // them private to prevent misuse. The purpose of these methods is to be aware
     58  // of when the IPC system around this actor goes down: mIPCOpen is then set to
     59  // false.
     60  void AddIPDLReference();
     61  void ReleaseIPDLReference();
     62 
     63  gfx::Rect mLeftEyeRect;
     64  gfx::Rect mRightEyeRect;
     65  RefPtr<WebGLFramebufferJS> mFramebuffer;
     66 
     67  Maybe<layers::SurfaceDescriptor> mThisFrameTextureDesc;
     68  Maybe<layers::SurfaceDescriptor> mLastFrameTextureDesc;
     69 
     70  uint64_t mLastSubmittedFrameId = 0;
     71 };
     72 
     73 }  // namespace gfx
     74 }  // namespace mozilla
     75 
     76 #endif