2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2016-02-25 02:54:50 +03:00
|
|
|
* 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_DISPLAY_CLIENT_H
|
|
|
|
#define GFX_VR_DISPLAY_CLIENT_H
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2019-03-19 19:02:12 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-02-25 02:54:50 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "mozilla/dom/VRDisplayBinding.h"
|
|
|
|
|
|
|
|
#include "gfxVR.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2020-04-06 22:33:32 +03:00
|
|
|
namespace dom {
|
|
|
|
enum class XRReferenceSpaceType : uint8_t;
|
|
|
|
class XRSession;
|
|
|
|
} // namespace dom
|
2016-02-25 02:54:50 +03:00
|
|
|
namespace gfx {
|
|
|
|
class VRDisplayPresentation;
|
|
|
|
class VRManagerChild;
|
|
|
|
|
|
|
|
class VRDisplayClient {
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRDisplayClient)
|
|
|
|
|
|
|
|
explicit VRDisplayClient(const VRDisplayInfo& aDisplayInfo);
|
|
|
|
|
2019-03-19 19:02:12 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void UpdateDisplayInfo(const VRDisplayInfo& aDisplayInfo);
|
2017-05-23 11:55:30 +03:00
|
|
|
void UpdateSubmitFrameResult(const VRSubmitFrameResultInfo& aResult);
|
2016-02-25 02:54:50 +03:00
|
|
|
|
|
|
|
const VRDisplayInfo& GetDisplayInfo() const { return mDisplayInfo; }
|
2018-12-18 22:39:44 +03:00
|
|
|
virtual const VRHMDSensorState& GetSensorState() const;
|
2017-05-23 11:55:30 +03:00
|
|
|
void GetSubmitFrameResult(VRSubmitFrameResultInfo& aResult);
|
2016-02-25 02:54:50 +03:00
|
|
|
|
2017-05-09 02:01:36 +03:00
|
|
|
already_AddRefed<VRDisplayPresentation> BeginPresentation(
|
|
|
|
const nsTArray<dom::VRLayer>& aLayers, uint32_t aGroup);
|
2020-04-06 22:33:32 +03:00
|
|
|
void PresentationCreated();
|
2016-02-25 02:54:50 +03:00
|
|
|
void PresentationDestroyed();
|
|
|
|
|
2020-04-06 22:33:32 +03:00
|
|
|
void SessionStarted(dom::XRSession* aSession);
|
|
|
|
void SessionEnded(dom::XRSession* aSession);
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
bool GetIsConnected() const;
|
|
|
|
|
|
|
|
void NotifyDisconnected();
|
2017-05-09 02:01:36 +03:00
|
|
|
void SetGroupMask(uint32_t aGroupMask);
|
2016-02-25 02:54:50 +03:00
|
|
|
|
2017-11-01 03:25:40 +03:00
|
|
|
bool IsPresentationGenerationCurrent() const;
|
|
|
|
void MakePresentationGenerationCurrent();
|
|
|
|
|
2018-07-31 04:41:25 +03:00
|
|
|
void StartVRNavigation();
|
|
|
|
void StopVRNavigation(const TimeDuration& aTimeout);
|
|
|
|
|
2019-10-24 22:58:15 +03:00
|
|
|
bool IsPresenting();
|
2020-04-06 22:33:32 +03:00
|
|
|
bool IsReferenceSpaceTypeSupported(dom::XRReferenceSpaceType aType) const;
|
2020-04-07 23:37:00 +03:00
|
|
|
gfx::VRAPIMode GetXRAPIMode() const;
|
2020-04-08 06:23:47 +03:00
|
|
|
void SetXRAPIMode(gfx::VRAPIMode aMode);
|
2019-10-24 22:58:15 +03:00
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
protected:
|
|
|
|
virtual ~VRDisplayClient();
|
|
|
|
|
2019-03-19 19:02:12 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void FireEvents();
|
2018-07-11 22:20:51 +03:00
|
|
|
void FireGamepadEvents();
|
2020-04-06 22:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void StartFrame();
|
2017-05-09 02:01:36 +03:00
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
VRDisplayInfo mDisplayInfo;
|
|
|
|
|
2016-10-19 01:18:10 +03:00
|
|
|
bool bLastEventWasMounted;
|
2016-02-25 02:54:50 +03:00
|
|
|
bool bLastEventWasPresenting;
|
|
|
|
|
|
|
|
int mPresentationCount;
|
2017-09-15 23:38:47 +03:00
|
|
|
uint64_t mLastEventFrameId;
|
2017-11-01 03:25:40 +03:00
|
|
|
uint32_t mLastPresentingGeneration;
|
2018-07-11 22:20:51 +03:00
|
|
|
|
|
|
|
// Difference between mDisplayInfo.mControllerState and
|
|
|
|
// mLastEventControllerState determines what gamepad events to fire when
|
|
|
|
// updated.
|
|
|
|
VRControllerState mLastEventControllerState[kVRControllerMaxCount];
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-04-06 22:33:32 +03:00
|
|
|
/**
|
|
|
|
* mSessions is cleared in VRDisplayClient::SessionEnded.
|
|
|
|
* SessionEnded is guaranteed to be called by every XRSession
|
|
|
|
* when it is shutdown explicitly with the WebXR XRSession.end
|
|
|
|
* call, when all JS references on the XRSession are released, or
|
|
|
|
* when the window is closed.
|
|
|
|
*/
|
|
|
|
nsTArray<RefPtr<dom::XRSession>> mSessions;
|
|
|
|
|
2017-05-23 11:55:30 +03:00
|
|
|
private:
|
2020-03-13 23:57:15 +03:00
|
|
|
void GamepadMappingForWebVR(VRControllerState& aControllerState);
|
|
|
|
|
2017-05-23 11:55:30 +03:00
|
|
|
VRSubmitFrameResultInfo mSubmitFrameResult;
|
2020-04-08 06:23:47 +03:00
|
|
|
gfx::VRAPIMode mAPIMode;
|
2016-02-25 02:54:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* GFX_VR_DISPLAY_CLIENT_H */
|