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_PUPPETSESSION_H
8 #define GFX_VR_SERVICE_PUPPETSESSION_H
9 
10 #include "VRSession.h"
11 
12 #include "mozilla/TimeStamp.h"
13 #include "moz_external_vr.h"
14 
15 #if defined(XP_WIN)
16 #  include <d3d11_1.h>
17 #endif
18 class nsITimer;
19 
20 namespace mozilla {
21 namespace gfx {
22 
23 class PuppetSession : public VRSession {
24  public:
25   PuppetSession();
26   virtual ~PuppetSession();
27 
28   bool Initialize(mozilla::gfx::VRSystemState& aSystemState,
29                   bool aDetectRuntimesOnly) override;
30   void Shutdown() override;
31   void ProcessEvents(mozilla::gfx::VRSystemState& aSystemState) override;
32   void StartFrame(mozilla::gfx::VRSystemState& aSystemState) override;
33   bool StartPresentation() override;
34   void StopPresentation() override;
35   void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
36                      float aIntensity, float aDuration) override;
37   void StopVibrateHaptic(uint32_t aControllerIdx) override;
38   void StopAllHaptics() override;
39 
40  protected:
41 #if defined(XP_WIN)
42   bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
43                    ID3D11Texture2D* aTexture) override;
44 #elif defined(XP_MACOSX)
45   bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer,
46                    const VRLayerTextureHandle& aTexture) override;
47 #endif
48 
49  private:
50 #if defined(XP_WIN)
51   bool CreateD3DObjects();
52 #endif
53 };
54 
55 }  // namespace gfx
56 }  // namespace mozilla
57 
58 #endif  // GFX_VR_SERVICE_PUPPETSESSION_H
59