Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 :
7 : #include "VRLayerParent.h"
8 : #include "mozilla/Unused.h"
9 :
10 : namespace mozilla {
11 : namespace gfx {
12 :
13 0 : VRLayerParent::VRLayerParent(uint32_t aVRDisplayID, const Rect& aLeftEyeRect, const Rect& aRightEyeRect, const uint32_t aGroup)
14 : : mIPCOpen(true)
15 : , mVRDisplayID(aVRDisplayID)
16 : , mLeftEyeRect(aLeftEyeRect)
17 : , mRightEyeRect(aRightEyeRect)
18 0 : , mGroup(aGroup)
19 : {
20 0 : }
21 :
22 0 : VRLayerParent::~VRLayerParent()
23 : {
24 0 : MOZ_COUNT_DTOR(VRLayerParent);
25 0 : }
26 :
27 : mozilla::ipc::IPCResult
28 0 : VRLayerParent::RecvDestroy()
29 : {
30 0 : Destroy();
31 0 : return IPC_OK();
32 : }
33 :
34 : void
35 0 : VRLayerParent::ActorDestroy(ActorDestroyReason aWhy)
36 : {
37 0 : mIPCOpen = false;
38 0 : }
39 :
40 : void
41 0 : VRLayerParent::Destroy()
42 : {
43 0 : if (mVRDisplayID) {
44 0 : VRManager* vm = VRManager::Get();
45 0 : RefPtr<gfx::VRDisplayHost> display = vm->GetDisplay(mVRDisplayID);
46 0 : if (display) {
47 0 : display->RemoveLayer(this);
48 : }
49 : // 0 will never be a valid VRDisplayID; we can use it to indicate that
50 : // we are destroyed and no longer associated with a display.
51 0 : mVRDisplayID = 0;
52 : }
53 :
54 0 : if (mIPCOpen) {
55 0 : Unused << PVRLayerParent::Send__delete__(this);
56 : }
57 0 : }
58 :
59 : mozilla::ipc::IPCResult
60 0 : VRLayerParent::RecvSubmitFrame(PTextureParent* texture)
61 : {
62 0 : if (mVRDisplayID) {
63 0 : VRManager* vm = VRManager::Get();
64 0 : vm->SubmitFrame(this, texture, mLeftEyeRect, mRightEyeRect);
65 : }
66 :
67 0 : return IPC_OK();
68 : }
69 :
70 :
71 : } // namespace gfx
72 : } // namespace mozilla
|