Bug 1497379 - Don't disable OSVR along with OpenVR on BSDs. r=kip
authorJan Beich <jbeich@FreeBSD.org>
Mon, 08 Oct 2018 22:41:00 -0400
changeset 499019 dfe25ffb4ad26ff7807439e2fd26f091f07ace11
parent 499018 5336690f90da7a1b9f08f13930996b205ecb62d1
child 499020 73a17eb4a47cb8d4cf5bef48ce37d850630caaca
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1497379
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497379 - Don't disable OSVR along with OpenVR on BSDs. r=kip
gfx/vr/VRManager.cpp
gfx/vr/VRManager.h
gfx/vr/ipc/VRGPUParent.cpp
gfx/vr/ipc/VRGPUParent.h
gfx/vr/moz.build
gfx/vr/service/VRService.cpp
gfx/vr/service/VRService.h
gfx/vr/service/moz.build
--- a/gfx/vr/VRManager.cpp
+++ b/gfx/vr/VRManager.cpp
@@ -25,17 +25,17 @@
 #include "gfxVROculus.h"
 #endif
 #if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
 #include "gfxVROpenVR.h"
 #endif
 
 #include "gfxVRPuppet.h"
 #include "ipc/VRLayerParent.h"
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
 #include "service/VRService.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 using namespace mozilla::gl;
 
