2015-04-01 13:02:20 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GFX_VR_OCULUS_H
|
|
|
|
#define GFX_VR_OCULUS_H
|
|
|
|
|
|
|
|
#include "nsTArray.h"
|
2015-10-17 22:24:48 -07:00
|
|
|
#include "mozilla/RefPtr.h"
|
2015-04-01 13:02:20 -07:00
|
|
|
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "mozilla/EnumeratedArray.h"
|
|
|
|
|
|
|
|
#include "gfxVR.h"
|
2015-07-02 08:58:24 -07:00
|
|
|
//#include <OVR_CAPI.h>
|
|
|
|
//#include <OVR_CAPI_D3D.h>
|
2015-04-01 13:02:20 -07:00
|
|
|
#include "ovr_capi_dynamic.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
namespace impl {
|
|
|
|
|
2015-07-02 08:58:24 -07:00
|
|
|
class HMDInfoOculus : public VRHMDInfo, public VRHMDRenderingSupport {
|
2015-04-01 13:02:20 -07:00
|
|
|
public:
|
2015-09-22 06:38:28 -07:00
|
|
|
explicit HMDInfoOculus(ovrSession aSession);
|
2015-04-01 13:02:20 -07:00
|
|
|
|
|
|
|
bool SetFOV(const VRFieldOfView& aFOVLeft, const VRFieldOfView& aFOVRight,
|
|
|
|
double zNear, double zFar) override;
|
|
|
|
|
|
|
|
VRHMDSensorState GetSensorState(double timeOffset) override;
|
|
|
|
void ZeroSensor() override;
|
2015-09-17 14:23:13 -07:00
|
|
|
bool KeepSensorTracking() override;
|
|
|
|
void NotifyVsync(const TimeStamp& aVsyncTimestamp) override;
|
2015-04-01 13:02:20 -07:00
|
|
|
|
|
|
|
void FillDistortionConstants(uint32_t whichEye,
|
|
|
|
const IntSize& textureSize, const IntRect& eyeViewport,
|
|
|
|
const Size& destViewport, const Rect& destRect,
|
|
|
|
VRDistortionConstants& values) override;
|
|
|
|
|
2015-07-02 08:58:24 -07:00
|
|
|
VRHMDRenderingSupport* GetRenderingSupport() override { return this; }
|
|
|
|
|
2015-04-01 13:02:20 -07:00
|
|
|
void Destroy();
|
|
|
|
|
2015-07-02 08:58:24 -07:00
|
|
|
/* VRHMDRenderingSupport */
|
|
|
|
already_AddRefed<RenderTargetSet> CreateRenderTargetSet(layers::Compositor *aCompositor, const IntSize& aSize) override;
|
|
|
|
void DestroyRenderTargetSet(RenderTargetSet *aRTSet) override;
|
|
|
|
void SubmitFrame(RenderTargetSet *aRTSet) override;
|
|
|
|
|
2015-09-22 06:38:28 -07:00
|
|
|
ovrSession GetOculusSession() const { return mSession; }
|
2015-07-02 08:58:24 -07:00
|
|
|
|
2015-04-01 13:02:20 -07:00
|
|
|
protected:
|
2015-09-17 14:23:13 -07:00
|
|
|
virtual ~HMDInfoOculus() {
|
|
|
|
Destroy();
|
|
|
|
MOZ_COUNT_DTOR_INHERITED(HMDInfoOculus, VRHMDInfo);
|
|
|
|
}
|
|
|
|
|
2015-04-01 13:02:20 -07:00
|
|
|
// must match the size of VRDistortionVertex
|
|
|
|
struct DistortionVertex {
|
|
|
|
float pos[2];
|
|
|
|
float texR[2];
|
|
|
|
float texG[2];
|
|
|
|
float texB[2];
|
|
|
|
float genericAttribs[4];
|
|
|
|
};
|
|
|
|
|
2015-09-22 06:38:28 -07:00
|
|
|
ovrSession mSession;
|
|
|
|
ovrHmdDesc mDesc;
|
2015-04-01 13:02:20 -07:00
|
|
|
ovrFovPort mFOVPort[2];
|
2015-07-02 08:58:24 -07:00
|
|
|
ovrTrackingState mLastTrackingState;
|
2015-04-01 13:02:20 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace impl
|
|
|
|
|
|
|
|
class VRHMDManagerOculus : public VRHMDManager
|
|
|
|
{
|
|
|
|
public:
|
2015-09-17 14:23:13 -07:00
|
|
|
static already_AddRefed<VRHMDManagerOculus> Create();
|
2015-04-01 13:02:20 -07:00
|
|
|
virtual bool Init() override;
|
|
|
|
virtual void Destroy() override;
|
2015-10-17 22:24:48 -07:00
|
|
|
virtual void GetHMDs(nsTArray<RefPtr<VRHMDInfo> >& aHMDResult) override;
|
2015-04-01 13:02:20 -07:00
|
|
|
protected:
|
2015-09-17 14:23:13 -07:00
|
|
|
VRHMDManagerOculus()
|
|
|
|
: mOculusInitialized(false)
|
|
|
|
{ }
|
|
|
|
|
2015-09-22 06:38:28 -07:00
|
|
|
RefPtr<impl::HMDInfoOculus> mHMDInfo;
|
2015-04-01 13:02:20 -07:00
|
|
|
bool mOculusInitialized;
|
2015-09-17 14:23:13 -07:00
|
|
|
RefPtr<nsIThread> mOculusThread;
|
2015-04-01 13:02:20 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* GFX_VR_OCULUS_H */
|