2017-10-27 23:10:06 +00: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-24 23:54:50 +00: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/. */
|
|
|
|
|
|
|
|
|
|
|
|
#include "VRLayerParent.h"
|
2016-08-23 04:09:32 +00:00
|
|
|
#include "mozilla/Unused.h"
|
2017-07-22 00:30:34 +00:00
|
|
|
#include "VRDisplayHost.h"
|
2017-11-02 04:44:12 +00:00
|
|
|
#include "mozilla/layers/CompositorThread.h"
|
2016-02-24 23:54:50 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2017-10-05 10:16:16 +00:00
|
|
|
using namespace layers;
|
2016-02-24 23:54:50 +00:00
|
|
|
namespace gfx {
|
|
|
|
|
2017-08-28 23:20:59 +00:00
|
|
|
VRLayerParent::VRLayerParent(uint32_t aVRDisplayID, const uint32_t aGroup)
|
2016-02-24 23:54:50 +00:00
|
|
|
: mIPCOpen(true)
|
|
|
|
, mVRDisplayID(aVRDisplayID)
|
2017-05-08 23:01:36 +00:00
|
|
|
, mGroup(aGroup)
|
2016-02-24 23:54:50 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VRLayerParent::~VRLayerParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(VRLayerParent);
|
|
|
|
}
|
|
|
|
|
2016-11-15 03:26:00 +00:00
|
|
|
mozilla::ipc::IPCResult
|
2016-02-24 23:54:50 +00:00
|
|
|
VRLayerParent::RecvDestroy()
|
|
|
|
{
|
|
|
|
Destroy();
|
2016-11-15 03:26:00 +00:00
|
|
|
return IPC_OK();
|
2016-02-24 23:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VRLayerParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
mIPCOpen = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VRLayerParent::Destroy()
|
|
|
|
{
|
2017-07-04 20:28:27 +00:00
|
|
|
if (mVRDisplayID) {
|
|
|
|
VRManager* vm = VRManager::Get();
|
|
|
|
RefPtr<gfx::VRDisplayHost> display = vm->GetDisplay(mVRDisplayID);
|
|
|
|
if (display) {
|
|
|
|
display->RemoveLayer(this);
|
|
|
|
}
|
|
|
|
// 0 will never be a valid VRDisplayID; we can use it to indicate that
|
|
|
|
// we are destroyed and no longer associated with a display.
|
|
|
|
mVRDisplayID = 0;
|
|
|
|
}
|
|
|
|
|
2016-02-24 23:54:50 +00:00
|
|
|
if (mIPCOpen) {
|
|
|
|
Unused << PVRLayerParent::Send__delete__(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 03:26:00 +00:00
|
|
|
mozilla::ipc::IPCResult
|
2017-07-22 00:30:34 +00:00
|
|
|
VRLayerParent::RecvSubmitFrame(const layers::SurfaceDescriptor &aTexture,
|
2017-08-28 23:20:59 +00:00
|
|
|
const uint64_t& aFrameId,
|
|
|
|
const gfx::Rect& aLeftEyeRect,
|
|
|
|
const gfx::Rect& aRightEyeRect)
|
2016-02-24 23:54:50 +00:00
|
|
|
{
|
2017-07-04 20:28:27 +00:00
|
|
|
if (mVRDisplayID) {
|
|
|
|
VRManager* vm = VRManager::Get();
|
2017-07-22 00:30:34 +00:00
|
|
|
RefPtr<VRDisplayHost> display = vm->GetDisplay(mVRDisplayID);
|
|
|
|
if (display) {
|
2017-11-17 08:06:59 +00:00
|
|
|
display->SubmitFrame(this, aTexture, aFrameId, aLeftEyeRect, aRightEyeRect);
|
2017-07-22 00:30:34 +00:00
|
|
|
}
|
2017-07-04 20:28:27 +00:00
|
|
|
}
|
2016-02-24 23:54:50 +00:00
|
|
|
|
2016-11-15 03:26:00 +00:00
|
|
|
return IPC_OK();
|
2016-02-24 23:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|