Bug 1550422 - P23. Remove gfxPref sync with VR process. r?daoshengmu! draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 17 May 2019 00:31:48 +1000
changeset 2008599 19bb8e7e59aef087441c5dc53cb8552cee094b32
parent 2008598 917b14906154d94f69611edf2dbec066f25a108e
child 2008600 b043b4ab98105639814878a811d2b3c04593f638
push id363925
push userjyavenard@mozilla.com
push dateSat, 18 May 2019 07:53:18 +0000
treeherdertry@5082cd581229 [default view] [failures only]
reviewersdaoshengmu
bugs1550422
milestone68.0a1
Bug 1550422 - P23. Remove gfxPref sync with VR process. r?daoshengmu! Differential Revision: https://phabricator.services.mozilla.com/D31466
gfx/thebes/gfxPrefs.cpp
gfx/vr/ipc/PVR.ipdl
gfx/vr/ipc/VRChild.cpp
gfx/vr/ipc/VRParent.cpp
gfx/vr/ipc/VRParent.h
--- a/gfx/thebes/gfxPrefs.cpp
+++ b/gfx/thebes/gfxPrefs.cpp
@@ -69,23 +69,16 @@ void gfxPrefs::AssertMainThread() {
 void gfxPrefs::Pref::OnChange() {
   if (auto gpm = gfx::GPUProcessManager::Get()) {
     if (gfx::GPUChild* gpu = gpm->GetGPUChild()) {
       GfxPrefValue value;
       GetLiveValue(&value);
       Unused << gpu->SendUpdatePref(gfx::GfxPrefSetting(mIndex, value));
     }
   }
-  if (auto vpm = gfx::VRProcessManager::Get()) {
-    if (gfx::VRChild* vr = vpm->GetVRChild()) {
-      GfxPrefValue value;
-      GetLiveValue(&value);
-      Unused << vr->SendUpdatePref(gfx::GfxPrefSetting(mIndex, value));
-    }
-  }
   FireChangeCallback();
 }
 
 void gfxPrefs::Pref::FireChangeCallback() {
   if (mChangeCallback) {
     GfxPrefValue value;
     GetLiveValue(&value);
     mChangeCallback(value);
--- a/gfx/vr/ipc/PVR.ipdl
+++ b/gfx/vr/ipc/PVR.ipdl
@@ -17,20 +17,19 @@ include "VRMessageUtils.h";
 
 namespace mozilla {
 namespace gfx {
 
 async protocol PVR
 {
 parent:
   async NewGPUVRManager(Endpoint<PVRGPUParent> endpoint);
-  async Init(GfxPrefSetting[] prefs, GfxVarUpdate[] vars, DevicePrefs devicePrefs);
+  async Init(GfxVarUpdate[] vars, DevicePrefs devicePrefs);
   async NotifyVsync(TimeStamp vsyncTimestamp);
 
-  async UpdatePref(GfxPrefSetting pref);
   async UpdateVar(GfxVarUpdate var);
   async PreferenceUpdate(Pref pref);
   async OpenVRControllerActionPathToVR(nsCString aPath);
   async OpenVRControllerManifestPathToVR(OpenVRControllerType aType, nsCString aPath);
   async RequestMemoryReport(uint32_t generation,
                             bool anonymize,
                             bool minimizeMemoryUsage,
                             FileDescriptor? DMDFile);
--- a/gfx/vr/ipc/VRChild.cpp
+++ b/gfx/vr/ipc/VRChild.cpp
@@ -100,45 +100,28 @@ void VRChild::ActorDestroy(ActorDestroyR
         nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_VR)),
         1);
   }
   gfxVars::RemoveReceiver(this);
   mHost->OnChannelClosed();
 }
 
 void VRChild::Init() {
-  // Build a list of prefs the VR process will need. Note that because we
-  // limit the VR process to prefs contained in gfxPrefs, we can simplify
-  // the message in two ways: one, we only need to send its index in gfxPrefs
-  // rather than its name, and two, we only need to send prefs that don't
-  // have their default value.
-  // Todo: Consider to make our own vrPrefs that we are interested in VR
-  // process.
-  nsTArray<GfxPrefSetting> prefs;
-  for (auto pref : gfxPrefs::all()) {
-    if (pref->HasDefaultValue()) {
-      continue;
-    }
-
-    GfxPrefValue value;
-    pref->GetCachedValue(&value);
-    prefs.AppendElement(GfxPrefSetting(pref->Index(), value));
-  }
   nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();
 
   DevicePrefs devicePrefs;
   devicePrefs.hwCompositing() = gfxConfig::GetValue(Feature::HW_COMPOSITING);
   devicePrefs.d3d11Compositing() =
       gfxConfig::GetValue(Feature::D3D11_COMPOSITING);
   devicePrefs.oglCompositing() =
       gfxConfig::GetValue(Feature::OPENGL_COMPOSITING);
   devicePrefs.advancedLayers() = gfxConfig::GetValue(Feature::ADVANCED_LAYERS);
   devicePrefs.useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D);
 
-  SendInit(prefs, updates, devicePrefs);
+  SendInit(updates, devicePrefs);
 
   if (!sOpenVRControllerManifestManager) {
     sOpenVRControllerManifestManager = new OpenVRControllerManifestManager();
     NS_DispatchToMainThread(NS_NewRunnableFunction(
         "ClearOnShutdown OpenVRControllerManifestManager",
         []() { ClearOnShutdown(&sOpenVRControllerManifestManager); }));
   }
 
--- a/gfx/vr/ipc/VRParent.cpp
+++ b/gfx/vr/ipc/VRParent.cpp
@@ -33,26 +33,20 @@ IPCResult VRParent::RecvNewGPUVRManager(
   if (!vrGPUParent) {
     return IPC_FAIL_NO_REASON(this);
   }
 
   mVRGPUParent = std::move(vrGPUParent);
   return IPC_OK();
 }
 
-IPCResult VRParent::RecvInit(nsTArray<GfxPrefSetting>&& prefs,
-                             nsTArray<GfxVarUpdate>&& vars,
+IPCResult VRParent::RecvInit(nsTArray<GfxVarUpdate>&& vars,
                              const DevicePrefs& devicePrefs) {
   Unused << SendInitComplete();
 
-  const nsTArray<gfxPrefs::Pref*>& globalPrefs = gfxPrefs::all();
-  for (auto& setting : prefs) {
-    gfxPrefs::Pref* pref = globalPrefs[setting.index()];
-    pref->SetCachedValue(setting.value());
-  }
   for (const auto& var : vars) {
     gfxVars::ApplyUpdate(var);
   }
 
   // Inherit device preferences.
   gfxConfig::Inherit(Feature::HW_COMPOSITING, devicePrefs.hwCompositing());
   gfxConfig::Inherit(Feature::D3D11_COMPOSITING,
                      devicePrefs.d3d11Compositing());
@@ -69,22 +63,16 @@ IPCResult VRParent::RecvInit(nsTArray<Gf
 }
 
 IPCResult VRParent::RecvNotifyVsync(const TimeStamp& vsyncTimestamp) {
   VRManager* vm = VRManager::Get();
   vm->NotifyVsync(vsyncTimestamp);
   return IPC_OK();
 }
 
-IPCResult VRParent::RecvUpdatePref(const GfxPrefSetting& setting) {
-  gfxPrefs::Pref* pref = gfxPrefs::all()[setting.index()];
-  pref->SetCachedValue(setting.value());
-  return IPC_OK();
-}
-
 IPCResult VRParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) {
   gfxVars::ApplyUpdate(aUpdate);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult VRParent::RecvPreferenceUpdate(const Pref& aPref) {
   Preferences::SetPreference(aPref);
   return IPC_OK();
--- a/gfx/vr/ipc/VRParent.h
+++ b/gfx/vr/ipc/VRParent.h
@@ -31,21 +31,19 @@ class VRParent final : public PVRParent 
   bool GetOpenVRControllerManifestPath(OpenVRControllerType aType,
                                        nsCString* aPath);
 
  protected:
   ~VRParent() = default;
 
   mozilla::ipc::IPCResult RecvNewGPUVRManager(
       Endpoint<PVRGPUParent>&& aEndpoint);
-  mozilla::ipc::IPCResult RecvInit(nsTArray<GfxPrefSetting>&& prefs,
-                                   nsTArray<GfxVarUpdate>&& vars,
+  mozilla::ipc::IPCResult RecvInit(nsTArray<GfxVarUpdate>&& vars,
                                    const DevicePrefs& devicePrefs);
   mozilla::ipc::IPCResult RecvNotifyVsync(const TimeStamp& vsyncTimestamp);
-  mozilla::ipc::IPCResult RecvUpdatePref(const GfxPrefSetting& setting);
   mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref);
   mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref);
   mozilla::ipc::IPCResult RecvOpenVRControllerActionPathToVR(
       const nsCString& aPath);
   mozilla::ipc::IPCResult RecvOpenVRControllerManifestPathToVR(
       const OpenVRControllerType& aType, const nsCString& aPath);
   mozilla::ipc::IPCResult RecvRequestMemoryReport(
       const uint32_t& generation, const bool& anonymize,