/src/mozilla-central/gfx/vr/ipc/VRChild.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 | | #include "VRChild.h" |
8 | | #include "VRProcessParent.h" |
9 | | #include "gfxConfig.h" |
10 | | |
11 | | #include "mozilla/gfx/gfxVars.h" |
12 | | #include "mozilla/SystemGroup.h" |
13 | | #include "mozilla/VsyncDispatcher.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace gfx { |
17 | | |
18 | | VRChild::VRChild(VRProcessParent* aHost) |
19 | | : mHost(aHost) |
20 | 0 | { |
21 | 0 | MOZ_ASSERT(XRE_IsParentProcess()); |
22 | 0 | } |
23 | | |
24 | | void |
25 | | VRChild::ActorDestroy(ActorDestroyReason aWhy) |
26 | 0 | { |
27 | 0 | gfxVars::RemoveReceiver(this); |
28 | 0 | mHost->OnChannelClosed(); |
29 | 0 | XRE_ShutdownChildProcess(); |
30 | 0 | } |
31 | | |
32 | | void |
33 | | VRChild::Init() |
34 | 0 | { |
35 | 0 | // Build a list of prefs the VR process will need. Note that because we |
36 | 0 | // limit the VR process to prefs contained in gfxPrefs, we can simplify |
37 | 0 | // the message in two ways: one, we only need to send its index in gfxPrefs |
38 | 0 | // rather than its name, and two, we only need to send prefs that don't |
39 | 0 | // have their default value. |
40 | 0 | // Todo: Consider to make our own vrPrefs that we are interested in VR process. |
41 | 0 | nsTArray<GfxPrefSetting> prefs; |
42 | 0 | for (auto pref : gfxPrefs::all()) { |
43 | 0 | if (pref->HasDefaultValue()) { |
44 | 0 | continue; |
45 | 0 | } |
46 | 0 | |
47 | 0 | GfxPrefValue value; |
48 | 0 | pref->GetCachedValue(&value); |
49 | 0 | prefs.AppendElement(GfxPrefSetting(pref->Index(), value)); |
50 | 0 | } |
51 | 0 | nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars(); |
52 | 0 |
|
53 | 0 | DevicePrefs devicePrefs; |
54 | 0 | devicePrefs.hwCompositing() = gfxConfig::GetValue(Feature::HW_COMPOSITING); |
55 | 0 | devicePrefs.d3d11Compositing() = gfxConfig::GetValue(Feature::D3D11_COMPOSITING); |
56 | 0 | devicePrefs.oglCompositing() = gfxConfig::GetValue(Feature::OPENGL_COMPOSITING); |
57 | 0 | devicePrefs.advancedLayers() = gfxConfig::GetValue(Feature::ADVANCED_LAYERS); |
58 | 0 | devicePrefs.useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D); |
59 | 0 |
|
60 | 0 | SendInit(prefs, updates, devicePrefs); |
61 | 0 | gfxVars::AddReceiver(this); |
62 | 0 | } |
63 | | |
64 | | void |
65 | | VRChild::OnVarChanged(const GfxVarUpdate& aVar) |
66 | 0 | { |
67 | 0 | SendUpdateVar(aVar); |
68 | 0 | } |
69 | | |
70 | | class DeferredDeleteVRChild : public Runnable |
71 | | { |
72 | | public: |
73 | | explicit DeferredDeleteVRChild(UniquePtr<VRChild>&& aChild) |
74 | | : Runnable("gfx::DeferredDeleteVRChild") |
75 | | , mChild(std::move(aChild)) |
76 | 0 | { |
77 | 0 | } |
78 | | |
79 | 0 | NS_IMETHODIMP Run() override { |
80 | 0 | return NS_OK; |
81 | 0 | } |
82 | | |
83 | | private: |
84 | | UniquePtr<VRChild> mChild; |
85 | | }; |
86 | | |
87 | | /* static */ void |
88 | | VRChild::Destroy(UniquePtr<VRChild>&& aChild) |
89 | 0 | { |
90 | 0 | NS_DispatchToMainThread(new DeferredDeleteVRChild(std::move(aChild))); |
91 | 0 | } |
92 | | |
93 | | } // namespace gfx |
94 | | } // namespace mozilla |