2015-09-18 00:23:13 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
|
|
|
/* 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 MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
|
|
|
#define MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
#include "mozilla/layers/CompositableTransactionParent.h"
|
2016-05-16 09:39:30 +03:00
|
|
|
#include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder
|
2015-09-18 00:23:13 +03:00
|
|
|
#include "mozilla/gfx/PVRManagerParent.h" // for PVRManagerParent
|
2016-02-25 02:54:50 +03:00
|
|
|
#include "mozilla/gfx/PVRLayerParent.h" // for PVRLayerParent
|
2015-09-18 00:23:13 +03:00
|
|
|
#include "mozilla/ipc/ProtocolUtils.h" // for IToplevelProtocol
|
|
|
|
#include "mozilla/TimeStamp.h" // for TimeStamp
|
|
|
|
#include "gfxVR.h" // for VRFieldOfView
|
|
|
|
|
|
|
|
namespace mozilla {
|
2016-02-25 02:54:50 +03:00
|
|
|
using namespace layers;
|
2015-09-18 00:23:13 +03:00
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class VRManager;
|
|
|
|
|
|
|
|
class VRManagerParent final : public PVRManagerParent
|
2016-02-25 02:54:50 +03:00
|
|
|
, public HostIPCAllocator
|
|
|
|
, public ShmemAllocator
|
2015-09-18 00:23:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-07-21 10:14:59 +03:00
|
|
|
explicit VRManagerParent(ProcessId aChildProcessId);
|
2015-09-18 00:23:13 +03:00
|
|
|
|
|
|
|
static VRManagerParent* CreateSameProcess();
|
2016-07-21 10:14:59 +03:00
|
|
|
static bool CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint);
|
2016-07-21 10:14:59 +03:00
|
|
|
static bool CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint);
|
2015-09-18 00:23:13 +03:00
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
virtual base::ProcessId GetChildProcessId() override;
|
|
|
|
|
|
|
|
// ShmemAllocator
|
|
|
|
|
|
|
|
virtual ShmemAllocator* AsShmemAllocator() override { return this; }
|
|
|
|
|
|
|
|
virtual bool AllocShmem(size_t aSize,
|
|
|
|
ipc::SharedMemory::SharedMemoryType aType,
|
|
|
|
ipc::Shmem* aShmem) override;
|
|
|
|
|
|
|
|
virtual bool AllocUnsafeShmem(size_t aSize,
|
|
|
|
ipc::SharedMemory::SharedMemoryType aType,
|
|
|
|
ipc::Shmem* aShmem) override;
|
|
|
|
|
|
|
|
virtual void DeallocShmem(ipc::Shmem& aShmem) override;
|
|
|
|
|
|
|
|
virtual bool IsSameProcess() const override;
|
|
|
|
bool HaveEventListener();
|
|
|
|
|
|
|
|
virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override;
|
|
|
|
virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) override;
|
|
|
|
|
2015-09-18 00:23:13 +03:00
|
|
|
protected:
|
|
|
|
~VRManagerParent();
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
|
|
|
|
const LayersBackend& aLayersBackend,
|
|
|
|
const TextureFlags& aFlags,
|
|
|
|
const uint64_t& aSerial) override;
|
|
|
|
virtual bool DeallocPTextureParent(PTextureParent* actor) override;
|
|
|
|
|
|
|
|
virtual PVRLayerParent* AllocPVRLayerParent(const uint32_t& aDisplayID,
|
|
|
|
const float& aLeftEyeX,
|
|
|
|
const float& aLeftEyeY,
|
|
|
|
const float& aLeftEyeWidth,
|
|
|
|
const float& aLeftEyeHeight,
|
|
|
|
const float& aRightEyeX,
|
|
|
|
const float& aRightEyeY,
|
|
|
|
const float& aRightEyeWidth,
|
|
|
|
const float& aRightEyeHeight) override;
|
|
|
|
virtual bool DeallocPVRLayerParent(PVRLayerParent* actor) override;
|
|
|
|
|
2015-09-18 00:23:13 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why) override;
|
|
|
|
void OnChannelConnected(int32_t pid) override;
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
virtual bool RecvRefreshDisplays() override;
|
2016-07-05 01:52:21 +03:00
|
|
|
virtual bool RecvGetDisplays(nsTArray<VRDisplayInfo> *aDisplays) override;
|
2016-02-25 02:54:50 +03:00
|
|
|
virtual bool RecvResetSensor(const uint32_t& aDisplayID) override;
|
|
|
|
virtual bool RecvGetSensorState(const uint32_t& aDisplayID, VRHMDSensorState* aState) override;
|
|
|
|
virtual bool RecvGetImmediateSensorState(const uint32_t& aDisplayID, VRHMDSensorState* aState) override;
|
|
|
|
virtual bool RecvSetHaveEventListener(const bool& aHaveEventListener) override;
|
2015-09-18 00:23:13 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
void RegisterWithManager();
|
|
|
|
void UnregisterFromManager();
|
|
|
|
|
2016-07-21 10:14:59 +03:00
|
|
|
void Bind(Endpoint<PVRManagerParent>&& aEndpoint);
|
|
|
|
|
2015-09-18 00:23:13 +03:00
|
|
|
static void RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager);
|
|
|
|
|
|
|
|
void DeferredDestroy();
|
|
|
|
|
|
|
|
// This keeps us alive until ActorDestroy(), at which point we do a
|
|
|
|
// deferred destruction of ourselves.
|
|
|
|
RefPtr<VRManagerParent> mSelfRef;
|
|
|
|
|
|
|
|
// Keep the compositor thread alive, until we have destroyed ourselves.
|
|
|
|
RefPtr<layers::CompositorThreadHolder> mCompositorThreadHolder;
|
|
|
|
|
|
|
|
// Keep the VRManager alive, until we have destroyed ourselves.
|
|
|
|
RefPtr<VRManager> mVRManagerHolder;
|
2016-02-25 02:54:50 +03:00
|
|
|
bool mHaveEventListener;
|
2015-09-18 00:23:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
} // namespace gfx
|
|
|
|
|
|
|
|
#endif // MOZILLA_GFX_VR_VRMANAGERPARENT_H
|