1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "VRGPUParent.h"
8 #include "VRPuppetCommandBuffer.h"
10 #include "mozilla/ipc/Endpoint.h"
11 #include "mozilla/ipc/ProcessChild.h"
12 #include "mozilla/StaticPrefs_dom.h"
19 VRGPUParent::VRGPUParent(EndpointProcInfo aChildProcess
) : mClosed(false) {
20 MOZ_ASSERT(NS_IsMainThread());
22 SetOtherEndpointProcInfo(aChildProcess
);
25 VRGPUParent::~VRGPUParent() = default;
27 void VRGPUParent::ActorDestroy(ActorDestroyReason aWhy
) {
28 #if !defined(MOZ_WIDGET_ANDROID)
39 RefPtr
<VRGPUParent
> VRGPUParent::CreateForGPU(
40 Endpoint
<PVRGPUParent
>&& aEndpoint
) {
41 if (!StaticPrefs::dom_vr_enabled() && !StaticPrefs::dom_vr_webxr_enabled()) {
45 RefPtr
<VRGPUParent
> vcp
= new VRGPUParent(aEndpoint
.OtherEndpointProcInfo());
46 GetCurrentSerialEventTarget()->Dispatch(
47 NewRunnableMethod
<Endpoint
<PVRGPUParent
>&&>("gfx::VRGPUParent::Bind", vcp
,
49 std::move(aEndpoint
)));
54 void VRGPUParent::Bind(Endpoint
<PVRGPUParent
>&& aEndpoint
) {
55 if (!aEndpoint
.Bind(this)) {
60 mozilla::ipc::IPCResult
VRGPUParent::RecvStartVRService() {
61 #if !defined(MOZ_WIDGET_ANDROID)
62 mVRService
= VRService::Create();
63 MOZ_ASSERT(mVRService
);
71 mozilla::ipc::IPCResult
VRGPUParent::RecvStopVRService() {
72 #if !defined(MOZ_WIDGET_ANDROID)
82 mozilla::ipc::IPCResult
VRGPUParent::RecvPuppetReset() {
83 #if !defined(MOZ_WIDGET_ANDROID)
84 VRPuppetCommandBuffer::Get().Reset();
89 mozilla::ipc::IPCResult
VRGPUParent::RecvPuppetSubmit(
90 const nsTArray
<uint64_t>& aBuffer
) {
91 #if !defined(MOZ_WIDGET_ANDROID)
92 VRPuppetCommandBuffer::Get().Submit(aBuffer
);
97 mozilla::ipc::IPCResult
VRGPUParent::RecvPuppetCheckForCompletion() {
98 #if !defined(MOZ_WIDGET_ANDROID)
99 if (VRPuppetCommandBuffer::Get().HasEnded()) {
100 Unused
<< SendNotifyPuppetComplete();
106 bool VRGPUParent::IsClosed() { return mClosed
; }
109 } // namespace mozilla