/src/mozilla-central/gfx/vr/ipc/VRLayerParent.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
8 | | #include "VRLayerParent.h" |
9 | | #include "mozilla/Unused.h" |
10 | | #include "VRDisplayHost.h" |
11 | | #include "mozilla/layers/CompositorThread.h" |
12 | | |
13 | | namespace mozilla { |
14 | | using namespace layers; |
15 | | namespace gfx { |
16 | | |
17 | | VRLayerParent::VRLayerParent(uint32_t aVRDisplayID, const uint32_t aGroup) |
18 | | : mIPCOpen(true) |
19 | | , mVRDisplayID(aVRDisplayID) |
20 | | , mGroup(aGroup) |
21 | 0 | { |
22 | 0 | } |
23 | | |
24 | | VRLayerParent::~VRLayerParent() |
25 | 0 | { |
26 | 0 | MOZ_COUNT_DTOR(VRLayerParent); |
27 | 0 | } |
28 | | |
29 | | mozilla::ipc::IPCResult |
30 | | VRLayerParent::RecvDestroy() |
31 | 0 | { |
32 | 0 | Destroy(); |
33 | 0 | return IPC_OK(); |
34 | 0 | } |
35 | | |
36 | | void |
37 | | VRLayerParent::ActorDestroy(ActorDestroyReason aWhy) |
38 | 0 | { |
39 | 0 | mIPCOpen = false; |
40 | 0 | } |
41 | | |
42 | | void |
43 | | VRLayerParent::Destroy() |
44 | 0 | { |
45 | 0 | if (mVRDisplayID) { |
46 | 0 | VRManager* vm = VRManager::Get(); |
47 | 0 | RefPtr<gfx::VRDisplayHost> display = vm->GetDisplay(mVRDisplayID); |
48 | 0 | if (display) { |
49 | 0 | display->RemoveLayer(this); |
50 | 0 | } |
51 | 0 | // 0 will never be a valid VRDisplayID; we can use it to indicate that |
52 | 0 | // we are destroyed and no longer associated with a display. |
53 | 0 | mVRDisplayID = 0; |
54 | 0 | } |
55 | 0 |
|
56 | 0 | if (mIPCOpen) { |
57 | 0 | Unused << PVRLayerParent::Send__delete__(this); |
58 | 0 | } |
59 | 0 | } |
60 | | |
61 | | mozilla::ipc::IPCResult |
62 | | VRLayerParent::RecvSubmitFrame(const layers::SurfaceDescriptor &aTexture, |
63 | | const uint64_t& aFrameId, |
64 | | const gfx::Rect& aLeftEyeRect, |
65 | | const gfx::Rect& aRightEyeRect) |
66 | 0 | { |
67 | 0 | if (mVRDisplayID) { |
68 | 0 | VRManager* vm = VRManager::Get(); |
69 | 0 | RefPtr<VRDisplayHost> display = vm->GetDisplay(mVRDisplayID); |
70 | 0 | if (display) { |
71 | 0 | display->SubmitFrame(this, aTexture, aFrameId, aLeftEyeRect, aRightEyeRect); |
72 | 0 | } |
73 | 0 | } |
74 | 0 |
|
75 | 0 | return IPC_OK(); |
76 | 0 | } |
77 | | |
78 | | } // namespace gfx |
79 | | } // namespace mozilla |