2018-08-07 21:20:34 +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
|
|
|
|
* 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 "VRGPUParent.h"
|
|
|
|
|
|
|
|
#include "mozilla/ipc/ProcessChild.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
using namespace ipc;
|
|
|
|
|
2019-01-12 01:51:48 +03:00
|
|
|
VRGPUParent::VRGPUParent(ProcessId aChildProcessId) : mClosed(false) {
|
2018-08-07 21:20:34 +03:00
|
|
|
MOZ_COUNT_CTOR(VRGPUParent);
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
SetOtherProcessId(aChildProcessId);
|
|
|
|
}
|
|
|
|
|
2019-01-15 00:58:51 +03:00
|
|
|
VRGPUParent::~VRGPUParent() { MOZ_COUNT_DTOR(VRGPUParent); }
|
|
|
|
|
2018-08-07 21:20:34 +03:00
|
|
|
void VRGPUParent::ActorDestroy(ActorDestroyReason aWhy) {
|
2018-10-09 05:41:00 +03:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID)
|
2018-08-21 00:58:28 +03:00
|
|
|
if (mVRService) {
|
|
|
|
mVRService->Stop();
|
|
|
|
mVRService = nullptr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-01-12 01:51:48 +03:00
|
|
|
mClosed = true;
|
2018-08-07 21:20:34 +03:00
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
NewRunnableMethod("gfx::VRGPUParent::DeferredDestroy", this,
|
2018-08-07 08:47:18 +03:00
|
|
|
&VRGPUParent::DeferredDestroy));
|
2018-08-07 21:20:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void VRGPUParent::DeferredDestroy() { mSelfRef = nullptr; }
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
RefPtr<VRGPUParent> VRGPUParent::CreateForGPU(
|
2018-08-07 21:20:34 +03:00
|
|
|
Endpoint<PVRGPUParent>&& aEndpoint) {
|
|
|
|
RefPtr<VRGPUParent> vcp = new VRGPUParent(aEndpoint.OtherPid());
|
|
|
|
MessageLoop::current()->PostTask(NewRunnableMethod<Endpoint<PVRGPUParent>&&>(
|
|
|
|
"gfx::VRGPUParent::Bind", vcp, &VRGPUParent::Bind, std::move(aEndpoint)));
|
|
|
|
|
2019-01-12 01:51:48 +03:00
|
|
|
return vcp.forget();
|
2018-08-07 21:20:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void VRGPUParent::Bind(Endpoint<PVRGPUParent>&& aEndpoint) {
|
|
|
|
if (!aEndpoint.Bind(this)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mSelfRef = this;
|
|
|
|
}
|
|
|
|
|
2018-08-21 00:58:28 +03:00
|
|
|
mozilla::ipc::IPCResult VRGPUParent::RecvStartVRService() {
|
2018-10-09 05:41:00 +03:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID)
|
2018-08-21 00:58:28 +03:00
|
|
|
mVRService = VRService::Create();
|
|
|
|
MOZ_ASSERT(mVRService);
|
|
|
|
|
|
|
|
mVRService->Start();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult VRGPUParent::RecvStopVRService() {
|
2018-10-09 05:41:00 +03:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID)
|
2018-08-21 00:58:28 +03:00
|
|
|
if (mVRService) {
|
|
|
|
mVRService->Stop();
|
|
|
|
mVRService = nullptr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-08-07 21:20:34 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-01-12 01:51:48 +03:00
|
|
|
bool VRGPUParent::IsClosed() { return mClosed; }
|
|
|
|
|
2018-08-07 21:20:34 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|