@@ -94,17 +94,17 @@ VRManager::VRManager()
    *
    * OpenvR comes second, as it is the native interface for HTC Vive
    * which is the most common HMD at this time.
    *
    * OSVR will be used if Oculus SDK and OpenVR don't detect any HMDS,
    * to support everyone else.
    */
 
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   // The VR Service accesses all hardware from a separate process
   // and replaces the other VRSystemManager when enabled.
   if (!gfxPrefs::VRProcessEnabled()) {
     mVRService = VRService::Create();
   } else if (gfxPrefs::VRProcessEnabled() && XRE_IsGPUProcess()) {
     gfx::GPUParent* gpu = GPUParent::GetSingleton();
     MOZ_ASSERT(gpu);
     Unused << gpu->SendCreateVRProcess();
@@ -162,34 +162,34 @@ void
 VRManager::Destroy()
 {
   StopTasks();
   mVRDisplays.Clear();
   mVRControllers.Clear();
   for (uint32_t i = 0; i < mManagers.Length(); ++i) {
     mManagers[i]->Destroy();
   }
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   if (mVRService) {
     mVRService->Stop();
     mVRService = nullptr;
   }
 #endif
   mInitialized = false;
 }
 
 void
 VRManager::Shutdown()
 {
   mVRDisplays.Clear();
   mVRControllers.Clear();
   for (uint32_t i = 0; i < mManagers.Length(); ++i) {
     mManagers[i]->Shutdown();
   }
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   if (mVRService) {
     mVRService->Stop();
   }
   if (gfxPrefs::VRProcessEnabled() &&
       VRGPUChild::IsCreated()) {
     RefPtr<Runnable> task = NS_NewRunnableFunction(
       "VRGPUChild::SendStopVRService",
       [] () -> void {
@@ -541,17 +541,17 @@ void
 VRManager::RefreshVRDisplays(bool aMustDispatch)
 {
   /**
   * If we aren't viewing WebVR content, don't enumerate
   * new hardware, as it will cause some devices to power on
   * or interrupt other VR activities.
   */
   if (mVRDisplaysRequested || aMustDispatch) {
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
     // Tell VR process to start VR service.
     if (gfxPrefs::VRProcessEnabled() && !mVRServiceStarted) {
       RefPtr<Runnable> task = NS_NewRunnableFunction(
         "VRGPUChild::SendStartVRService",
         [] () -> void {
           VRGPUChild* vrGPUChild = VRGPUChild::Get();
           vrGPUChild->SendStartVRService();
       });
--- a/gfx/vr/VRManager.h
+++ b/gfx/vr/VRManager.h
@@ -19,17 +19,17 @@ namespace mozilla {
 namespace layers {
 class TextureHost;
 }
 namespace gfx {
 
 class VRLayerParent;
 class VRManagerParent;
 class VRDisplayHost;
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
 class VRService;
 #endif
 class VRSystemManagerPuppet;
 class VRSystemManagerExternal;
 
 class VRManager
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::gfx::VRManager)
@@ -103,17 +103,17 @@ private:
 
   TimeStamp mLastControllerEnumerationTime;
   TimeStamp mLastDisplayEnumerationTime;
   TimeStamp mLastActiveTime;
   TimeStamp mLastTickTime;
   double mAccumulator100ms;
   RefPtr<VRSystemManagerPuppet> mPuppetManager;
   RefPtr<VRSystemManagerExternal> mExternalManager;
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   RefPtr<VRService> mVRService;
 #endif
   bool mVRDisplaysRequested;
   bool mVRControllersRequested;
   bool mVRServiceStarted;
   uint32_t mTaskInterval;
   RefPtr<nsITimer> mTaskTimer;
 };
--- a/gfx/vr/ipc/VRGPUParent.cpp
+++ b/gfx/vr/ipc/VRGPUParent.cpp
@@ -21,17 +21,17 @@ VRGPUParent::VRGPUParent(ProcessId aChil
   MOZ_ASSERT(NS_IsMainThread());
 
   SetOtherProcessId(aChildProcessId);
 }
 
 void
 VRGPUParent::ActorDestroy(ActorDestroyReason aWhy)
 {
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   if (mVRService) {
     mVRService->Stop();
     mVRService = nullptr;
   }
 #endif
 
   MessageLoop::current()->PostTask(
   NewRunnableMethod("gfx::VRGPUParent::DeferredDestroy",
@@ -67,30 +67,30 @@ VRGPUParent::Bind(Endpoint<PVRGPUParent>
   }
 
   mSelfRef = this;
 }
 
 mozilla::ipc::IPCResult
 VRGPUParent::RecvStartVRService()
 {
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   mVRService = VRService::Create();
   MOZ_ASSERT(mVRService);
 
   mVRService->Start();
 #endif
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 VRGPUParent::RecvStopVRService()
 {
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   if (mVRService) {
     mVRService->Stop();
     mVRService = nullptr;
   }
 #endif
 
   return IPC_OK();
 }
--- a/gfx/vr/ipc/VRGPUParent.h
+++ b/gfx/vr/ipc/VRGPUParent.h
@@ -27,17 +27,17 @@ protected:
   void Bind(Endpoint<PVRGPUParent>&& aEndpoint);
   virtual mozilla::ipc::IPCResult RecvStartVRService() override;
   virtual mozilla::ipc::IPCResult RecvStopVRService() override;
 
 private:
   void DeferredDestroy();
 
   RefPtr<VRGPUParent> mSelfRef;
-#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
+#if !defined(MOZ_WIDGET_ANDROID)
   RefPtr<VRService> mVRService;
 #endif
 };
 
 } // namespace gfx
 } // namespace mozilla
 
-#endif // GFX_VR_CONTENT_PARENT_H
\ No newline at end of file
+#endif // GFX_VR_CONTENT_PARENT_H
--- a/gfx/vr/moz.build
+++ b/gfx/vr/moz.build
@@ -60,29 +60,32 @@ SOURCES += [
     'VRDisplayHost.cpp',
     'VRDisplayLocal.cpp',
 ]
 
 # Build OpenVR on Windows, Linux, and macOS desktop targets
 if CONFIG['OS_TARGET'] in ('WINNT', 'Linux', 'Darwin'):
     DIRS += [
         'openvr',
-        'service',
     ]
     SOURCES += [
         'gfxVROpenVR.cpp',
     ]
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     SOURCES += [
         'gfxVROculus.cpp',
     ]
 
 if CONFIG['OS_TARGET'] == 'Android':
     LOCAL_INCLUDES += ['/widget/android']
+else:
+    DIRS += [
+        'service',
+    ]
 
 IPDL_SOURCES = [
     'ipc/PVR.ipdl',
     'ipc/PVRGPU.ipdl',
     'ipc/PVRLayer.ipdl',
     'ipc/PVRManager.ipdl',
 ]
 
--- a/gfx/vr/service/VRService.cpp
+++ b/gfx/vr/service/VRService.cpp
@@ -6,16 +6,18 @@
 
 #include "VRService.h"
 #include "gfxPrefs.h"
 #include "base/thread.h"                // for Thread
 #include <cstring>                      // for memcmp
 
 #if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
 #include "OpenVRSession.h"
+#endif
+#if !defined(MOZ_WIDGET_ANDROID)
 #include "OSVRSession.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace std;
 
 namespace {
@@ -215,16 +217,18 @@ VRService::ServiceInitialize()
 #if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
   // Try OpenVR
   if (!session) {
     session = MakeUnique<OpenVRSession>();
     if (!session->Initialize(mSystemState)) {
       session = nullptr;
     }
   }
+#endif
+#if !defined(MOZ_WIDGET_ANDROID)
   // Try OSVR
   if (!session) {
     session = MakeUnique<OSVRSession>();
     if (!session->Initialize(mSystemState)) {
       session = nullptr;
     }
   }
 #endif
--- a/gfx/vr/service/VRService.h
+++ b/gfx/vr/service/VRService.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_VR_SERVICE_VRSERVICE_H
 #define GFX_VR_SERVICE_VRSERVICE_H
 
 #include "mozilla/Atomics.h"
+#include "base/process.h"               // for ProcessHandle
 
 #include "moz_external_vr.h"
 
 namespace base {
 class Thread;
 } // namespace base
 namespace mozilla {
 namespace gfx {
--- a/gfx/vr/service/moz.build
+++ b/gfx/vr/service/moz.build
@@ -3,25 +3,25 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Build OSVR on all platforms except Android
 if CONFIG['OS_TARGET'] != 'Android':
     UNIFIED_SOURCES += [
         'OSVRSession.cpp',
+        'VRService.cpp',
+        'VRSession.cpp',
     ]
+    include('/ipc/chromium/chromium-config.mozbuild')
 
 # Build OpenVR on Windows, Linux, and macOS desktop targets
 if CONFIG['OS_TARGET'] in ('WINNT', 'Linux', 'Darwin'):
     UNIFIED_SOURCES += [
         'OpenVRSession.cpp',
-        'VRService.cpp',
-        'VRSession.cpp',
     ]
     LOCAL_INCLUDES += [
         '/dom/base',
         '/gfx/layers/d3d11',
         '/gfx/thebes',
     ]
-    include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'