LCOV - code coverage report
Current view: top level - gfx/vr - gfxVROSVR.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 10 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef GFX_VR_OSVR_H
       7             : #define GFX_VR_OSVR_H
       8             : 
       9             : #include "nsTArray.h"
      10             : #include "mozilla/RefPtr.h"
      11             : #include "nsThreadUtils.h"
      12             : 
      13             : #include "mozilla/gfx/2D.h"
      14             : #include "mozilla/EnumeratedArray.h"
      15             : 
      16             : #include "VRDisplayHost.h"
      17             : 
      18             : #include <osvr/ClientKit/ClientKitC.h>
      19             : #include <osvr/ClientKit/DisplayC.h>
      20             : 
      21             : namespace mozilla {
      22             : namespace gfx {
      23             : namespace impl {
      24             : 
      25             : class VRDisplayOSVR : public VRDisplayHost
      26             : {
      27             : public:
      28             :   void ZeroSensor() override;
      29             : 
      30             : protected:
      31             :   VRHMDSensorState GetSensorState() override;
      32             :   virtual void StartPresentation() override;
      33             :   virtual void StopPresentation() override;
      34             : 
      35             : #if defined(XP_WIN)
      36             :   virtual bool SubmitFrame(TextureSourceD3D11* aSource,
      37             :     const IntSize& aSize,
      38             :     const gfx::Rect& aLeftEyeRect,
      39             :     const gfx::Rect& aRightEyeRect) override;
      40             : #endif
      41             : 
      42             : public:
      43             :   explicit VRDisplayOSVR(OSVR_ClientContext* context,
      44             :                          OSVR_ClientInterface* iface,
      45             :                          OSVR_DisplayConfig* display);
      46             : 
      47             : protected:
      48           0 :   virtual ~VRDisplayOSVR()
      49           0 :   {
      50           0 :     Destroy();
      51           0 :     MOZ_COUNT_DTOR_INHERITED(VRDisplayOSVR, VRDisplayHost);
      52           0 :   }
      53             :   void Destroy();
      54             : 
      55             :   OSVR_ClientContext* m_ctx;
      56             :   OSVR_ClientInterface* m_iface;
      57             :   OSVR_DisplayConfig* m_display;
      58             : };
      59             : 
      60             : } // namespace impl
      61             : 
      62           0 : class VRSystemManagerOSVR : public VRSystemManager
      63             : {
      64             : public:
      65             :   static already_AddRefed<VRSystemManagerOSVR> Create();
      66             :   virtual void Destroy() override;
      67             :   virtual void Shutdown() override;
      68             :   virtual bool GetHMDs(nsTArray<RefPtr<VRDisplayHost>>& aHMDResult) override;
      69             :   virtual bool GetIsPresenting() override;
      70             :   virtual void HandleInput() override;
      71             :   virtual void GetControllers(nsTArray<RefPtr<VRControllerHost>>&
      72             :                               aControllerResult) override;
      73             :   virtual void ScanForControllers() override;
      74             :   virtual void RemoveControllers() override;
      75             :   virtual void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
      76             :                              double aIntensity, double aDuration, uint32_t aPromiseID) override;
      77             :   virtual void StopVibrateHaptic(uint32_t aControllerIdx) override;
      78             : 
      79             : protected:
      80           0 :   VRSystemManagerOSVR()
      81           0 :     : mOSVRInitialized(false)
      82             :     , mClientContextInitialized(false)
      83             :     , mDisplayConfigInitialized(false)
      84             :     , mInterfaceInitialized(false)
      85             :     , m_ctx(nullptr)
      86             :     , m_iface(nullptr)
      87           0 :     , m_display(nullptr)
      88             :   {
      89           0 :   }
      90             : 
      91             :   bool Init();
      92             : 
      93             :   RefPtr<impl::VRDisplayOSVR> mHMDInfo;
      94             :   bool mOSVRInitialized;
      95             :   bool mClientContextInitialized;
      96             :   bool mDisplayConfigInitialized;
      97             :   bool mInterfaceInitialized;
      98             :   RefPtr<nsIThread> mOSVRThread;
      99             : 
     100             :   OSVR_ClientContext m_ctx;
     101             :   OSVR_ClientInterface m_iface;
     102             :   OSVR_DisplayConfig m_display;
     103             : 
     104             : private:
     105             :   // check if all components are initialized
     106             :   // and if not, it will try to initialize them
     107             :   void CheckOSVRStatus();
     108             :   void InitializeClientContext();
     109             :   void InitializeDisplay();
     110             :   void InitializeInterface();
     111             : };
     112             : 
     113             : } // namespace gfx
     114             : } // namespace mozilla
     115             : 
     116             : #endif /* GFX_VR_OSVR_H */

Generated by: LCOV version 1.13