VRLayerParent.cpp (1496B)
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/. */ 6 7 #include "VRLayerParent.h" 8 #include "VRManager.h" 9 #include "mozilla/layers/CompositorThread.h" 10 11 namespace mozilla { 12 using namespace layers; 13 namespace gfx { 14 15 VRLayerParent::VRLayerParent(uint32_t aVRDisplayID, const uint32_t aGroup) 16 : mIPCOpen(true), mDestroyed(false), mGroup(aGroup) {} 17 18 VRLayerParent::~VRLayerParent() { 19 Destroy(); 20 MOZ_COUNT_DTOR(VRLayerParent); 21 } 22 23 mozilla::ipc::IPCResult VRLayerParent::RecvDestroy() { 24 Destroy(); 25 return IPC_OK(); 26 } 27 28 void VRLayerParent::ActorDestroy(ActorDestroyReason aWhy) { mIPCOpen = false; } 29 30 void VRLayerParent::Destroy() { 31 if (!mDestroyed) { 32 VRManager* vm = VRManager::Get(); 33 vm->RemoveLayer(this); 34 mDestroyed = true; 35 } 36 37 if (mIPCOpen) { 38 (void)PVRLayerParent::Send__delete__(this); 39 } 40 } 41 42 mozilla::ipc::IPCResult VRLayerParent::RecvSubmitFrame( 43 const layers::SurfaceDescriptor& aTexture, const uint64_t& aFrameId, 44 const gfx::Rect& aLeftEyeRect, const gfx::Rect& aRightEyeRect) { 45 if (!mDestroyed) { 46 VRManager* vm = VRManager::Get(); 47 vm->SubmitFrame(this, aTexture, aFrameId, aLeftEyeRect, aRightEyeRect); 48 } 49 50 return IPC_OK(); 51 } 52 53 } // namespace gfx 54 } // namespace mozilla