tor-browser

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

OSVRSession.h (2402B)


      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_SERVICE_OSVRSESSION_H
      8 #define GFX_VR_SERVICE_OSVRSESSION_H
      9 
     10 #include "VRSession.h"
     11 
     12 #include "mozilla/gfx/2D.h"
     13 #include "mozilla/TimeStamp.h"
     14 #include "moz_external_vr.h"
     15 
     16 #include <osvr/ClientKit/ClientKitC.h>
     17 #include <osvr/ClientKit/DisplayC.h>
     18 
     19 #if defined(XP_WIN)
     20 #  include <d3d11_1.h>
     21 #endif
     22 
     23 namespace mozilla {
     24 namespace gfx {
     25 
     26 class OSVRSession : public VRSession {
     27 public:
     28  OSVRSession();
     29  virtual ~OSVRSession();
     30 
     31  bool Initialize(mozilla::gfx::VRSystemState& aSystemState,
     32                  bool aDetectRuntimesOnly) override;
     33  void Shutdown() override;
     34  void ProcessEvents(mozilla::gfx::VRSystemState& aSystemState) override;
     35  void StartFrame(mozilla::gfx::VRSystemState& aSystemState) override;
     36  bool StartPresentation() override;
     37  void StopPresentation() override;
     38  void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
     39                     float aIntensity, float aDuration) override;
     40  void StopVibrateHaptic(uint32_t aControllerIdx) override;
     41  void StopAllHaptics() override;
     42 
     43 protected:
     44 #if defined(XP_WIN)
     45  bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
     46                   ID3D11Texture2D* aTexture) override;
     47 #elif defined(XP_MACOSX)
     48  bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
     49                   const VRLayerTextureHandle& aTexture) override;
     50 #endif
     51 
     52 private:
     53  bool InitState(mozilla::gfx::VRSystemState& aSystemState);
     54  void UpdateHeadsetPose(mozilla::gfx::VRSystemState& aState);
     55  bool mRuntimeLoaded;
     56  bool mOSVRInitialized;
     57  bool mClientContextInitialized;
     58  bool mDisplayConfigInitialized;
     59  bool mInterfaceInitialized;
     60  OSVR_ClientContext m_ctx;
     61  OSVR_ClientInterface m_iface;
     62  OSVR_DisplayConfig m_display;
     63  gfx::Matrix4x4 mHeadToEye[2];
     64 
     65  // check if all components are initialized
     66  // and if not, it will try to initialize them
     67  void CheckOSVRStatus();
     68  void InitializeClientContext();
     69  void InitializeDisplay();
     70  void InitializeInterface();
     71 };
     72 
     73 }  // namespace gfx
     74 }  // namespace mozilla
     75 
     76 #endif  // GFX_VR_SERVICE_OSVRSESSION_H