From a6cc14939e75eacfef7e00504f80c71b4ce6e505 Mon Sep 17 00:00:00 2001 From: Fedor Date: Fri, 6 Oct 2023 19:14:50 +0300 Subject: [PATCH] Disable vr --- dom/base/Document.cpp | 2 + dom/base/Element.cpp | 4 +- dom/base/Navigator.cpp | 14 +++++-- dom/base/Navigator.h | 8 ++++ dom/base/nsGlobalWindowInner.cpp | 38 ++++++++++++++++--- dom/base/nsGlobalWindowInner.h | 12 ++++++ dom/base/nsGlobalWindowOuter.cpp | 27 ++++++++++---- dom/base/nsGlobalWindowOuter.h | 6 +++ dom/canvas/WebGLContext.cpp | 12 +++++- dom/canvas/WebGLContext.h | 8 +++- dom/events/EventNameList.h | 2 + dom/gamepad/GamepadManager.cpp | 14 ++++++- dom/gamepad/GamepadManager.h | 2 + dom/html/HTMLCanvasElement.cpp | 6 ++- dom/html/HTMLCanvasElement.h | 4 ++ dom/ipc/BrowserChild.cpp | 8 +++- dom/ipc/ContentChild.cpp | 12 +++++- dom/ipc/ContentChild.h | 4 ++ dom/ipc/ContentParent.cpp | 24 ++++++++++-- dom/ipc/PContent.ipdl | 6 +++ dom/ipc/moz.build | 5 ++- dom/moz.build | 4 +- dom/webidl/Gamepad.webidl | 2 + dom/webidl/Navigator.webidl | 2 + dom/webidl/Window.webidl | 2 + dom/webidl/moz.build | 12 ++++-- gfx/gl/SharedSurface.cpp | 4 +- gfx/ipc/GPUChild.cpp | 6 ++- gfx/ipc/GPUChild.h | 2 + gfx/ipc/GPUParent.cpp | 16 ++++++-- gfx/ipc/GPUParent.h | 8 ++-- gfx/ipc/GPUProcessHost.cpp | 6 ++- gfx/ipc/GPUProcessManager.cpp | 20 ++++++++-- gfx/ipc/GPUProcessManager.h | 8 ++++ gfx/ipc/PGPU.ipdl | 15 ++++++-- gfx/ipc/moz.build | 5 ++- gfx/layers/d3d9/CompositorD3D9.cpp | 41 --------------------- gfx/layers/d3d9/DeviceManagerD3D9.cpp | 27 -------------- gfx/layers/d3d9/DeviceManagerD3D9.h | 9 ----- gfx/layers/ipc/CompositorBridgeParent.cpp | 4 +- gfx/layers/ipc/CompositorThread.cpp | 4 ++ gfx/layers/ipc/CompositorVsyncScheduler.cpp | 25 +++++++++++-- gfx/layers/ipc/CompositorVsyncScheduler.h | 9 ++++- gfx/layers/moz.build | 1 - gfx/moz.build | 4 +- gfx/thebes/DeviceManagerDx.cpp | 8 ++++ gfx/thebes/DeviceManagerDx.h | 6 +++ gfx/thebes/gfxEnv.h | 4 ++ gfx/thebes/gfxPlatform.cpp | 20 ++++++++-- modules/libpref/init/StaticPrefList.yaml | 3 ++ toolkit/xre/nsAppRunner.cpp | 2 + toolkit/xre/nsEmbedFunctions.cpp | 8 +++- widget/EventMessageList.h | 2 + widget/nsBaseWidget.cpp | 8 +++- xpcom/base/nsMemoryReporterManager.cpp | 6 ++- xpcom/ds/StaticAtoms.py | 5 --- 56 files changed, 376 insertions(+), 150 deletions(-) diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 5bd2d611f2..ba14406b5e 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -10199,12 +10199,14 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest, ret = false; } #endif +#ifdef MOZ_VR if (globalWindow->HasUsedVR()) { MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose, ("Save of %s blocked due to having used VR", uri.get())); aBFCacheCombo |= BFCacheStatus::HAS_USED_VR; ret = false; } +#endif } return ret; diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 1e4f79b442..432a36ba3b 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -138,7 +138,9 @@ #include "mozilla/dom/KeyframeEffect.h" #include "mozilla/dom/MouseEventBinding.h" #include "mozilla/dom/WindowBinding.h" -#include "mozilla/dom/VRDisplay.h" +#ifdef MOZ_VR +# include "mozilla/dom/VRDisplay.h" +#endif #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/Preferences.h" #include "nsComputedDOMStyle.h" diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 2845bc7d32..cfaafbabde 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -45,9 +45,11 @@ #include "mozilla/dom/StorageManager.h" #include "mozilla/dom/TCPSocket.h" #include "mozilla/dom/URLSearchParams.h" -#include "mozilla/dom/VRDisplay.h" -#include "mozilla/dom/VRDisplayEvent.h" -#include "mozilla/dom/VRServiceTest.h" +#ifdef MOZ_VR +# include "mozilla/dom/VRDisplay.h" +# include "mozilla/dom/VRDisplayEvent.h" +# include "mozilla/dom/VRServiceTest.h" +#endif #include "mozilla/dom/workerinternals/RuntimeService.h" #include "mozilla/Hal.h" #include "mozilla/ClearOnShutdown.h" @@ -159,8 +161,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeySystemAccessManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresentation) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepadServiceTest) +#ifdef MOZ_VR NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRGetDisplaysPromises) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRServiceTest) +#endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(Navigator) @@ -216,12 +220,14 @@ void Navigator::Invalidate() { mGamepadServiceTest = nullptr; } +#ifdef MOZ_VR mVRGetDisplaysPromises.Clear(); if (mVRServiceTest) { mVRServiceTest->Shutdown(); mVRServiceTest = nullptr; } +#endif mMediaCapabilities = nullptr; @@ -1325,6 +1331,7 @@ GamepadServiceTest* Navigator::RequestGamepadServiceTest() { return mGamepadServiceTest; } +#ifdef MOZ_VR already_AddRefed Navigator::GetVRDisplays(ErrorResult& aRv) { if (!mWindow || !mWindow->GetDocShell() || !mWindow->GetExtantDoc()) { aRv.Throw(NS_ERROR_UNEXPECTED); @@ -1431,6 +1438,7 @@ void Navigator::RequestVRPresentation(VRDisplay& aDisplay) { win->DispatchVRDisplayActivate(aDisplay.DisplayId(), VRDisplayEventReason::Requested); } +#endif // MOZ_VR already_AddRefed Navigator::RequestMIDIAccess( const MIDIOptions& aOptions, ErrorResult& aRv) { diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 837ffa15e8..9ec96032c2 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -75,8 +75,10 @@ class Connection; class Presentation; class LegacyMozTCPSocket; +#ifdef MOZ_VR class VRDisplay; class VRServiceTest; +#endif class StorageManager; class MediaCapabilities; @@ -172,12 +174,14 @@ class Navigator final : public nsISupports, public nsWrapperCache { void GetGamepads(nsTArray>& aGamepads, ErrorResult& aRv); GamepadServiceTest* RequestGamepadServiceTest(); +#ifdef MOZ_VR already_AddRefed GetVRDisplays(ErrorResult& aRv); void GetActiveVRDisplays(nsTArray>& aDisplays) const; VRServiceTest* RequestVRServiceTest(); bool IsWebVRContentDetected() const; bool IsWebVRContentPresenting() const; void RequestVRPresentation(VRDisplay& aDisplay); +#endif already_AddRefed RequestMIDIAccess(const MIDIOptions& aOptions, ErrorResult& aRv); @@ -238,9 +242,11 @@ class Navigator final : public nsISupports, public nsWrapperCache { private: RefPtr mMediaKeySystemAccessManager; +#ifdef MOZ_VR public: void NotifyVRDisplaysUpdated(); void NotifyActiveVRDisplaysChanged(); +#endif private: virtual ~Navigator(); @@ -270,8 +276,10 @@ class Navigator final : public nsISupports, public nsWrapperCache { nsCOMPtr mWindow; RefPtr mPresentation; RefPtr mGamepadServiceTest; +#ifdef MOZ_VR nsTArray> mVRGetDisplaysPromises; RefPtr mVRServiceTest; +#endif nsTArray mRequestedVibrationPattern; RefPtr mStorageManager; RefPtr mMediaCapabilities; diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 5165ad2339..5912007804 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -183,11 +183,13 @@ #include "mozilla/dom/Gamepad.h" #include "mozilla/dom/GamepadManager.h" -#include "gfxVR.h" -#include "mozilla/dom/VRDisplay.h" -#include "mozilla/dom/VRDisplayEvent.h" -#include "mozilla/dom/VRDisplayEventBinding.h" -#include "mozilla/dom/VREventObserver.h" +#ifdef MOZ_VR +# include "gfxVR.h" +# include "mozilla/dom/VRDisplay.h" +# include "mozilla/dom/VRDisplayEvent.h" +# include "mozilla/dom/VRDisplayEventBinding.h" +# include "mozilla/dom/VREventObserver.h" +#endif #include "nsRefreshDriver.h" #include "Layers.h" @@ -833,9 +835,11 @@ nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow) mFocusByKeyOccurred(false), mDidFireDocElemInserted(false), mHasGamepad(false), - mHasVREvents(false), mHintedWasLoading(false), +#ifdef MOZ_VR + mHasVREvents(false), mHasVRDisplayActivateEvents(false), +#endif mHasSeenGamepadInput(false), mSuspendDepth(0), mFreezeDepth(0), @@ -1147,10 +1151,12 @@ void nsGlobalWindowInner::FreeInnerObjects() { DisableGamepadUpdates(); mHasGamepad = false; mGamepads.Clear(); +#ifdef MOZ_VR DisableVRUpdates(); mHasVREvents = false; mHasVRDisplayActivateEvents = false; mVRDisplays.Clear(); +#endif // This breaks a cycle between the window and the ClientSource object. mClientSource.reset(); @@ -1345,7 +1351,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowInner) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepads) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheStorage) +#ifdef MOZ_VR NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRDisplays) +#endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDebuggerNotificationManager) @@ -1447,7 +1455,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner) NS_IMPL_CYCLE_COLLECTION_UNLINK(mGamepads) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheStorage) +#ifdef MOZ_VR NS_IMPL_CYCLE_COLLECTION_UNLINK(mVRDisplays) +#endif NS_IMPL_CYCLE_COLLECTION_UNLINK(mDebuggerNotificationManager) @@ -1925,6 +1935,7 @@ nsresult nsGlobalWindowInner::PostHandleEvent(EventChainPostVisitor& aVisitor) { // will receive a vrdisplayactive event to indicate that it should // immediately begin vr presentation. This should occur when navigating // forwards, navigating backwards, and on page reload. +#ifdef MOZ_VR for (const auto& display : mVRDisplays) { if (display->IsPresenting()) { display->StartVRNavigation(); @@ -1942,6 +1953,7 @@ nsresult nsGlobalWindowInner::PostHandleEvent(EventChainPostVisitor& aVisitor) { break; } } +#endif // Execute bindingdetached handlers before we tear ourselves // down. if (mDoc) { @@ -1984,6 +1996,7 @@ nsresult nsGlobalWindowInner::PostHandleEvent(EventChainPostVisitor& aVisitor) { } } +#ifdef MOZ_VR if (mVREventObserver) { mVREventObserver->NotifyAfterLoad(); } @@ -1997,6 +2010,7 @@ nsresult nsGlobalWindowInner::PostHandleEvent(EventChainPostVisitor& aVisitor) { DispatchVRDisplayActivate(autoActivateVRDisplayID, VRDisplayEventReason::Navigation); } +#endif } return NS_OK; @@ -4013,6 +4027,7 @@ void nsGlobalWindowInner::DisableGamepadUpdates() { } } +#ifdef MOZ_VR void nsGlobalWindowInner::EnableVRUpdates() { if (mHasVREvents && !mVREventObserver) { mVREventObserver = new VREventObserver(this); @@ -4043,6 +4058,7 @@ void nsGlobalWindowInner::StopVRActivity() { mVREventObserver->StopActivity(); } } +#endif #ifndef XP_WIN // This guard should match the guard at the callsite. static bool ShouldShowFocusRingIfFocusedByMouse(nsIContent* aNode) { @@ -5127,7 +5143,9 @@ void nsGlobalWindowInner::Suspend() { ac->RemoveWindowListener(mEnabledSensors[i], this); } DisableGamepadUpdates(); +#ifdef MOZ_VR DisableVRUpdates(); +#endif SuspendWorkersForWindow(this); @@ -5180,7 +5198,9 @@ void nsGlobalWindowInner::Resume() { ac->AddWindowListener(mEnabledSensors[i], this); } EnableGamepadUpdates(); +#ifdef MOZ_VR EnableVRUpdates(); +#endif // Resume all of the AudioContexts for this window for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) { @@ -5979,6 +5999,7 @@ void nsGlobalWindowInner::SetHasGamepadEventListener( } void nsGlobalWindowInner::EventListenerAdded(nsAtom* aType) { +#ifdef MOZ_VR if (aType == nsGkAtoms::onvrdisplayactivate || aType == nsGkAtoms::onvrdisplayconnect || aType == nsGkAtoms::onvrdisplaydeactivate || @@ -5990,6 +6011,7 @@ void nsGlobalWindowInner::EventListenerAdded(nsAtom* aType) { if (aType == nsGkAtoms::onvrdisplayactivate) { mHasVRDisplayActivateEvents = true; } +#endif if (aType == nsGkAtoms::onbeforeunload && mBrowserChild && (!mDoc || !(mDoc->GetSandboxFlags() & SANDBOXED_MODALS))) { @@ -6035,6 +6057,7 @@ void nsGlobalWindowInner::EventListenerRemoved(nsAtom* aType) { } } +#ifdef MOZ_VR void nsGlobalWindowInner::NotifyVREventListenerAdded() { mHasVREvents = true; EnableVRUpdates(); @@ -6060,6 +6083,7 @@ bool nsGlobalWindowInner::IsVRContentPresenting() const { } return false; } +#endif void nsGlobalWindowInner::AddSizeOfIncludingThis( nsWindowSizes& aWindowSizes) const { @@ -6183,6 +6207,7 @@ void nsGlobalWindowInner::StopGamepadHaptics() { } } +#ifdef MOZ_VR bool nsGlobalWindowInner::UpdateVRDisplays( nsTArray>& aDevices) { VRDisplay::UpdateVRDisplays(mVRDisplays, this); @@ -6352,6 +6377,7 @@ void nsGlobalWindowInner::DispatchVRDisplayPresentChange(uint32_t aDisplayID) { } } } +#endif // MOZ_VR enum WindowState { // These constants need to match the constants in Window.webidl diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index 23abaf5c01..4de135d7ff 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -127,9 +127,11 @@ class TabGroup; class Timeout; class U2F; class VisualViewport; +#ifdef MOZ_VR class VRDisplay; enum class VRDisplayEventReason : uint8_t; class VREventObserver; +#endif class WakeLock; #if defined(MOZ_WIDGET_ANDROID) class WindowOrientationObserver; @@ -369,10 +371,12 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, // Inner windows only. virtual void SetHasGamepadEventListener(bool aHasGamepad = true) override; +#ifdef MOZ_VR void NotifyVREventListenerAdded(); bool HasUsedVR() const; bool IsVRContentDetected() const; bool IsVRContentPresenting() const; +#endif using EventTarget::EventListenerAdded; virtual void EventListenerAdded(nsAtom* aType) override; @@ -513,6 +517,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, // Inner windows only. // Enable/disable updates for VR +#ifdef MOZ_VR void EnableVRUpdates(); void DisableVRUpdates(); // Reset telemetry data when switching windows. @@ -538,6 +543,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, void DispatchVRDisplayConnect(uint32_t aDisplayID); void DispatchVRDisplayDisconnect(uint32_t aDisplayID); void DispatchVRDisplayPresentChange(uint32_t aDisplayID); +#endif #define EVENT(name_, id_, type_, struct_) \ mozilla::dom::EventHandlerNonNull* GetOn##name_() { \ @@ -1299,13 +1305,17 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, bool mHasGamepad : 1; // Indicates whether this window wants VR events +#ifdef MOZ_VR bool mHasVREvents : 1; +#endif // Whether we told the JS engine that we were in pageload. bool mHintedWasLoading : 1; // Indicates whether this window wants VRDisplayActivate events +#ifdef MOZ_VR bool mHasVRDisplayActivateEvents : 1; +#endif nsCheapSet mGamepadIndexSet; nsRefPtrHashtable mGamepads; bool mHasSeenGamepadInput; @@ -1422,9 +1432,11 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, uint32_t mCanSkipCCGeneration; // The VR Displays for this window +#ifdef MOZ_VR nsTArray> mVRDisplays; RefPtr mVREventObserver; +#endif int64_t mBeforeUnloadListenerCount; diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index abf8273358..f9764edf5f 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -187,11 +187,13 @@ #include "mozilla/dom/Gamepad.h" #include "mozilla/dom/GamepadManager.h" -#include "gfxVR.h" -#include "mozilla/dom/VRDisplay.h" -#include "mozilla/dom/VRDisplayEvent.h" -#include "mozilla/dom/VRDisplayEventBinding.h" -#include "mozilla/dom/VREventObserver.h" +#ifdef MOZ_VR +# include "gfxVR.h" +# include "mozilla/dom/VRDisplay.h" +# include "mozilla/dom/VRDisplayEvent.h" +# include "mozilla/dom/VRDisplayEventBinding.h" +# include "mozilla/dom/VREventObserver.h" +#endif #include "nsRefreshDriver.h" #include "Layers.h" @@ -1113,8 +1115,11 @@ nsGlobalWindowOuter::nsGlobalWindowOuter(uint64_t aWindowID) #ifdef DEBUG mIsValidatingTabGroup(false), #endif - mCanSkipCCGeneration(0), - mAutoActivateVRDisplayID(0) { + mCanSkipCCGeneration(0) +#ifdef MOZ_VR + , mAutoActivateVRDisplayID(0) +#endif + { AssertIsOnMainThread(); nsLayoutStatics::AddRef(); @@ -6840,10 +6845,12 @@ void nsGlobalWindowOuter::SetIsBackground(bool aIsBackground) { // the background window. if (inner && changed) { inner->StopGamepadHaptics(); +#ifdef MOZ_VR inner->StopVRActivity(); // true is for asking to set the delta time to // the telemetry. inner->ResetVRTelemetry(true); +#endif } return; } @@ -6851,9 +6858,11 @@ void nsGlobalWindowOuter::SetIsBackground(bool aIsBackground) { if (inner) { // When switching to be as a top tab, restart the telemetry. // false is for only resetting the timestamp. +#ifdef MOZ_VR inner->ResetVRTelemetry(false); - inner->SyncGamepadState(); inner->StartVRActivity(); +#endif + inner->SyncGamepadState(); } } @@ -7506,6 +7515,7 @@ void nsGlobalWindowOuter::AddSizeOfIncludingThis( aWindowSizes.mDOMOtherSize += aWindowSizes.mState.mMallocSizeOf(this); } +#ifdef MOZ_VR uint32_t nsGlobalWindowOuter::GetAutoActivateVRDisplayID() { uint32_t retVal = mAutoActivateVRDisplayID; mAutoActivateVRDisplayID = 0; @@ -7516,6 +7526,7 @@ void nsGlobalWindowOuter::SetAutoActivateVRDisplayID( uint32_t aAutoActivateVRDisplayID) { mAutoActivateVRDisplayID = aAutoActivateVRDisplayID; } +#endif already_AddRefed nsGlobalWindowOuter::GetWindowRootOuter() { nsCOMPtr root = GetTopWindowRoot(); diff --git a/dom/base/nsGlobalWindowOuter.h b/dom/base/nsGlobalWindowOuter.h index 0996e929ba..75a9e2b63a 100644 --- a/dom/base/nsGlobalWindowOuter.h +++ b/dom/base/nsGlobalWindowOuter.h @@ -113,9 +113,11 @@ class SpeechSynthesis; class TabGroup; class Timeout; class U2F; +#ifdef MOZ_VR class VRDisplay; enum class VRDisplayEventReason : uint8_t; class VREventObserver; +#endif class WakeLock; #if defined(MOZ_WIDGET_ANDROID) class WindowOrientationObserver; @@ -468,9 +470,11 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget, void AllowScriptsToClose() { mAllowScriptsToClose = true; } // Outer windows only. +#ifdef MOZ_VR uint32_t GetAutoActivateVRDisplayID(); // Outer windows only. void SetAutoActivateVRDisplayID(uint32_t aAutoActivateVRDisplayID); +#endif #define EVENT(name_, id_, type_, struct_) \ mozilla::dom::EventHandlerNonNull* GetOn##name_() { \ @@ -1133,7 +1137,9 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget, // When non-zero, the document should receive a vrdisplayactivate event // after loading. The value is the ID of the VRDisplay that content should // begin presentation on. +#ifdef MOZ_VR uint32_t mAutoActivateVRDisplayID; +#endif static OuterWindowByIdTable* sOuterWindowsById; diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 9c19a1a0e2..d2f5c901a8 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -46,7 +46,9 @@ #include "SVGObserverUtils.h" #include "prenv.h" #include "ScopedGLHelpers.h" -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +#endif #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/TextureClientSharedSurface.h" #include "mozilla/layers/WebRenderUserData.h" @@ -134,7 +136,9 @@ WebGLContext::WebGLContext() mDisableExtensions = false; mIsMesa = false; mWebGLError = 0; +#ifdef MOZ_VR mVRReady = false; +#endif mViewportX = 0; mViewportY = 0; @@ -219,7 +223,7 @@ void WebGLContext::DestroyResourcesAndContext() { mDefaultVertexArray = nullptr; mBoundTransformFeedback = nullptr; mDefaultTransformFeedback = nullptr; -#if defined(MOZ_WIDGET_ANDROID) +#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_VR) mVRScreen = nullptr; #endif @@ -1217,7 +1221,9 @@ bool WebGLContext::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder, aRenderer->Initialize(data); aRenderer->SetDirty(); +#ifdef MOZ_VR mVRReady = true; +#endif return true; } @@ -2115,6 +2121,7 @@ CheckedUint32 WebGLContext::GetUnpackSize(bool isFunc3D, uint32_t width, return totalBytes; } +#ifdef MOZ_VR #if defined(MOZ_WIDGET_ANDROID) already_AddRefed WebGLContext::GetVRFrame() { @@ -2209,6 +2216,7 @@ void WebGLContext::EnsureVRReady() { mVRReady = true; } } +#endif // MOZ_VR //////////////////////////////////////////////////////////////////////////////// diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index 49c5fed410..cc87749f03 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -86,7 +86,9 @@ struct WebGLContextAttributes; namespace gfx { class SourceSurface; +#ifdef MOZ_VR class VRLayerChild; +#endif } // namespace gfx namespace gl { @@ -692,8 +694,10 @@ class WebGLContext : public nsICanvasRenderingContextInternal, void PixelStorei(GLenum pname, GLint param); void PolygonOffset(GLfloat factor, GLfloat units); +#ifdef MOZ_VR already_AddRefed GetVRFrame(); void EnsureVRReady(); +#endif //// @@ -1477,7 +1481,9 @@ class WebGLContext : public nsICanvasRenderingContextInternal, bool mCanLoseContextInForeground; bool mShouldPresent; bool mDisableFragHighP; +#ifdef MOZ_VR bool mVRReady; +#endif template void DeleteWebGLObjectsArray(nsTArray& array); @@ -1946,7 +1952,7 @@ class WebGLContext : public nsICanvasRenderingContextInternal, bool mNeedsIndexValidation = false; const bool mAllowFBInvalidation; -#if defined(MOZ_WIDGET_ANDROID) +#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_VR) UniquePtr mVRScreen; #endif diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index 2560d8ae2a..86a85417d2 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -328,6 +328,7 @@ WINDOW_ONLY_EVENT(userproximity, eUserProximity, EventNameType_None, eBasicEventClass) WINDOW_ONLY_EVENT(devicelight, eDeviceLight, EventNameType_None, eBasicEventClass) +#ifdef MOZ_VR WINDOW_ONLY_EVENT(vrdisplayactivate, eVRDisplayActivate, EventNameType_None, eBasicEventClass) WINDOW_ONLY_EVENT(vrdisplaydeactivate, eVRDisplayDeactivate, EventNameType_None, @@ -338,6 +339,7 @@ WINDOW_ONLY_EVENT(vrdisplaydisconnect, eVRDisplayDisconnect, EventNameType_None, eBasicEventClass) WINDOW_ONLY_EVENT(vrdisplaypresentchange, eVRDisplayPresentChange, EventNameType_None, eBasicEventClass) +#endif // Install events as per W3C Manifest spec WINDOW_ONLY_EVENT(appinstalled, eAppInstalled, EventNameType_None, eBasicEventClass) diff --git a/dom/gamepad/GamepadManager.cpp b/dom/gamepad/GamepadManager.cpp index 6e543a1311..cab3915f55 100644 --- a/dom/gamepad/GamepadManager.cpp +++ b/dom/gamepad/GamepadManager.cpp @@ -24,7 +24,9 @@ #include "nsIObserver.h" #include "nsIObserverService.h" #include "nsThreadUtils.h" -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +#endif #include "mozilla/Services.h" #include "mozilla/Unused.h" @@ -93,10 +95,12 @@ void GamepadManager::StopMonitoring() { for (uint32_t i = 0; i < mChannelChildren.Length(); ++i) { mChannelChildren[i]->SendGamepadListenerRemoved(); } +#ifdef MOZ_VR if (gfx::VRManagerChild::IsCreated()) { gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); vm->SendControllerListenerRemoved(); } +#endif mChannelChildren.Clear(); mGamepads.Clear(); } @@ -136,12 +140,14 @@ void GamepadManager::AddListener(nsGlobalWindowInner* aWindow) { child->SendGamepadListenerAdded(); mChannelChildren.AppendElement(child); +#ifdef MOZ_VR if (gfx::VRManagerChild::IsCreated()) { // Construct VRManagerChannel and ask adding the connected // VR controllers to GamepadManager gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); vm->SendControllerListenerAdded(); } +#endif } if (!mEnabled || mShuttingDown || @@ -203,9 +209,11 @@ uint32_t GamepadManager::GetGamepadIndexWithServiceType( MOZ_ASSERT(aIndex <= VR_GAMEPAD_IDX_OFFSET); newIndex = aIndex; break; +#ifdef MOZ_VR case GamepadServiceType::VR: newIndex = aIndex + VR_GAMEPAD_IDX_OFFSET; break; +#endif default: MOZ_ASSERT(false); break; @@ -579,6 +587,7 @@ already_AddRefed GamepadManager::VibrateHaptic( } if (Preferences::GetBool(kGamepadHapticEnabledPref)) { if (aControllerIdx >= VR_GAMEPAD_IDX_OFFSET) { +#ifdef MOZ_VR if (gfx::VRManagerChild::IsCreated()) { const uint32_t index = aControllerIdx - VR_GAMEPAD_IDX_OFFSET; gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); @@ -586,6 +595,7 @@ already_AddRefed GamepadManager::VibrateHaptic( vm->SendVibrateHaptic(index, aHapticIndex, aIntensity, aDuration, mPromiseID); } +#endif } else { for (const auto& channelChild : mChannelChildren) { channelChild->AddPromise(mPromiseID, promise); @@ -608,11 +618,13 @@ void GamepadManager::StopHaptics() { for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) { const uint32_t gamepadIndex = iter.UserData()->HashKey(); if (gamepadIndex >= VR_GAMEPAD_IDX_OFFSET) { +#ifdef MOZ_VR if (gfx::VRManagerChild::IsCreated()) { const uint32_t index = gamepadIndex - VR_GAMEPAD_IDX_OFFSET; gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); vm->SendStopVibrateHaptic(index); } +#endif } else { for (auto& channelChild : mChannelChildren) { channelChild->SendStopVibrateHaptic(gamepadIndex); diff --git a/dom/gamepad/GamepadManager.h b/dom/gamepad/GamepadManager.h index bb1fd86f9e..490768afaf 100644 --- a/dom/gamepad/GamepadManager.h +++ b/dom/gamepad/GamepadManager.h @@ -13,9 +13,11 @@ class nsGlobalWindowInner; namespace mozilla { +#ifdef MOZ_VR namespace gfx { class VRManagerChild; } // namespace gfx +#endif namespace dom { class EventTarget; diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index e4175951dd..037330f4cc 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -42,7 +42,9 @@ #include "nsStreamUtils.h" #include "ActiveLayerTracker.h" #include "CanvasUtils.h" -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +#endif #include "WebGL1Context.h" #include "WebGL2Context.h" @@ -1415,6 +1417,7 @@ void HTMLCanvasElement::InvalidateFromAsyncCanvasRenderer( element->InvalidateCanvasContent(nullptr); } +#ifdef MOZ_VR already_AddRefed HTMLCanvasElement::GetVRFrame() { if (GetCurrentContextType() != CanvasContextType::WebGL1 && @@ -1429,6 +1432,7 @@ HTMLCanvasElement::GetVRFrame() { return webgl->GetVRFrame(); } +#endif } // namespace dom } // namespace mozilla diff --git a/dom/html/HTMLCanvasElement.h b/dom/html/HTMLCanvasElement.h index 77e112845d..ea7d20b212 100644 --- a/dom/html/HTMLCanvasElement.h +++ b/dom/html/HTMLCanvasElement.h @@ -37,7 +37,9 @@ class WebRenderCanvasData; } // namespace layers namespace gfx { class SourceSurface; +#ifdef MOZ_VR class VRLayerChild; +#endif } // namespace gfx namespace dom { @@ -326,7 +328,9 @@ class HTMLCanvasElement final : public nsGenericHTMLElement, static void SetAttrFromAsyncCanvasRenderer(AsyncCanvasRenderer* aRenderer); static void InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer* aRenderer); +#ifdef MOZ_VR already_AddRefed GetVRFrame(); +#endif bool MaybeModified() const { return mMaybeModified; }; diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 9c495e06c4..29d91c2bf2 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -109,7 +109,9 @@ #include "nsDeviceContext.h" #include "nsSandboxFlags.h" #include "FrameLayerBuilder.h" -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +#endif #include "nsCommandParams.h" #include "nsISHEntry.h" #include "nsISHistory.h" @@ -2648,7 +2650,9 @@ void BrowserChild::InitRenderingState( MOZ_ASSERT(mLayersConnected == Some(true)); // Succeeded to create "remote" layer manager ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier); +#ifdef MOZ_VR gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier); +#endif InitAPZState(); RefPtr lm = mPuppetWidget->GetLayerManager(); MOZ_ASSERT(lm); @@ -3023,7 +3027,9 @@ void BrowserChild::ReinitRendering() { mLayersConnected = Some(true); ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier); +#ifdef MOZ_VR gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier); +#endif InitAPZState(); RefPtr lm = mPuppetWidget->GetLayerManager(); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index c4a20e2601..bc5c594a60 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -242,7 +242,9 @@ #include "gfxPlatform.h" #include "gfxPlatformFontList.h" #include "nscore.h" // for NS_FREE_PERMANENT_DATA -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +#endif #include "private/pprio.h" #include "nsString.h" #include "MMPrinter.h" @@ -1432,7 +1434,9 @@ void CGSShutdownServerConnections(); mozilla::ipc::IPCResult ContentChild::RecvInitRendering( Endpoint&& aCompositor, Endpoint&& aImageBridge, +#ifdef MOZ_VR Endpoint&& aVRBridge, +#endif Endpoint&& aVideoManager, nsTArray&& namespaces) { MOZ_ASSERT(namespaces.Length() == 3); @@ -1454,9 +1458,11 @@ mozilla::ipc::IPCResult ContentChild::RecvInitRendering( namespaces[2])) { return GetResultForRenderingInitFailure(aImageBridge.OtherPid()); } +#ifdef MOZ_VR if (!gfx::VRManagerChild::InitForContent(std::move(aVRBridge))) { return GetResultForRenderingInitFailure(aVRBridge.OtherPid()); } +#endif RemoteDecoderManagerChild::InitForGPUProcess(std::move(aVideoManager)); #if defined(XP_MACOSX) && !defined(MOZ_SANDBOX) @@ -1474,7 +1480,9 @@ mozilla::ipc::IPCResult ContentChild::RecvInitRendering( mozilla::ipc::IPCResult ContentChild::RecvReinitRendering( Endpoint&& aCompositor, Endpoint&& aImageBridge, +#ifdef MOZ_VR Endpoint&& aVRBridge, +#endif Endpoint&& aVideoManager, nsTArray&& namespaces) { MOZ_ASSERT(namespaces.Length() == 3); @@ -1498,9 +1506,11 @@ mozilla::ipc::IPCResult ContentChild::RecvReinitRendering( namespaces[2])) { return GetResultForRenderingInitFailure(aImageBridge.OtherPid()); } +#ifdef MOZ_VR if (!gfx::VRManagerChild::ReinitForContent(std::move(aVRBridge))) { return GetResultForRenderingInitFailure(aVRBridge.OtherPid()); } +#endif gfxPlatform::GetPlatform()->CompositorUpdated(); // Establish new PLayerTransactions. diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 22379017e4..dcde17f94a 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -173,7 +173,9 @@ class ContentChild final : public PContentChild, mozilla::ipc::IPCResult RecvInitRendering( Endpoint&& aCompositor, Endpoint&& aImageBridge, +#ifdef MOZ_VR Endpoint&& aVRBridge, +#endif Endpoint&& aVideoManager, nsTArray&& namespaces); @@ -182,7 +184,9 @@ class ContentChild final : public PContentChild, mozilla::ipc::IPCResult RecvReinitRendering( Endpoint&& aCompositor, Endpoint&& aImageBridge, +#ifdef MOZ_VR Endpoint&& aVRBridge, +#endif Endpoint&& aVideoManager, nsTArray&& namespaces); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index c491cc204f..d6e004aaba 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2365,17 +2365,25 @@ void ContentParent::InitInternal(ProcessPriority aInitialPriority) { Endpoint compositor; Endpoint imageBridge; +#ifdef MOZ_VR Endpoint vrBridge; +#endif Endpoint videoManager; AutoTArray namespaces; DebugOnly opened = gpm->CreateContentBridges(OtherPid(), &compositor, &imageBridge, - &vrBridge, &videoManager, &namespaces); +#ifdef MOZ_VR + &vrBridge, +#endif + &videoManager, &namespaces); MOZ_ASSERT(opened); Unused << SendInitRendering(std::move(compositor), std::move(imageBridge), - std::move(vrBridge), std::move(videoManager), +#ifdef MOZ_VR + std::move(vrBridge), +#endif + std::move(videoManager), namespaces); gpm->AddListener(this); @@ -2531,17 +2539,25 @@ void ContentParent::OnCompositorUnexpectedShutdown() { Endpoint compositor; Endpoint imageBridge; +#ifdef MOZ_VR Endpoint vrBridge; +#endif Endpoint videoManager; AutoTArray namespaces; DebugOnly opened = gpm->CreateContentBridges(OtherPid(), &compositor, &imageBridge, - &vrBridge, &videoManager, &namespaces); +#ifdef MOZ_VR + &vrBridge, +#endif + &videoManager, &namespaces); MOZ_ASSERT(opened); Unused << SendReinitRendering(std::move(compositor), std::move(imageBridge), - std::move(vrBridge), std::move(videoManager), +#ifdef MOZ_VR + std::move(vrBridge), +#endif + std::move(videoManager), namespaces); } diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 8f2d9e73e2..f06531d109 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -37,7 +37,9 @@ include protocol PWebrtcGlobal; include protocol PPresentation; include protocol PURLClassifier; include protocol PURLClassifierLocal; +#ifdef MOZ_VR include protocol PVRManager; +#endif include protocol PRemoteDecoderManager; include protocol PProfiler; include protocol PScriptCache; @@ -410,7 +412,9 @@ child: async InitRendering( Endpoint compositor, Endpoint imageBridge, +#ifdef MOZ_VR Endpoint vr, +#endif Endpoint video, uint32_t[] namespaces); @@ -420,7 +424,9 @@ child: async ReinitRendering( Endpoint compositor, Endpoint bridge, +#ifdef MOZ_VR Endpoint vr, +#endif Endpoint video, uint32_t[] namespaces); diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index b09b134463..f115c0f124 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -123,7 +123,6 @@ IPDL_SOURCES += [ 'PBrowserBridge.ipdl', 'PBrowserOrId.ipdlh', 'PColorPicker.ipdl', - 'PContent.ipdl', 'PContentPermission.ipdlh', 'PContentPermissionRequest.ipdl', 'PCycleCollectWithLogs.ipdl', @@ -139,6 +138,10 @@ IPDL_SOURCES += [ 'ServiceWorkerConfiguration.ipdlh', ] +PREPROCESSED_IPDL_SOURCES += [ + 'PContent.ipdl', +] + include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' diff --git a/dom/moz.build b/dom/moz.build index 1c29fdf552..a310e9f23f 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -88,7 +88,6 @@ DIRS += [ 'xslt', 'xul', 'manifest', - 'vr', 'u2f', 'console', 'performance', @@ -112,6 +111,9 @@ if CONFIG['OS_ARCH'] == 'WINNT': if CONFIG['MOZ_WEBGPU']: DIRS += ['webgpu'] +if CONFIG['MOZ_VR']: + DIRS += ['vr'] + DIRS += ['presentation'] TEST_DIRS += [ diff --git a/dom/webidl/Gamepad.webidl b/dom/webidl/Gamepad.webidl index 128cedb76b..6374ee62ca 100644 --- a/dom/webidl/Gamepad.webidl +++ b/dom/webidl/Gamepad.webidl @@ -58,8 +58,10 @@ interface Gamepad { * The displayId in use for as an association point in the VRDisplay API * to identify which VRDisplay that the gamepad is associated with. */ +#ifdef MOZ_VR [Pref="dom.vr.enabled"] readonly attribute unsigned long displayId; +#endif /** * true if this gamepad is currently connected to the system. diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 4629028c6b..04506b620d 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -213,6 +213,7 @@ partial interface Navigator { GamepadServiceTest requestGamepadServiceTest(); }; +#ifdef MOZ_VR partial interface Navigator { [Throws, Pref="dom.vr.enabled"] Promise> getVRDisplays(); @@ -230,6 +231,7 @@ partial interface Navigator { [Pref="dom.vr.test.enabled"] VRServiceTest requestVRServiceTest(); }; +#endif // http://webaudio.github.io/web-midi-api/#requestmidiaccess partial interface Navigator { diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index 4f816eb7c5..991a9badbc 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -522,6 +522,7 @@ partial interface Window { readonly attribute boolean isChromeWindow; }; +#ifdef MOZ_VR partial interface Window { [Pref="dom.vr.enabled"] attribute EventHandler onvrdisplayconnect; @@ -534,6 +535,7 @@ partial interface Window { [Pref="dom.vr.enabled"] attribute EventHandler onvrdisplaypresentchange; }; +#endif // https://drafts.css-houdini.org/css-paint-api-1/#dom-window-paintworklet partial interface Window { diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 739ee1d9d8..c06a581503 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -349,6 +349,7 @@ GENERATED_WEBIDL_FILES = [ ] PREPROCESSED_WEBIDL_FILES = [ + 'Gamepad.webidl', 'Navigator.webidl', 'Node.webidl', 'Window.webidl', @@ -513,7 +514,6 @@ WEBIDL_FILES = [ 'FrameLoader.webidl', 'Function.webidl', 'GainNode.webidl', - 'Gamepad.webidl', 'GamepadHapticActuator.webidl', 'GamepadPose.webidl', 'GamepadServiceTest.webidl', @@ -916,9 +916,6 @@ WEBIDL_FILES = [ 'VideoTrack.webidl', 'VideoTrackList.webidl', 'VisualViewport.webidl', - 'VRDisplay.webidl', - 'VRDisplayEvent.webidl', - 'VRServiceTest.webidl', 'VTTCue.webidl', 'VTTRegion.webidl', 'WaveShaperNode.webidl', @@ -958,6 +955,13 @@ if CONFIG['MOZ_WEBGPU']: 'WebGPU.webidl', ] +if CONFIG['MOZ_VR']: + WEBIDL_FILES += [ + 'VRDisplay.webidl', + 'VRDisplayEvent.webidl', + 'VRServiceTest.webidl', + ] + if CONFIG['MOZ_WEBRTC']: WEBIDL_FILES += [ 'PeerConnectionImpl.webidl', diff --git a/gfx/gl/SharedSurface.cpp b/gfx/gl/SharedSurface.cpp index 14312a5037..38a8bc51a9 100644 --- a/gfx/gl/SharedSurface.cpp +++ b/gfx/gl/SharedSurface.cpp @@ -16,7 +16,9 @@ #include "mozilla/layers/TextureClientSharedSurface.h" #include "mozilla/layers/TextureForwarder.h" #include "mozilla/Unused.h" -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +#endif namespace mozilla { namespace gl { diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp index a8d360f2b5..982c01675e 100644 --- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -5,7 +5,9 @@ #include "gfxConfig.h" #include "GPUProcessHost.h" #include "GPUProcessManager.h" -#include "VRProcessManager.h" +#ifdef MOZ_VR +# include "VRProcessManager.h" +#endif #include "mozilla/StaticPrefs_dom.h" #include "mozilla/Telemetry.h" #include "mozilla/TelemetryIPC.h" @@ -117,6 +119,7 @@ mozilla::ipc::IPCResult GPUChild::RecvGraphicsError(const nsCString& aError) { return IPC_OK(); } +#ifdef MOZ_VR mozilla::ipc::IPCResult GPUChild::RecvCreateVRProcess() { // Make sure create VR process at the main process MOZ_ASSERT(XRE_IsParentProcess()); @@ -142,6 +145,7 @@ mozilla::ipc::IPCResult GPUChild::RecvShutdownVRProcess() { return IPC_OK(); } +#endif mozilla::ipc::IPCResult GPUChild::RecvNotifyUiObservers( const nsCString& aTopic) { diff --git a/gfx/ipc/GPUChild.h b/gfx/ipc/GPUChild.h index 0c448d3af3..d30de5473e 100644 --- a/gfx/ipc/GPUChild.h +++ b/gfx/ipc/GPUChild.h @@ -40,9 +40,11 @@ class GPUChild final : public ipc::CrashReporterHelper, mozilla::ipc::IPCResult RecvInitComplete(const GPUDeviceData& aData); mozilla::ipc::IPCResult RecvReportCheckerboard(const uint32_t& aSeverity, const nsCString& aLog); +#ifdef MOZ_VR mozilla::ipc::IPCResult RecvCreateVRProcess(); mozilla::ipc::IPCResult RecvShutdownVRProcess(); +#endif mozilla::ipc::IPCResult RecvAccumulateChildHistograms( nsTArray&& aAccumulations); mozilla::ipc::IPCResult RecvAccumulateChildKeyedHistograms( diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index 51cfe0223f..3bc59fd881 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -43,9 +43,11 @@ #include "nsThreadManager.h" #include "prenv.h" #include "ProcessUtils.h" -#include "VRGPUChild.h" -#include "VRManager.h" -#include "VRManagerParent.h" +#ifdef MOZ_VR +# include "VRGPUChild.h" +# include "VRManager.h" +# include "VRManagerParent.h" +#endif #include "VsyncBridgeParent.h" #include "cairo.h" #include "skia/include/core/SkGraphics.h" @@ -262,7 +264,9 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( } #endif +#ifdef MOZ_VR VRManager::ManagerInit(); +#endif // Send a message to the UI process that we're done. GPUDeviceData data; RecvGetDeviceStatus(&data); @@ -291,6 +295,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInitImageBridge( return IPC_OK(); } +#ifdef MOZ_VR mozilla::ipc::IPCResult GPUParent::RecvInitVRManager( Endpoint&& aEndpoint) { VRManagerParent::CreateForGPUProcess(std::move(aEndpoint)); @@ -302,6 +307,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInitVR( gfx::VRGPUChild::InitForGPUProcess(std::move(aEndpoint)); return IPC_OK(); } +#endif mozilla::ipc::IPCResult GPUParent::RecvInitUiCompositorController( const LayersId& aRootLayerTreeId, @@ -397,6 +403,7 @@ mozilla::ipc::IPCResult GPUParent::RecvNewContentImageBridge( return IPC_OK(); } +#ifdef MOZ_VR mozilla::ipc::IPCResult GPUParent::RecvNewContentVRManager( Endpoint&& aEndpoint) { if (!VRManagerParent::CreateForContent(std::move(aEndpoint))) { @@ -404,6 +411,7 @@ mozilla::ipc::IPCResult GPUParent::RecvNewContentVRManager( } return IPC_OK(); } +#endif mozilla::ipc::IPCResult GPUParent::RecvNewContentRemoteDecoderManager( Endpoint&& aEndpoint) { @@ -468,12 +476,14 @@ mozilla::ipc::IPCResult GPUParent::RecvRequestMemoryReport( return IPC_OK(); } +#ifdef MOZ_VR mozilla::ipc::IPCResult GPUParent::RecvShutdownVR() { if (StaticPrefs::dom_vr_process_enabled_AtStartup()) { VRGPUChild::Shutdown(); } return IPC_OK(); } +#endif void GPUParent::ActorDestroy(ActorDestroyReason aWhy) { if (AbnormalShutdown == aWhy) { diff --git a/gfx/ipc/GPUParent.h b/gfx/ipc/GPUParent.h index ee839cf75b..837553be54 100644 --- a/gfx/ipc/GPUParent.h +++ b/gfx/ipc/GPUParent.h @@ -44,9 +44,14 @@ class GPUParent final : public PGPUParent { Endpoint&& aVsyncEndpoint); mozilla::ipc::IPCResult RecvInitImageBridge( Endpoint&& aEndpoint); +#ifdef MOZ_VR mozilla::ipc::IPCResult RecvInitVRManager( Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvInitVR(Endpoint&& aVRGPUChild); + mozilla::ipc::IPCResult RecvNewContentVRManager( + Endpoint&& aEndpoint); + mozilla::ipc::IPCResult RecvShutdownVR(); +#endif mozilla::ipc::IPCResult RecvInitUiCompositorController( const LayersId& aRootLayerTreeId, Endpoint&& aEndpoint); @@ -58,8 +63,6 @@ class GPUParent final : public PGPUParent { Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvNewContentImageBridge( Endpoint&& aEndpoint); - mozilla::ipc::IPCResult RecvNewContentVRManager( - Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvNewContentRemoteDecoderManager( Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvGetDeviceStatus(GPUDeviceData* aOutStatus); @@ -73,7 +76,6 @@ class GPUParent final : public PGPUParent { const uint32_t& generation, const bool& anonymize, const bool& minimizeMemoryUsage, const Maybe& DMDFile); - mozilla::ipc::IPCResult RecvShutdownVR(); void ActorDestroy(ActorDestroyReason aWhy) override; diff --git a/gfx/ipc/GPUProcessHost.cpp b/gfx/ipc/GPUProcessHost.cpp index c35f9bc507..dcbf3237ff 100644 --- a/gfx/ipc/GPUProcessHost.cpp +++ b/gfx/ipc/GPUProcessHost.cpp @@ -7,7 +7,9 @@ #include "mozilla/gfx/Logging.h" #include "mozilla/Preferences.h" #include "mozilla/StaticPrefs_layers.h" -#include "VRGPUChild.h" +#ifdef MOZ_VR +# include "VRGPUChild.h" +#endif #include "ProcessUtils.h" namespace mozilla { @@ -157,10 +159,12 @@ void GPUProcessHost::Shutdown() { // The channel might already be closed if we got here unexpectedly. if (!mChannelClosed) { +#ifdef MOZ_VR if (VRGPUChild::IsCreated()) { VRGPUChild::Get()->Close(); } mGPUChild->SendShutdownVR(); +#endif mGPUChild->Close(); } diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index 7c0c3fd641..080d75fbea 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -34,8 +34,10 @@ #endif #include "nsBaseWidget.h" #include "nsContentUtils.h" -#include "VRManagerChild.h" -#include "VRManagerParent.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +# include "VRManagerParent.h" +#endif #include "VsyncBridgeChild.h" #include "VsyncIOThreadHolder.h" #include "VsyncSource.h" @@ -235,7 +237,9 @@ bool GPUProcessManager::EnsureGPUReady() { void GPUProcessManager::EnsureProtocolsReady() { EnsureCompositorManagerChild(); EnsureImageBridgeChild(); +#ifdef MOZ_VR EnsureVRManager(); +#endif } void GPUProcessManager::EnsureCompositorManagerChild() { @@ -287,6 +291,7 @@ void GPUProcessManager::EnsureImageBridgeChild() { AllocateNamespace()); } +#ifdef MOZ_VR void GPUProcessManager::EnsureVRManager() { if (VRManagerChild::IsCreated()) { return; @@ -309,6 +314,7 @@ void GPUProcessManager::EnsureVRManager() { mGPUChild->SendInitVRManager(std::move(parentPipe)); VRManagerChild::InitWithGPUProcess(std::move(childPipe)); } +#endif #if defined(MOZ_WIDGET_ANDROID) already_AddRefed @@ -818,12 +824,16 @@ bool GPUProcessManager::CreateContentBridges( base::ProcessId aOtherProcess, ipc::Endpoint* aOutCompositor, ipc::Endpoint* aOutImageBridge, +#ifdef MOZ_VR ipc::Endpoint* aOutVRBridge, +#endif ipc::Endpoint* aOutVideoManager, nsTArray* aNamespaces) { if (!CreateContentCompositorManager(aOtherProcess, aOutCompositor) || - !CreateContentImageBridge(aOtherProcess, aOutImageBridge) || - !CreateContentVRManager(aOtherProcess, aOutVRBridge)) { +#ifdef MOZ_VR + !CreateContentVRManager(aOtherProcess, aOutVRBridge) || +#endif + !CreateContentImageBridge(aOtherProcess, aOutImageBridge)) { return false; } // VideoDeocderManager is only supported in the GPU process, so we allow this @@ -900,6 +910,7 @@ base::ProcessId GPUProcessManager::GPUProcessPid() { return gpuPid; } +#ifdef MOZ_VR bool GPUProcessManager::CreateContentVRManager( base::ProcessId aOtherProcess, ipc::Endpoint* aOutEndpoint) { @@ -929,6 +940,7 @@ bool GPUProcessManager::CreateContentVRManager( *aOutEndpoint = std::move(childPipe); return true; } +#endif void GPUProcessManager::CreateContentRemoteDecoderManager( base::ProcessId aOtherProcess, diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h index a4cce98de6..20cc6f7ea3 100644 --- a/gfx/ipc/GPUProcessManager.h +++ b/gfx/ipc/GPUProcessManager.h @@ -48,7 +48,9 @@ namespace gfx { class GPUChild; class GPUProcessListener; +#ifdef MOZ_VR class PVRManagerChild; +#endif class VsyncBridgeChild; class VsyncIOThreadHolder; @@ -97,7 +99,9 @@ class GPUProcessManager final : public GPUProcessHost::Listener { base::ProcessId aOtherProcess, mozilla::ipc::Endpoint* aOutCompositor, mozilla::ipc::Endpoint* aOutImageBridge, +#ifdef MOZ_VR mozilla::ipc::Endpoint* aOutVRBridge, +#endif mozilla::ipc::Endpoint* aOutVideoManager, nsTArray* aNamespaces); @@ -184,9 +188,11 @@ class GPUProcessManager final : public GPUProcessHost::Listener { bool CreateContentImageBridge( base::ProcessId aOtherProcess, mozilla::ipc::Endpoint* aOutEndpoint); +#ifdef MOZ_VR bool CreateContentVRManager( base::ProcessId aOtherProcess, mozilla::ipc::Endpoint* aOutEndpoint); +#endif void CreateContentRemoteDecoderManager( base::ProcessId aOtherProcess, mozilla::ipc::Endpoint* aOutEndPoint); @@ -226,7 +232,9 @@ class GPUProcessManager final : public GPUProcessHost::Listener { void EnsureProtocolsReady(); void EnsureCompositorManagerChild(); void EnsureImageBridgeChild(); +#ifdef MOZ_VR void EnsureVRManager(); +#endif #if defined(MOZ_WIDGET_ANDROID) already_AddRefed CreateUiCompositorController( diff --git a/gfx/ipc/PGPU.ipdl b/gfx/ipc/PGPU.ipdl index d5c14d07ff..a4497e114e 100644 --- a/gfx/ipc/PGPU.ipdl +++ b/gfx/ipc/PGPU.ipdl @@ -10,8 +10,10 @@ include protocol PAPZInputBridge; include protocol PCompositorManager; include protocol PImageBridge; include protocol PProfiler; +#ifdef MOZ_VR include protocol PVRGPU; include protocol PVRManager; +#endif include protocol PVsyncBridge; include protocol PUiCompositorController; include protocol PRemoteDecoderManager; @@ -56,11 +58,15 @@ parent: async InitCompositorManager(Endpoint endpoint); async InitVsyncBridge(Endpoint endpoint); async InitImageBridge(Endpoint endpoint); +#ifdef MOZ_VR async InitVRManager(Endpoint endpoint); - async InitUiCompositorController(LayersId rootLayerTreeId, Endpoint endpoint); - async InitProfiler(Endpoint endpoint); // Forward GPU process its endpoints to the VR process. async InitVR(Endpoint endpoint); + async NewContentVRManager(Endpoint endpoint); +#endif + async InitUiCompositorController(LayersId rootLayerTreeId, Endpoint endpoint); + async InitProfiler(Endpoint endpoint); + // Called to update a gfx variable. async UpdateVar(GfxVarUpdate var); @@ -69,7 +75,6 @@ parent: // Create a new content-process compositor bridge. async NewContentCompositorManager(Endpoint endpoint); async NewContentImageBridge(Endpoint endpoint); - async NewContentVRManager(Endpoint endpoint); async NewContentRemoteDecoderManager(Endpoint endpoint); // Called to notify the GPU process of who owns a layersId. @@ -92,7 +97,9 @@ parent: bool anonymize, bool minimizeMemoryUsage, FileDescriptor? DMDFile); +#ifdef MOZ_VR async ShutdownVR(); +#endif child: // Sent when the GPU process has initialized devices. This occurs once, after @@ -107,8 +114,10 @@ child: async InitCrashReporter(Shmem shmem, NativeThreadId threadId); +#ifdef MOZ_VR async CreateVRProcess(); async ShutdownVRProcess(); +#endif // Have a message be broadcasted to the UI process by the UI process // observer service. diff --git a/gfx/ipc/moz.build b/gfx/ipc/moz.build index 9139deffec..4ed69acdf5 100644 --- a/gfx/ipc/moz.build +++ b/gfx/ipc/moz.build @@ -68,10 +68,13 @@ SOURCES += [ IPDL_SOURCES = [ 'GraphicsMessages.ipdlh', - 'PGPU.ipdl', 'PVsyncBridge.ipdl', ] +PREPROCESSED_IPDL_SOURCES += [ + 'PGPU.ipdl', +] + LOCAL_INCLUDES += [ '/dom/ipc', '/toolkit/crashreporter', diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp index 626cae42ad..d7bed7f381 100644 --- a/gfx/layers/d3d9/CompositorD3D9.cpp +++ b/gfx/layers/d3d9/CompositorD3D9.cpp @@ -5,7 +5,6 @@ #include "CompositorD3D9.h" #include "D3D9SurfaceImage.h" #include "LayerManagerD3D9Shaders.h" -#include "Nv3DVUtils.h" #include "gfxCrashReporterUtils.h" #include "gfxFailure.h" #include "gfxUtils.h" @@ -403,46 +402,6 @@ void CompositorD3D9::DrawQuad(const gfx::Rect &aRect, MOZ_ASSERT(sourceCb->GetD3D9Texture()); MOZ_ASSERT(sourceCr->GetD3D9Texture()); - /* - * Send 3d control data and metadata - */ - if (mDeviceManager->GetNv3DVUtils()) { - Nv_Stereo_Mode mode; - switch (source->AsSourceD3D9()->GetStereoMode()) { - case StereoMode::LEFT_RIGHT: - mode = NV_STEREO_MODE_LEFT_RIGHT; - break; - case StereoMode::RIGHT_LEFT: - mode = NV_STEREO_MODE_RIGHT_LEFT; - break; - case StereoMode::BOTTOM_TOP: - mode = NV_STEREO_MODE_BOTTOM_TOP; - break; - case StereoMode::TOP_BOTTOM: - mode = NV_STEREO_MODE_TOP_BOTTOM; - break; - case StereoMode::MONO: - mode = NV_STEREO_MODE_MONO; - break; - } - - // Send control data even in mono case so driver knows to leave stereo - // mode. - mDeviceManager->GetNv3DVUtils()->SendNv3DVControl(mode, true, - FIREFOX_3DV_APP_HANDLE); - - if (source->AsSourceD3D9()->GetStereoMode() != StereoMode::MONO) { - mDeviceManager->GetNv3DVUtils()->SendNv3DVControl( - mode, true, FIREFOX_3DV_APP_HANDLE); - - RefPtr renderTarget; - d3d9Device->GetRenderTarget(0, getter_AddRefs(renderTarget)); - mDeviceManager->GetNv3DVUtils()->SendNv3DVMetaData( - (unsigned int)aRect.width, (unsigned int)aRect.height, - (HANDLE)(sourceY->GetD3D9Texture()), (HANDLE)(renderTarget)); - } - } - // Linear scaling is default here, adhering to mFilter is difficult since // presumably even with point filtering we'll still want chroma upsampling // to be linear. In the current approach we can't. diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.cpp b/gfx/layers/d3d9/DeviceManagerD3D9.cpp index 2550be7d68..85eab7f0a8 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp +++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp @@ -4,7 +4,6 @@ #include "DeviceManagerD3D9.h" #include "LayerManagerD3D9Shaders.h" -#include "Nv3DVUtils.h" #include "TextureD3D9.h" #include "gfx2DGlue.h" #include "gfxPlatform.h" @@ -220,21 +219,6 @@ bool DeviceManagerD3D9::Initialize() { return false; } - //if (gfxPrefs::StereoVideoEnabled()) { - /* Create an Nv3DVUtils instance */ - /*if (!mNv3DVUtils) { - mNv3DVUtils = new Nv3DVUtils(); - if (!mNv3DVUtils) { - NS_WARNING("Could not create a new instance of Nv3DVUtils."); - } - }*/ - - /* Initialize the Nv3DVUtils object */ - /*if (mNv3DVUtils) { - mNv3DVUtils->Initialize(); - } - }*/ - HMODULE d3d9 = LoadLibraryW(L"d3d9.dll"); decltype(Direct3DCreate9) *d3d9Create = (decltype(Direct3DCreate9) *)GetProcAddress(d3d9, "Direct3DCreate9"); @@ -352,17 +336,6 @@ bool DeviceManagerD3D9::Initialize() { return false; mDeviceMonitor = mD3D9->GetAdapterMonitor(parameters.AdapterOrdinal); - /* - * Do some post device creation setup - */ - if (mNv3DVUtils) { - IUnknown *devUnknown = nullptr; - if (mDevice) { - mDevice->QueryInterface(IID_IUnknown, (void **)&devUnknown); - } - mNv3DVUtils->SetDeviceInfo(devUnknown); - } - auto failCreateShaderMsg = "[D3D9] failed to create a critical resource (shader) code"; diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.h b/gfx/layers/d3d9/DeviceManagerD3D9.h index 8067e69b92..ef97473877 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.h +++ b/gfx/layers/d3d9/DeviceManagerD3D9.h @@ -17,7 +17,6 @@ namespace mozilla { namespace layers { class DeviceManagerD3D9; -class Nv3DVUtils; class Layer; class TextureSourceD3D9; @@ -170,11 +169,6 @@ class DeviceManagerD3D9 final { // returns the register to be used for the mask texture, if appropriate uint32_t SetShaderMode(ShaderMode aMode, MaskType aMaskType); - /** - * Return pointer to the Nv3DVUtils instance - */ - Nv3DVUtils *GetNv3DVUtils() { return mNv3DVUtils; } - /** * Returns true if this device was removed. */ @@ -328,9 +322,6 @@ class DeviceManagerD3D9 final { /* If this device was removed */ bool mDeviceWasRemoved; - /* Nv3DVUtils instance */ - nsAutoPtr mNv3DVUtils; - /** * Verifies all required device capabilities are present. */ diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 67ff4c8900..3792a7d1dd 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -33,7 +33,9 @@ #include "mozilla/gfx/Point.h" // for IntSize #include "mozilla/gfx/Rect.h" // for IntSize #include "mozilla/gfx/gfxVars.h" // for gfxVars -#include "VRManager.h" // for VRManager +#ifdef MOZ_VR +# include "VRManager.h" // for VRManager +#endif #include "mozilla/ipc/Transport.h" // for Transport #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/GPUParent.h" diff --git a/gfx/layers/ipc/CompositorThread.cpp b/gfx/layers/ipc/CompositorThread.cpp index 59863b84d3..65b3bcd3bd 100644 --- a/gfx/layers/ipc/CompositorThread.cpp +++ b/gfx/layers/ipc/CompositorThread.cpp @@ -11,10 +11,12 @@ namespace mozilla { +#ifdef MOZ_VR namespace gfx { // See VRManagerChild.cpp void ReleaseVRManagerParentSingleton(); } // namespace gfx +#endif namespace layers { @@ -122,7 +124,9 @@ void CompositorThreadHolder::Shutdown() { } ImageBridgeParent::Shutdown(); +#ifdef MOZ_VR gfx::ReleaseVRManagerParentSingleton(); +#endif MediaSystemResourceService::Shutdown(); CompositorManagerParent::Shutdown(); diff --git a/gfx/layers/ipc/CompositorVsyncScheduler.cpp b/gfx/layers/ipc/CompositorVsyncScheduler.cpp index 6c4ca172e8..451a4cc68e 100644 --- a/gfx/layers/ipc/CompositorVsyncScheduler.cpp +++ b/gfx/layers/ipc/CompositorVsyncScheduler.cpp @@ -33,7 +33,9 @@ # include "VsyncSource.h" #endif #include "mozilla/widget/CompositorWidget.h" -#include "VRManager.h" +#ifdef MOZ_VR +# include "VRManager.h" +#endif namespace mozilla { @@ -69,9 +71,12 @@ CompositorVsyncScheduler::CompositorVsyncScheduler( mVsyncNotificationsSkipped(0), mWidget(aWidget), mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor"), - mCurrentCompositeTask(nullptr), - mCurrentVRTaskMonitor("CurrentVRTaskMonitor"), - mCurrentVRTask(nullptr) { + mCurrentCompositeTask(nullptr) +#ifdef MOZ_VR + , mCurrentVRTaskMonitor("CurrentVRTaskMonitor"), + mCurrentVRTask(nullptr) +#endif + { mVsyncObserver = new Observer(this); // mAsapScheduling is set on the main thread during init, @@ -102,7 +107,9 @@ void CompositorVsyncScheduler::Destroy() { mCompositeRequestedAt = TimeStamp(); CancelCurrentCompositeTask(); +#ifdef MOZ_VR CancelCurrentVRTask(); +#endif } void CompositorVsyncScheduler::PostCompositeTask( @@ -118,6 +125,7 @@ void CompositorVsyncScheduler::PostCompositeTask( } } +#ifdef MOZ_VR void CompositorVsyncScheduler::PostVRTask(TimeStamp aTimestamp) { Monitor2AutoLock lockVR(mCurrentVRTaskMonitor); if (mCurrentVRTask == nullptr && CompositorThreadHolder::Loop()) { @@ -128,6 +136,7 @@ void CompositorVsyncScheduler::PostVRTask(TimeStamp aTimestamp) { CompositorThreadHolder::Loop()->PostDelayedTask(task.forget(), 0); } } +#endif void CompositorVsyncScheduler::ScheduleComposition() { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); @@ -177,18 +186,23 @@ bool CompositorVsyncScheduler::NotifyVsync(const VsyncEvent& aVsync) { MOZ_ASSERT(!NS_IsMainThread()); #if defined(MOZ_WIDGET_ANDROID) +#ifdef MOZ_VR gfx::VRManager* vm = gfx::VRManager::Get(); if (!vm->IsPresenting()) { PostCompositeTask(aVsync.mId, aVsync.mTime); } +#endif #else PostCompositeTask(aVsync.mId, aVsync.mTime); #endif // defined(MOZ_WIDGET_ANDROID) +#ifdef MOZ_VR PostVRTask(aVsync.mTime); +#endif return true; } +#ifdef MOZ_VR void CompositorVsyncScheduler::CancelCurrentVRTask() { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread() || NS_IsMainThread()); @@ -198,6 +212,7 @@ void CompositorVsyncScheduler::CancelCurrentVRTask() { mCurrentVRTask = nullptr; } } +#endif void CompositorVsyncScheduler::CancelCurrentCompositeTask() { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread() || @@ -310,6 +325,7 @@ void CompositorVsyncScheduler::UnobserveVsync() { mIsObservingVsync = false; } +#ifdef MOZ_VR void CompositorVsyncScheduler::DispatchVREvents(TimeStamp aVsyncTimestamp) { { Monitor2AutoLock lock(mCurrentVRTaskMonitor); @@ -326,6 +342,7 @@ void CompositorVsyncScheduler::DispatchVREvents(TimeStamp aVsyncTimestamp) { VRManager* vm = VRManager::Get(); vm->NotifyVsync(aVsyncTimestamp); } +#endif void CompositorVsyncScheduler::ScheduleTask( already_AddRefed aTask) { diff --git a/gfx/layers/ipc/CompositorVsyncScheduler.h b/gfx/layers/ipc/CompositorVsyncScheduler.h index 1574bdd64c..b5f24ade6c 100644 --- a/gfx/layers/ipc/CompositorVsyncScheduler.h +++ b/gfx/layers/ipc/CompositorVsyncScheduler.h @@ -114,6 +114,7 @@ class CompositorVsyncScheduler { // such a task already queued. Can be called from any thread. void PostCompositeTask(VsyncId aId, TimeStamp aCompositeTimestamp); +#ifdef MOZ_VR // Post a task to run DispatchVREvents() on the VR thread, if there isn't // such a task already queued. Can be called from any thread. void PostVRTask(TimeStamp aTimestamp); @@ -123,6 +124,10 @@ class CompositorVsyncScheduler { */ void CancelCurrentVRTask(); + void DispatchVREvents(TimeStamp aVsyncTimestamp); + +#endif + // This gets run at vsync time and "does" a composite (which really means // update internal state and call the owner to do the composite). void Composite(VsyncId aId, TimeStamp aVsyncTimestamp); @@ -130,8 +135,6 @@ class CompositorVsyncScheduler { void ObserveVsync(); void UnobserveVsync(); - void DispatchVREvents(TimeStamp aVsyncTimestamp); - class Observer final : public VsyncObserver { public: explicit Observer(CompositorVsyncScheduler* aOwner); @@ -161,8 +164,10 @@ class CompositorVsyncScheduler { mozilla::Monitor2 mCurrentCompositeTaskMonitor; RefPtr mCurrentCompositeTask; +#ifdef MOZ_VR mozilla::Monitor2 mCurrentVRTaskMonitor; RefPtr mCurrentVRTask; +#endif }; } // namespace layers diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 35afa9a0d8..1fe6f01ada 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -72,7 +72,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': SOURCES += [ 'd3d9/CompositorD3D9.cpp', 'd3d9/DeviceManagerD3D9.cpp', - 'd3d9/Nv3DVUtils.cpp', ] if CONFIG['MOZ_ENABLE_D3D10_LAYER']: EXPORTS.mozilla.layers += [ diff --git a/gfx/moz.build b/gfx/moz.build index 822265fa08..ba7d3bbffd 100644 --- a/gfx/moz.build +++ b/gfx/moz.build @@ -24,7 +24,6 @@ DIRS += [ 'ots/src', 'thebes', 'ipc', - 'vr', 'config', 'webrender_bindings', ] @@ -35,6 +34,9 @@ if CONFIG['MOZ_ENABLE_SKIA']: if CONFIG['MOZ_ENABLE_SKIA_PDF_SFNTLY']: DIRS += ['sfntly/cpp/src'] +if CONFIG['MOZ_VR']: + DIRS += ['vr'] + if CONFIG['ENABLE_TESTS']: DIRS += ['tests/gtest'] diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp index a0683a9373..24f2fa0651 100644 --- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -130,7 +130,9 @@ bool DeviceManagerDx::LoadDcomp() { void DeviceManagerDx::ReleaseD3D11() { MOZ_ASSERT(!mCompositorDevice); MOZ_ASSERT(!mContentDevice); +#ifdef MOZ_VR MOZ_ASSERT(!mVRDevice); +#endif MOZ_ASSERT(!mDecoderDevice); mD3D11Module.reset(); @@ -140,7 +142,9 @@ void DeviceManagerDx::ReleaseD3D11() { #ifdef DEBUG static inline bool ProcessOwnsCompositor() { return XRE_GetProcessType() == GeckoProcessType_GPU || +#ifdef MOZ_VR XRE_GetProcessType() == GeckoProcessType_VR || +#endif (XRE_IsParentProcess() && !gfxConfig::IsEnabled(Feature::GPU_PROCESS)); } #endif @@ -198,6 +202,7 @@ bool DeviceManagerDx::CreateCompositorDevices() { return true; } +#ifdef MOZ_VR bool DeviceManagerDx::CreateVRDevice() { MOZ_ASSERT(ProcessOwnsCompositor()); @@ -235,6 +240,7 @@ bool DeviceManagerDx::CreateVRDevice() { return true; } +#endif void DeviceManagerDx::CreateDirectCompositionDevice() { if (!gfxVars::UseWebRenderDCompWin()) { @@ -1031,6 +1037,7 @@ RefPtr DeviceManagerDx::GetImageDevice() { return mImageDevice; } +#ifdef MOZ_VR RefPtr DeviceManagerDx::GetVRDevice() { MutexAutoLock lock(mDeviceLock); if (!mVRDevice) { @@ -1038,6 +1045,7 @@ RefPtr DeviceManagerDx::GetVRDevice() { } return mVRDevice; } +#endif RefPtr DeviceManagerDx::GetDirectCompositionDevice() { MutexAutoLock lock(mDeviceLock); diff --git a/gfx/thebes/DeviceManagerDx.h b/gfx/thebes/DeviceManagerDx.h index 672cf1265d..6c36093d4a 100644 --- a/gfx/thebes/DeviceManagerDx.h +++ b/gfx/thebes/DeviceManagerDx.h @@ -56,7 +56,9 @@ class DeviceManagerDx final { RefPtr GetContentDevice(); RefPtr GetImageDevice(); RefPtr GetDirectCompositionDevice(); +#ifdef MOZ_VR RefPtr GetVRDevice(); +#endif RefPtr CreateDecoderDevice(); RefPtr GetMLGDevice(); IDirectDraw7* GetDirectDraw(); @@ -128,7 +130,9 @@ class DeviceManagerDx final { void CreateWARPCompositorDevice(); void CreateMLGDevice(); +#ifdef MOZ_VR bool CreateVRDevice(); +#endif mozilla::gfx::FeatureStatus CreateContentDevice(); @@ -162,7 +166,9 @@ class DeviceManagerDx final { RefPtr mCompositorDevice; RefPtr mContentDevice; RefPtr mImageDevice; +#ifdef MOZ_VR RefPtr mVRDevice; +#endif RefPtr mDecoderDevice; RefPtr mDirectCompositionDevice; diff --git a/gfx/thebes/gfxEnv.h b/gfx/thebes/gfxEnv.h index 03e79a4754..b760f76dc8 100644 --- a/gfx/thebes/gfxEnv.h +++ b/gfx/thebes/gfxEnv.h @@ -75,7 +75,9 @@ class gfxEnv final { // Force gfxDevCrash to use telemetry in Nightly and Aurora DECL_GFX_ENV("MOZ_GFX_CRASH_TELEMETRY", GfxDevCrashTelemetry); +#ifdef MOZ_VR DECL_GFX_ENV("MOZ_GFX_VR_NO_DISTORTION", VRNoDistortion); +#endif // Debugging in GLContext DECL_GFX_ENV("MOZ_GL_DEBUG", GlDebug); @@ -106,8 +108,10 @@ class gfxEnv final { // Skip rasterizing painted layer contents DECL_GFX_ENV("MOZ_SKIPRASTERIZATION", SkipRasterization); +#ifdef MOZ_VR // Stop the VR rendering DECL_GFX_ENV("NO_VR_RENDERING", NoVRRendering); +#endif // WARNING: // Please make sure that you've added your new envvar to the list above in diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index de55d9df0e..3b8846955c 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -42,8 +42,10 @@ #include "gfxTextRun.h" #include "gfxUserFontSet.h" #include "gfxConfig.h" -#include "VRProcessManager.h" -#include "VRThread.h" +#ifdef MOZ_VR +# include "VRProcessManager.h" +# include "VRThread.h" +#endif #ifdef XP_WIN # include @@ -143,8 +145,10 @@ static const uint32_t kDefaultGlyphCacheSize = -1; #include "nscore.h" // for NS_FREE_PERMANENT_DATA #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/TouchEvent.h" -#include "gfxVR.h" -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "gfxVR.h" +# include "VRManagerChild.h" +#endif #include "mozilla/gfx/GPUParent.h" #include "mozilla/layers/MemoryReportingMLGPU.h" #include "prsystem.h" @@ -478,7 +482,9 @@ gfxPlatform::gfxPlatform() mTotalSystemMemory = PR_GetPhysicalMemorySize(); +#ifdef MOZ_VR VRManager::ManagerInit(); +#endif } gfxPlatform* gfxPlatform::GetPlatform() { @@ -1247,7 +1253,9 @@ void gfxPlatform::Shutdown() { if (XRE_IsParentProcess()) { GPUProcessManager::Shutdown(); +#ifdef MOZ_VR VRProcessManager::Shutdown(); +#endif RDDProcessManager::Shutdown(); } @@ -1297,7 +1305,9 @@ void gfxPlatform::ShutdownLayersIPC() { sLayersIPCIsUp = false; if (XRE_IsContentProcess()) { +#ifdef MOZ_VR gfx::VRManagerChild::ShutDown(); +#endif // cf bug 1215265. if (StaticPrefs::layers_child_process_shutdown()) { layers::CompositorManagerChild::Shutdown(); @@ -1311,7 +1321,9 @@ void gfxPlatform::ShutdownLayersIPC() { #ifdef MOZ_WAYLAND widget::WaylandDisplayShutdown(); #endif +#ifdef MOZ_VR gfx::VRManagerChild::ShutDown(); +#endif layers::CompositorManagerChild::Shutdown(); layers::ImageBridgeChild::ShutDown(); // This has to happen after shutting down the child protocols. diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index e171336eb0..571d097d5b 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -2159,6 +2159,7 @@ # Is support for WebVR APIs enabled? # Enabled by default in beta and release for Windows and OS X and for all # platforms in nightly and aurora. +#ifdef MOZ_VR - name: dom.vr.enabled type: RelaxedAtomicBool #if defined(XP_WIN) || defined(XP_DARWIN) || !defined(RELEASE_OR_BETA) @@ -2376,6 +2377,8 @@ type: bool value: true mirror: once +#endif +# MOZ_VR # W3C draft pointer events - name: dom.w3c_pointer_events.enabled diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 28cba3f552..82ac01c500 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -609,7 +609,9 @@ SYNC_ENUMS(CONTENT, Content) SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest) SYNC_ENUMS(GMPLUGIN, GMPlugin) SYNC_ENUMS(GPU, GPU) +#ifdef MOZ_VR SYNC_ENUMS(VR, VR) +#endif SYNC_ENUMS(RDD, RDD) SYNC_ENUMS(SOCKET, Socket) SYNC_ENUMS(SANDBOX_BROKER, RemoteSandboxBroker) diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index c7e92a9018..3bf3a190a3 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -129,7 +129,9 @@ using mozilla::_ipdltest::IPDLUnitTestProcessChild; # include "mozilla/sandboxing/sandboxLogging.h" #endif -#include "VRProcessChild.h" +#ifdef MOZ_VR +# include "VRProcessChild.h" +#endif using namespace mozilla; @@ -652,7 +654,9 @@ nsresult XRE_InitChildProcess(int aArgc, char* aArgv[], switch (XRE_GetProcessType()) { case GeckoProcessType_Content: case GeckoProcessType_GPU: +#ifdef MOZ_VR case GeckoProcessType_VR: +#endif case GeckoProcessType_RDD: case GeckoProcessType_Socket: // Content processes need the XPCOM/chromium frankenventloop @@ -713,9 +717,11 @@ nsresult XRE_InitChildProcess(int aArgc, char* aArgv[], process = new gfx::GPUProcessImpl(parentPID); break; +#ifdef MOZ_VR case GeckoProcessType_VR: process = new gfx::VRProcessChild(parentPID); break; +#endif case GeckoProcessType_RDD: process = new RDDProcessImpl(parentPID); diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 5006bdb4b6..e5d8546c41 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -397,11 +397,13 @@ NS_EVENT_MESSAGE(eOrientationChange) #endif // WebVR events +#ifdef MOZ_VR NS_EVENT_MESSAGE(eVRDisplayActivate) NS_EVENT_MESSAGE(eVRDisplayDeactivate) NS_EVENT_MESSAGE(eVRDisplayConnect) NS_EVENT_MESSAGE(eVRDisplayDisconnect) NS_EVENT_MESSAGE(eVRDisplayPresentChange) +#endif NS_EVENT_MESSAGE(eShow) diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 08740d0291..00ab3c3c58 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -78,7 +78,9 @@ #endif #include "gfxConfig.h" #include "mozilla/layers/CompositorSession.h" -#include "VRManagerChild.h" +#ifdef MOZ_VR +# include "VRManagerChild.h" +#endif #include "gfxConfig.h" #include "nsView.h" #include "nsViewManager.h" @@ -1299,7 +1301,9 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight) { MOZ_ASSERT(textureFactoryIdentifier.mParentBackend == LayersBackend::LAYERS_WR); ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier); +#ifdef MOZ_VR gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier); +#endif } ShadowLayerForwarder* lf = lm->AsShadowForwarder(); @@ -1336,10 +1340,12 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight) { // Some popup or transparent widgets may use a different backend than the // compositors used with ImageBridge and VR (and more generally web // content). +#ifdef MOZ_VR if (WidgetTypeSupportsAcceleration()) { ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier); gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier); } +#endif } WindowUsesOMTC(); diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 9933506c11..30030c4950 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -25,7 +25,9 @@ #endif #include "nsNetCID.h" #include "nsThread.h" -#include "VRProcessManager.h" +#ifdef MOZ_VR +# include "VRProcessManager.h" +#endif #include "mozilla/Attributes.h" #include "mozilla/MemoryReportingProcess.h" #include "mozilla/PodOperations.h" @@ -1813,11 +1815,13 @@ nsresult nsMemoryReporterManager::StartGettingReports() { } } +#ifdef MOZ_VR if (gfx::VRProcessManager* vr = gfx::VRProcessManager::Get()) { if (RefPtr proc = vr->GetProcessMemoryReporter()) { s->mChildrenPending.AppendElement(proc.forget()); } } +#endif if (!mIsRegistrationBlocked && net::gIOService) { if (RefPtr proc = diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index 494fc704ce..9aa8c3f9f7 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -906,11 +906,6 @@ Atom("onversionchange", "onversionchange"), Atom("onvisibilitychange", "onvisibilitychange"), Atom("onvoiceschanged", "onvoiceschanged"), - Atom("onvrdisplayactivate", "onvrdisplayactivate"), - Atom("onvrdisplayconnect", "onvrdisplayconnect"), - Atom("onvrdisplaydeactivate", "onvrdisplaydeactivate"), - Atom("onvrdisplaydisconnect", "onvrdisplaydisconnect"), - Atom("onvrdisplaypresentchange", "onvrdisplaypresentchange"), Atom("onwebkitAnimationEnd", "onwebkitAnimationEnd"), Atom("onwebkitAnimationIteration", "onwebkitAnimationIteration"), Atom("onwebkitAnimationStart", "onwebkitAnimationStart"),