2015-09-18 00:23:13 +03: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_MANAGER_H
|
|
|
|
#define GFX_VR_MANAGER_H
|
|
|
|
|
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsTHashtable.h"
|
2016-02-25 02:54:50 +03:00
|
|
|
#include "nsDataHashtable.h"
|
2015-09-18 00:23:13 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "gfxVR.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2016-02-25 02:54:50 +03:00
|
|
|
namespace layers {
|
|
|
|
class TextureHost;
|
|
|
|
}
|
2015-09-18 00:23:13 +03:00
|
|
|
namespace gfx {
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
class VRLayerParent;
|
2015-09-18 00:23:13 +03:00
|
|
|
class VRManagerParent;
|
2016-02-25 02:54:50 +03:00
|
|
|
class VRDisplayHost;
|
2015-09-18 00:23:13 +03:00
|
|
|
|
|
|
|
class VRManager
|
|
|
|
{
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::gfx::VRManager)
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void ManagerInit();
|
|
|
|
static VRManager* Get();
|
|
|
|
|
|
|
|
void AddVRManagerParent(VRManagerParent* aVRManagerParent);
|
|
|
|
void RemoveVRManagerParent(VRManagerParent* aVRManagerParent);
|
|
|
|
|
|
|
|
void NotifyVsync(const TimeStamp& aVsyncTimestamp);
|
2016-02-25 02:54:50 +03:00
|
|
|
void NotifyVRVsync(const uint32_t& aDisplayID);
|
|
|
|
void RefreshVRDisplays(bool aMustDispatch = false);
|
|
|
|
RefPtr<gfx::VRDisplayHost> GetDisplay(const uint32_t& aDisplayID);
|
2016-07-05 01:52:21 +03:00
|
|
|
void GetVRDisplayInfo(nsTArray<VRDisplayInfo>& aDisplayInfo);
|
2016-02-25 02:54:50 +03:00
|
|
|
|
|
|
|
void SubmitFrame(VRLayerParent* aLayer, const int32_t& aInputFrameID,
|
|
|
|
layers::PTextureParent* aTexture, const gfx::Rect& aLeftEyeRect,
|
|
|
|
const gfx::Rect& aRightEyeRect);
|
2015-09-18 00:23:13 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
VRManager();
|
|
|
|
~VRManager();
|
|
|
|
|
|
|
|
private:
|
2016-02-25 02:54:50 +03:00
|
|
|
RefPtr<layers::TextureHost> mLastFrame;
|
2015-09-18 00:23:13 +03:00
|
|
|
|
|
|
|
void Init();
|
|
|
|
void Destroy();
|
|
|
|
|
2016-04-13 03:39:28 +03:00
|
|
|
void DispatchVRDisplayInfoUpdate();
|
2015-09-18 00:23:13 +03:00
|
|
|
|
|
|
|
typedef nsTHashtable<nsRefPtrHashKey<VRManagerParent>> VRManagerParentSet;
|
|
|
|
VRManagerParentSet mVRManagerParents;
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
typedef nsTArray<RefPtr<VRDisplayManager>> VRDisplayManagerArray;
|
|
|
|
VRDisplayManagerArray mManagers;
|
2015-09-18 00:23:13 +03:00
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
typedef nsRefPtrHashtable<nsUint32HashKey, gfx::VRDisplayHost> VRDisplayHostHashMap;
|
|
|
|
VRDisplayHostHashMap mVRDisplays;
|
2015-09-18 00:23:13 +03:00
|
|
|
|
|
|
|
Atomic<bool> mInitialized;
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
TimeStamp mLastRefreshTime;
|
2015-09-18 00:23:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GFX_VR_MANAGER_H
|