Remove VR hardware support.

This resolves #881
pull/1/head
wolfbeast 4 years ago committed by Roy Tam
parent f75592fd13
commit 9b1124ccbd
  1. 1
      dom/base/Element.cpp
  2. 78
      dom/base/Navigator.cpp
  3. 7
      dom/base/Navigator.h
  4. 66
      dom/base/nsGlobalWindow.cpp
  5. 22
      dom/base/nsGlobalWindow.h
  6. 79
      dom/canvas/WebGLContext.cpp
  7. 3
      dom/canvas/WebGLContext.h
  8. 41
      dom/html/HTMLCanvasElement.cpp
  9. 4
      dom/html/HTMLCanvasElement.h
  10. 9
      dom/ipc/ContentChild.cpp
  11. 6
      dom/ipc/ContentChild.h
  12. 6
      dom/ipc/ContentParent.cpp
  13. 3
      dom/ipc/PContent.ipdl
  14. 2
      dom/ipc/TabChild.cpp
  15. 1
      dom/moz.build
  16. 802
      dom/vr/VRDisplay.cpp
  17. 362
      dom/vr/VRDisplay.h
  18. 79
      dom/vr/VREventObserver.cpp
  19. 33
      dom/vr/VREventObserver.h
  20. 22
      dom/vr/moz.build
  21. 8
      dom/webidl/Navigator.webidl
  22. 286
      dom/webidl/VRDisplay.webidl
  23. 1
      dom/webidl/moz.build
  24. 16
      gfx/ipc/GPUParent.cpp
  25. 2
      gfx/ipc/GPUParent.h
  26. 71
      gfx/ipc/GPUProcessManager.cpp
  27. 5
      gfx/ipc/GPUProcessManager.h
  28. 3
      gfx/ipc/PGPU.ipdl
  29. 3
      gfx/layers/d3d11/TextureD3D11.cpp
  30. 11
      gfx/layers/ipc/CompositorBridgeParent.cpp
  31. 6
      gfx/layers/ipc/CompositorThread.cpp
  32. 1
      gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
  33. 3
      gfx/layers/ipc/PTexture.ipdl
  34. 1
      gfx/moz.build
  35. 6
      gfx/thebes/gfxPlatform.cpp
  36. 143
      gfx/vr/VRDisplayClient.cpp
  37. 61
      gfx/vr/VRDisplayClient.h
  38. 201
      gfx/vr/VRDisplayHost.cpp
  39. 114
      gfx/vr/VRDisplayHost.h
  40. 112
      gfx/vr/VRDisplayPresentation.cpp
  41. 39
      gfx/vr/VRDisplayPresentation.h
  42. 393
      gfx/vr/VRManager.cpp
  43. 88
      gfx/vr/VRManager.h
  44. 127
      gfx/vr/gfxVR.cpp
  45. 285
      gfx/vr/gfxVR.h
  46. 529
      gfx/vr/gfxVROSVR.cpp
  47. 107
      gfx/vr/gfxVROSVR.h
  48. 896
      gfx/vr/gfxVROculus.cpp
  49. 111
      gfx/vr/gfxVROculus.h
  50. 749
      gfx/vr/gfxVROpenVR.cpp
  51. 140
      gfx/vr/gfxVROpenVR.h
  52. 27
      gfx/vr/ipc/PVRLayer.ipdl
  53. 86
      gfx/vr/ipc/PVRManager.ipdl
  54. 86
      gfx/vr/ipc/VRLayerChild.cpp
  55. 53
      gfx/vr/ipc/VRLayerChild.h
  56. 59
      gfx/vr/ipc/VRLayerParent.cpp
  57. 43
      gfx/vr/ipc/VRLayerParent.h
  58. 593
      gfx/vr/ipc/VRManagerChild.cpp
  59. 185
      gfx/vr/ipc/VRManagerChild.h
  60. 332
      gfx/vr/ipc/VRManagerParent.cpp
  61. 118
      gfx/vr/ipc/VRManagerParent.h
  62. 193
      gfx/vr/ipc/VRMessageUtils.h
  63. 71
      gfx/vr/moz.build
  64. 27
      gfx/vr/openvr/LICENSE
  65. 2
      gfx/vr/openvr/README
  66. 3352
      gfx/vr/openvr/openvr.h
  67. 37
      gfx/vr/osvr/ClientKit/ClientKitC.h
  68. 96
      gfx/vr/osvr/ClientKit/ContextC.h
  69. 506
      gfx/vr/osvr/ClientKit/DisplayC.h
  70. 138
      gfx/vr/osvr/ClientKit/Export.h
  71. 75
      gfx/vr/osvr/ClientKit/InterfaceC.h
  72. 77
      gfx/vr/osvr/ClientKit/InterfaceCallbackC.h
  73. 79
      gfx/vr/osvr/ClientKit/InterfaceStateC.h
  74. 47
      gfx/vr/osvr/ClientKit/SystemCallbackC.h
  75. 75
      gfx/vr/osvr/ClientKit/TransformsC.h
  76. 50
      gfx/vr/osvr/Util/APIBaseC.h
  77. 232
      gfx/vr/osvr/Util/AnnotationMacrosC.h
  78. 59
      gfx/vr/osvr/Util/BoolC.h
  79. 57
      gfx/vr/osvr/Util/ChannelCountC.h
  80. 140
      gfx/vr/osvr/Util/ClientCallbackTypesC.h
  81. 69
      gfx/vr/osvr/Util/ClientOpaqueTypesC.h
  82. 348
      gfx/vr/osvr/Util/ClientReportTypesC.h
  83. 138
      gfx/vr/osvr/Util/Export.h
  84. 91
      gfx/vr/osvr/Util/ImagingReportTypesC.h
  85. 190
      gfx/vr/osvr/Util/MatrixConventionsC.h
  86. 88
      gfx/vr/osvr/Util/PlatformConfig.h
  87. 70
      gfx/vr/osvr/Util/Pose3C.h
  88. 92
      gfx/vr/osvr/Util/QuaternionC.h
  89. 84
      gfx/vr/osvr/Util/QuatlibInteropC.h
  90. 62
      gfx/vr/osvr/Util/RadialDistortionParametersC.h
  91. 134
      gfx/vr/osvr/Util/RenderingTypesC.h
  92. 57
      gfx/vr/osvr/Util/ReturnCodesC.h
  93. 42
      gfx/vr/osvr/Util/StdInt.h
  94. 271
      gfx/vr/osvr/Util/TimeValueC.h
  95. 86
      gfx/vr/osvr/Util/Vec2C.h
  96. 89
      gfx/vr/osvr/Util/Vec3C.h
  97. 676
      gfx/vr/ovr_capi_dynamic.h
  98. 24
      modules/libpref/init/all.js
  99. 3
      widget/nsBaseWidget.cpp

@ -145,7 +145,6 @@
#include "mozilla/dom/KeyframeEffectBinding.h"
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/VRDisplay.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Preferences.h"
#include "nsComputedDOMStyle.h"

@ -44,7 +44,6 @@
#include "mozilla/dom/ServiceWorkerContainer.h"
#include "mozilla/dom/StorageManager.h"
#include "mozilla/dom/TCPSocket.h"
#include "mozilla/dom/VRDisplay.h"
#include "mozilla/dom/workers/RuntimeService.h"
#include "mozilla/Hal.h"
#include "nsISiteSpecificUserAgent.h"
@ -1471,83 +1470,6 @@ Navigator::RequestGamepadServiceTest()
}
#endif
already_AddRefed<Promise>
Navigator::GetVRDisplays(ErrorResult& aRv)
{
if (!mWindow || !mWindow->GetDocShell()) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
win->NotifyVREventListenerAdded();
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
RefPtr<Promise> p = Promise::Create(go, aRv);
if (aRv.Failed()) {
return nullptr;
}
// We pass mWindow's id to RefreshVRDisplays, so NotifyVRDisplaysUpdated will
// be called asynchronously, resolving the promises in mVRGetDisplaysPromises.
if (!VRDisplay::RefreshVRDisplays(win->WindowID())) {
p->MaybeReject(NS_ERROR_FAILURE);
return p.forget();
}
mVRGetDisplaysPromises.AppendElement(p);
return p.forget();
}
void
Navigator::GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const
{
/**
* Get only the active VR displays.
* Callers do not wish to VRDisplay::RefreshVRDisplays, as the enumeration may
* activate hardware that is not yet intended to be used.
*/
if (!mWindow || !mWindow->GetDocShell()) {
return;
}
nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
win->NotifyVREventListenerAdded();
nsTArray<RefPtr<VRDisplay>> displays;
if (win->UpdateVRDisplays(displays)) {
for (auto display : displays) {
if (display->IsPresenting()) {
aDisplays.AppendElement(display);
}
}
}
}
void
Navigator::NotifyVRDisplaysUpdated()
{
// Synchronize the VR devices and resolve the promises in
// mVRGetDisplaysPromises
nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
nsTArray<RefPtr<VRDisplay>> vrDisplays;
if (win->UpdateVRDisplays(vrDisplays)) {
for (auto p : mVRGetDisplaysPromises) {
p->MaybeResolve(vrDisplays);
}
} else {
for (auto p : mVRGetDisplaysPromises) {
p->MaybeReject(NS_ERROR_FAILURE);
}
}
mVRGetDisplaysPromises.Clear();
}
void
Navigator::NotifyActiveVRDisplaysChanged()
{
NavigatorBinding::ClearCachedActiveVRDisplaysValue(this);
}
//*****************************************************************************
// Navigator::nsIMozNavigatorNetwork
//*****************************************************************************

@ -76,7 +76,6 @@ class Connection;
class PowerManager;
class Presentation;
class LegacyMozTCPSocket;
class VRDisplay;
class StorageManager;
namespace time {
@ -204,8 +203,6 @@ public:
void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
GamepadServiceTest* RequestGamepadServiceTest();
#endif // MOZ_GAMEPAD
already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const;
#ifdef MOZ_TIME_MANAGER
time::TimeManager* GetMozTime(ErrorResult& aRv);
#endif // MOZ_TIME_MANAGER
@ -269,10 +266,6 @@ private:
RefPtr<MediaKeySystemAccessManager> mMediaKeySystemAccessManager;
#endif
public:
void NotifyVRDisplaysUpdated();
void NotifyActiveVRDisplaysChanged();
private:
virtual ~Navigator();

@ -202,9 +202,6 @@
#include "mozilla/dom/GamepadManager.h"
#endif
#include "mozilla/dom/VRDisplay.h"
#include "mozilla/dom/VREventObserver.h"
#include "nsRefreshDriver.h"
#include "Layers.h"
@ -1532,7 +1529,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
mShowFocusRingForContent(false),
mFocusByKeyOccurred(false),
mHasGamepad(false),
mHasVREvents(false),
#ifdef MOZ_GAMEPAD
mHasSeenGamepadInput(false),
#endif
@ -1967,12 +1963,9 @@ nsGlobalWindow::CleanUp()
if (IsInnerWindow()) {
DisableGamepadUpdates();
mHasGamepad = false;
DisableVRUpdates();
mHasVREvents = false;
DisableIdleCallbackRequests();
} else {
MOZ_ASSERT(!mHasGamepad);
MOZ_ASSERT(!mHasVREvents);
}
if (mCleanMessageManager) {
@ -2118,9 +2111,6 @@ nsGlobalWindow::FreeInnerObjects(bool aForDocumentOpen)
mHasGamepad = false;
mGamepads.Clear();
#endif
DisableVRUpdates();
mHasVREvents = false;
mVRDisplays.Clear();
}
//*****************************************************************************
@ -2275,7 +2265,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
#endif
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheStorage)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRDisplays)
// Traverse stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
@ -2352,7 +2341,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
#endif
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheStorage)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mVRDisplays)
// Unlink stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
@ -10507,24 +10495,6 @@ nsGlobalWindow::DisableGamepadUpdates()
}
}
void
nsGlobalWindow::EnableVRUpdates()
{
MOZ_ASSERT(IsInnerWindow());
if (mHasVREvents && !mVREventObserver) {
mVREventObserver = new VREventObserver(this);
}
}
void
nsGlobalWindow::DisableVRUpdates()
{
MOZ_ASSERT(IsInnerWindow());
mVREventObserver = nullptr;
}
void
nsGlobalWindow::SetChromeEventHandler(EventTarget* aChromeEventHandler)
{
@ -12210,7 +12180,6 @@ nsGlobalWindow::Suspend()
ac->RemoveWindowListener(mEnabledSensors[i], this);
}
DisableGamepadUpdates();
DisableVRUpdates();
mozilla::dom::workers::SuspendWorkersForWindow(AsInner());
@ -12274,7 +12243,6 @@ nsGlobalWindow::Resume()
ac->AddWindowListener(mEnabledSensors[i], this);
}
EnableGamepadUpdates();
EnableVRUpdates();
// Resume all of the AudioContexts for this window
for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
@ -14030,19 +13998,6 @@ nsGlobalWindow::SetHasGamepadEventListener(bool aHasGamepad/* = true*/)
void
nsGlobalWindow::EventListenerAdded(nsIAtom* aType)
{
if (aType == nsGkAtoms::onvrdisplayconnect ||
aType == nsGkAtoms::onvrdisplaydisconnect ||
aType == nsGkAtoms::onvrdisplaypresentchange) {
NotifyVREventListenerAdded();
}
}
void
nsGlobalWindow::NotifyVREventListenerAdded()
{
MOZ_ASSERT(IsInnerWindow());
mHasVREvents = true;
EnableVRUpdates();
}
void
@ -14187,27 +14142,6 @@ nsGlobalWindow::SyncGamepadState()
}
#endif // MOZ_GAMEPAD
bool
nsGlobalWindow::UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDevices)
{
FORWARD_TO_INNER(UpdateVRDisplays, (aDevices), false);
VRDisplay::UpdateVRDisplays(mVRDisplays, AsInner());
aDevices = mVRDisplays;
return true;
}
void
nsGlobalWindow::NotifyActiveVRDisplaysChanged()
{
MOZ_ASSERT(IsInnerWindow());
if (mNavigator) {
mNavigator->NotifyActiveVRDisplaysChanged();
}
}
// nsGlobalChromeWindow implementation
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow)

@ -135,8 +135,6 @@ class SpeechSynthesis;
class TabGroup;
class Timeout;
class U2F;
class VRDisplay;
class VREventObserver;
class WakeLock;
#if defined(MOZ_WIDGET_ANDROID)
class WindowOrientationObserver;
@ -745,18 +743,6 @@ public:
void EnableGamepadUpdates();
void DisableGamepadUpdates();
// Inner windows only.
// Enable/disable updates for VR
void EnableVRUpdates();
void DisableVRUpdates();
// Update the VR displays for this window
bool UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDisplays);
// Inner windows only.
// Called to inform that the set of active VR displays has changed.
void NotifyActiveVRDisplaysChanged();
#define EVENT(name_, id_, type_, struct_) \
mozilla::dom::EventHandlerNonNull* GetOn##name_() \
{ \
@ -1832,9 +1818,6 @@ protected:
// Indicates whether this window wants gamepad input events
bool mHasGamepad : 1;
// Inner windows only.
// Indicates whether this window wants VR events
bool mHasVREvents : 1;
#ifdef MOZ_GAMEPAD
nsCheapSet<nsUint32HashKey> mGamepadIndexSet;
nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Gamepad> mGamepads;
@ -1989,11 +1972,6 @@ protected:
// This is the CC generation the last time we called CanSkip.
uint32_t mCanSkipCCGeneration;
// The VR Displays for this window
nsTArray<RefPtr<mozilla::dom::VRDisplay>> mVRDisplays;
nsAutoPtr<mozilla::dom::VREventObserver> mVREventObserver;
friend class nsDOMScriptableHelper;
friend class nsDOMWindowUtils;
friend class mozilla::dom::PostMessageEvent;

@ -47,7 +47,6 @@
#include "nsSVGEffects.h"
#include "prenv.h"
#include "ScopedGLHelpers.h"
#include "VRManagerChild.h"
#include "mozilla/layers/TextureClientSharedSurface.h"
// Local
@ -2239,84 +2238,6 @@ WebGLContext::GetUnpackSize(bool isFunc3D, uint32_t width, uint32_t height,
return totalBytes;
}
already_AddRefed<layers::SharedSurfaceTextureClient>
WebGLContext::GetVRFrame()
{
if (!mLayerIsMirror) {
/**
* Do not allow VR frame submission until a mirroring canvas layer has
* been returned by GetCanvasLayer
*/
return nullptr;
}
VRManagerChild* vrmc = VRManagerChild::Get();
if (!vrmc) {
return nullptr;
}
/**
* Swap buffers as though composition has occurred.
* We will then share the resulting front buffer to be submitted to the VR
* compositor.
*/
BeginComposition();
EndComposition();
gl::GLScreenBuffer* screen = gl->Screen();
if (!screen) {
return nullptr;
}
RefPtr<SharedSurfaceTextureClient> sharedSurface = screen->Front();
if (!sharedSurface) {
return nullptr;
}
if (sharedSurface && sharedSurface->GetAllocator() != vrmc) {
RefPtr<SharedSurfaceTextureClient> dest =
screen->Factory()->NewTexClient(sharedSurface->GetSize());
if (!dest) {
return nullptr;
}
gl::SharedSurface* destSurf = dest->Surf();
destSurf->ProducerAcquire();
SharedSurface::ProdCopy(sharedSurface->Surf(), dest->Surf(),
screen->Factory());
destSurf->ProducerRelease();
return dest.forget();
}
return sharedSurface.forget();
}
bool
WebGLContext::StartVRPresentation()
{
VRManagerChild* vrmc = VRManagerChild::Get();
if (!vrmc) {
return false;
}
gl::GLScreenBuffer* screen = gl->Screen();
if (!screen) {
return false;
}
gl::SurfaceCaps caps = screen->mCaps;
UniquePtr<gl::SurfaceFactory> factory =
gl::GLScreenBuffer::CreateFactory(gl,
caps,
vrmc,
vrmc->GetBackendType(),
TextureFlags::ORIGIN_BOTTOM_LEFT);
if (factory) {
screen->Morph(Move(factory));
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
static inline size_t

@ -656,9 +656,6 @@ public:
void PixelStorei(GLenum pname, GLint param);
void PolygonOffset(GLfloat factor, GLfloat units);
already_AddRefed<layers::SharedSurfaceTextureClient> GetVRFrame();
bool StartVRPresentation();
////
webgl::PackingInfo

@ -42,7 +42,6 @@
#include "nsRefreshDriver.h"
#include "nsStreamUtils.h"
#include "ActiveLayerTracker.h"
#include "VRManagerChild.h"
#include "WebGL1Context.h"
#include "WebGL2Context.h"
@ -358,7 +357,6 @@ NS_IMPL_ISUPPORTS(HTMLCanvasElementObserver, nsIObserver)
HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsGenericHTMLElement(aNodeInfo),
mResetLayer(true) ,
mVRPresentationActive(false),
mWriteOnly(false)
{}
@ -1111,7 +1109,7 @@ HTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
static uint8_t sOffscreenCanvasLayerUserDataDummy = 0;
if (mCurrentContext) {
return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager, mVRPresentationActive);
return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager);
}
if (mOffscreenCanvas) {
@ -1441,42 +1439,5 @@ HTMLCanvasElement::InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRende
element->InvalidateCanvasContent(nullptr);
}
void
HTMLCanvasElement::StartVRPresentation()
{
WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0));
if (!webgl) {
return;
}
if (!webgl->StartVRPresentation()) {
return;
}
mVRPresentationActive = true;
}
void
HTMLCanvasElement::StopVRPresentation()
{
mVRPresentationActive = false;
}
already_AddRefed<layers::SharedSurfaceTextureClient>
HTMLCanvasElement::GetVRFrame()
{
if (GetCurrentContextType() != CanvasContextType::WebGL1 &&
GetCurrentContextType() != CanvasContextType::WebGL2) {
return nullptr;
}
WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0));
if (!webgl) {
return nullptr;
}
return webgl->GetVRFrame();
}
} // namespace dom
} // namespace mozilla

@ -350,10 +350,6 @@ public:
static void SetAttrFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRenderer);
static void InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRenderer);
void StartVRPresentation();
void StopVRPresentation();
already_AddRefed<layers::SharedSurfaceTextureClient> GetVRFrame();
protected:
virtual ~HTMLCanvasElement();

@ -171,7 +171,6 @@
#include "GMPServiceChild.h"
#include "gfxPlatform.h"
#include "nscore.h" // for NS_FREE_PERMANENT_DATA
#include "VRManagerChild.h"
using namespace mozilla;
using namespace mozilla::docshell;
@ -1148,7 +1147,6 @@ ContentChild::RecvGMPsChanged(nsTArray<GMPCapabilityData>&& capabilities)
bool
ContentChild::RecvInitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor,
Endpoint<PImageBridgeChild>&& aImageBridge,
Endpoint<PVRManagerChild>&& aVRBridge,
Endpoint<PVideoDecoderManagerChild>&& aVideoManager)
{
if (!CompositorBridgeChild::InitForContent(Move(aCompositor))) {
@ -1157,9 +1155,6 @@ ContentChild::RecvInitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor,
if (!ImageBridgeChild::InitForContent(Move(aImageBridge))) {
return false;
}
if (!gfx::VRManagerChild::InitForContent(Move(aVRBridge))) {
return false;
}
VideoDecoderManagerChild::InitForContent(Move(aVideoManager));
return true;
}
@ -1167,7 +1162,6 @@ ContentChild::RecvInitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor,
bool
ContentChild::RecvReinitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor,
Endpoint<PImageBridgeChild>&& aImageBridge,
Endpoint<PVRManagerChild>&& aVRBridge,
Endpoint<PVideoDecoderManagerChild>&& aVideoManager)
{
nsTArray<RefPtr<TabChild>> tabs = TabChild::GetAll();
@ -1186,9 +1180,6 @@ ContentChild::RecvReinitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor
if (!ImageBridgeChild::ReinitForContent(Move(aImageBridge))) {
return false;
}
if (!gfx::VRManagerChild::ReinitForContent(Move(aVRBridge))) {
return false;
}
// Establish new PLayerTransactions.
for (const auto& tabChild : tabs) {

@ -152,15 +152,13 @@ public:
RecvInitRendering(
Endpoint<PCompositorBridgeChild>&& aCompositor,
Endpoint<PImageBridgeChild>&& aImageBridge,
Endpoint<PVRManagerChild>&& aVRBridge,
Endpoint<PVideoDecoderManagerChild>&& aVideoManager) override;
Endpoint<PVideoDecoderManagerChild>&& aVideoManager);
bool
RecvReinitRendering(
Endpoint<PCompositorBridgeChild>&& aCompositor,
Endpoint<PImageBridgeChild>&& aImageBridge,
Endpoint<PVRManagerChild>&& aVRBridge,
Endpoint<PVideoDecoderManagerChild>&& aVideoManager) override;
Endpoint<PVideoDecoderManagerChild>&& aVideoManager);
PProcessHangMonitorChild*
AllocPProcessHangMonitorChild(Transport* aTransport,

@ -2073,21 +2073,18 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
Endpoint<PCompositorBridgeChild> compositor;
Endpoint<PImageBridgeChild> imageBridge;
Endpoint<PVRManagerChild> vrBridge;
Endpoint<PVideoDecoderManagerChild> videoManager;
DebugOnly<bool> opened = gpm->CreateContentBridges(
OtherPid(),
&compositor,
&imageBridge,
&vrBridge,
&videoManager);
MOZ_ASSERT(opened);
Unused << SendInitRendering(
Move(compositor),
Move(imageBridge),
Move(vrBridge),
Move(videoManager));
gpm->AddListener(this);
@ -2201,21 +2198,18 @@ ContentParent::OnCompositorUnexpectedShutdown()
Endpoint<PCompositorBridgeChild> compositor;
Endpoint<PImageBridgeChild> imageBridge;
Endpoint<PVRManagerChild> vrBridge;
Endpoint<PVideoDecoderManagerChild> videoManager;
DebugOnly<bool> opened = gpm->CreateContentBridges(
OtherPid(),
&compositor,
&imageBridge,
&vrBridge,
&videoManager);
MOZ_ASSERT(opened);
Unused << SendReinitRendering(
Move(compositor),
Move(imageBridge),
Move(vrBridge),
Move(videoManager));
}

@ -44,7 +44,6 @@ include protocol PRemoteSpellcheckEngine;
include protocol PWebBrowserPersistDocument;
include protocol PWebrtcGlobal;
include protocol PPresentation;
include protocol PVRManager;
include protocol PVideoDecoderManager;
include protocol PFlyWebPublishedServer;
include DOMTypes;
@ -311,7 +310,6 @@ child:
async InitRendering(
Endpoint<PCompositorBridgeChild> compositor,
Endpoint<PImageBridgeChild> imageBridge,
Endpoint<PVRManagerChild> vr,
Endpoint<PVideoDecoderManagerChild> video);
// Re-create the rendering stack using the given endpoints. This is sent
@ -320,7 +318,6 @@ child:
async ReinitRendering(
Endpoint<PCompositorBridgeChild> compositor,
Endpoint<PImageBridgeChild> bridge,
Endpoint<PVRManagerChild> vr,
Endpoint<PVideoDecoderManagerChild> video);
/**

@ -107,7 +107,6 @@
#include "nsDeviceContext.h"
#include "nsSandboxFlags.h"
#include "FrameLayerBuilder.h"
#include "VRManagerChild.h"
#include "nsICommandParams.h"
#include "nsISHistory.h"
#include "nsQueryObject.h"
@ -2565,7 +2564,6 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
lf->SetShadowManager(shadowManager);
lf->IdentifyTextureHost(mTextureFactoryIdentifier);
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier);
}
mRemoteFrame = remoteFrame;

@ -94,7 +94,6 @@ DIRS += [
'xslt',
'xul',
'manifest',
'vr',
'u2f',
'console',
'performance',

@ -1,802 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "nsWrapperCache.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/VRDisplay.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/VRDisplayBinding.h"
#include "Navigator.h"
#include "gfxVR.h"
#include "VRDisplayClient.h"
#include "VRManagerChild.h"
#include "VRDisplayPresentation.h"
#include "nsIObserverService.h"
#include "nsIFrame.h"
#include "nsISupportsPrimitives.h"
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
VRFieldOfView::VRFieldOfView(nsISupports* aParent,
double aUpDegrees, double aRightDegrees,
double aDownDegrees, double aLeftDegrees)
: mParent(aParent)
, mUpDegrees(aUpDegrees)
, mRightDegrees(aRightDegrees)
, mDownDegrees(aDownDegrees)
, mLeftDegrees(aLeftDegrees)
{
}
VRFieldOfView::VRFieldOfView(nsISupports* aParent, const gfx::VRFieldOfView& aSrc)
: mParent(aParent)
, mUpDegrees(aSrc.upDegrees)
, mRightDegrees(aSrc.rightDegrees)
, mDownDegrees(aSrc.downDegrees)
, mLeftDegrees(aSrc.leftDegrees)
{
}
bool
VRDisplayCapabilities::HasPosition() const
{
return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_Position);
}
bool
VRDisplayCapabilities::HasOrientation() const
{
return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_Orientation);
}
bool
VRDisplayCapabilities::HasExternalDisplay() const
{
return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_External);
}
bool
VRDisplayCapabilities::CanPresent() const
{
return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_Present);
}
uint32_t
VRDisplayCapabilities::MaxLayers() const
{
return CanPresent() ? 1 : 0;
}
/*static*/ bool
VRDisplay::RefreshVRDisplays(uint64_t aWindowId)
{
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
return vm && vm->RefreshVRDisplaysWithCallback(aWindowId);
}
/*static*/ void
VRDisplay::UpdateVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays, nsPIDOMWindowInner* aWindow)
{
nsTArray<RefPtr<VRDisplay>> displays;
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
nsTArray<RefPtr<gfx::VRDisplayClient>> updatedDisplays;
if (vm && vm->GetVRDisplays(updatedDisplays)) {
for (size_t i = 0; i < updatedDisplays.Length(); i++) {
RefPtr<gfx::VRDisplayClient> display = updatedDisplays[i];
bool isNewDisplay = true;
for (size_t j = 0; j < aDisplays.Length(); j++) {
if (aDisplays[j]->GetClient()->GetDisplayInfo() == display->GetDisplayInfo()) {
displays.AppendElement(aDisplays[j]);
isNewDisplay = false;
}
}
if (isNewDisplay) {
displays.AppendElement(new VRDisplay(aWindow, display));
}
}
}
aDisplays = displays;
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VRFieldOfView, mParent)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRFieldOfView, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRFieldOfView, Release)
JSObject*
VRFieldOfView::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return VRFieldOfViewBinding::Wrap(aCx, this, aGivenProto);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(VREyeParameters)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(VREyeParameters)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent, mFOV)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
tmp->mOffset = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(VREyeParameters)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent, mFOV)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(VREyeParameters)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mOffset)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VREyeParameters, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VREyeParameters, Release)
VREyeParameters::VREyeParameters(nsISupports* aParent,
const gfx::Point3D& aEyeTranslation,
const gfx::VRFieldOfView& aFOV,
const gfx::IntSize& aRenderSize)
: mParent(aParent)
, mEyeTranslation(aEyeTranslation)
, mRenderSize(aRenderSize)
{
mFOV = new VRFieldOfView(aParent, aFOV);
mozilla::HoldJSObjects(this);
}
VREyeParameters::~VREyeParameters()
{
mozilla::DropJSObjects(this);
}
VRFieldOfView*
VREyeParameters::FieldOfView()
{
return mFOV;
}
void
VREyeParameters::GetOffset(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval, ErrorResult& aRv)
{
if (!mOffset) {
// Lazily create the Float32Array
mOffset = dom::Float32Array::Create(aCx, this, 3, mEyeTranslation.components);
if (!mOffset) {
aRv.NoteJSContextException(aCx);
return;
}
}
aRetval.set(mOffset);
}
JSObject*
VREyeParameters::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return VREyeParametersBinding::Wrap(aCx, this, aGivenProto);
}
VRStageParameters::VRStageParameters(nsISupports* aParent,
const gfx::Matrix4x4& aSittingToStandingTransform,
const gfx::Size& aSize)
: mParent(aParent)
, mSittingToStandingTransform(aSittingToStandingTransform)
, mSittingToStandingTransformArray(nullptr)
, mSize(aSize)
{
mozilla::HoldJSObjects(this);
}
VRStageParameters::~VRStageParameters()
{
mozilla::DropJSObjects(this);
}
JSObject*
VRStageParameters::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return VRStageParametersBinding::Wrap(aCx, this, aGivenProto);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(VRStageParameters)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(VRStageParameters)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
tmp->mSittingToStandingTransformArray = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(VRStageParameters)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(VRStageParameters)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mSittingToStandingTransformArray)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRStageParameters, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRStageParameters, Release)
void
VRStageParameters::GetSittingToStandingTransform(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
if (!mSittingToStandingTransformArray) {
// Lazily create the Float32Array
mSittingToStandingTransformArray = dom::Float32Array::Create(aCx, this, 16,
mSittingToStandingTransform.components);
if (!mSittingToStandingTransformArray) {
aRv.NoteJSContextException(aCx);
return;
}
}
aRetval.set(mSittingToStandingTransformArray);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VRDisplayCapabilities, mParent)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRDisplayCapabilities, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRDisplayCapabilities, Release)
JSObject*
VRDisplayCapabilities::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return VRDisplayCapabilitiesBinding::Wrap(aCx, this, aGivenProto);
}
VRPose::VRPose(nsISupports* aParent, const gfx::VRHMDSensorState& aState)
: Pose(aParent)
, mVRState(aState)
{
mFrameId = aState.inputFrameID;
mozilla::HoldJSObjects(this);
}
VRPose::VRPose(nsISupports* aParent)
: Pose(aParent)
{
mFrameId = 0;
mVRState.Clear();
mozilla::HoldJSObjects(this);
}
VRPose::~VRPose()
{
mozilla::DropJSObjects(this);
}
void
VRPose::GetPosition(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
SetFloat32Array(aCx, aRetval, mPosition, mVRState.position, 3,
!mPosition && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Position),
aRv);
}
void
VRPose::GetLinearVelocity(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
SetFloat32Array(aCx, aRetval, mLinearVelocity, mVRState.linearVelocity, 3,
!mLinearVelocity && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Position),
aRv);
}
void
VRPose::GetLinearAcceleration(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
SetFloat32Array(aCx, aRetval, mLinearAcceleration, mVRState.linearAcceleration, 3,
!mLinearAcceleration && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_LinearAcceleration),
aRv);
}
void
VRPose::GetOrientation(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
SetFloat32Array(aCx, aRetval, mOrientation, mVRState.orientation, 4,
!mOrientation && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Orientation),
aRv);
}
void
VRPose::GetAngularVelocity(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
SetFloat32Array(aCx, aRetval, mAngularVelocity, mVRState.angularVelocity, 3,
!mAngularVelocity && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Orientation),
aRv);
}
void
VRPose::GetAngularAcceleration(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
SetFloat32Array(aCx, aRetval, mAngularAcceleration, mVRState.angularAcceleration, 3,
!mAngularAcceleration && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_AngularAcceleration),
aRv);
}
JSObject*
VRPose::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return VRPoseBinding::Wrap(aCx, this, aGivenProto);
}
/* virtual */ JSObject*
VRDisplay::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return VRDisplayBinding::Wrap(aCx, this, aGivenProto);
}
VRDisplay::VRDisplay(nsPIDOMWindowInner* aWindow, gfx::VRDisplayClient* aClient)
: DOMEventTargetHelper(aWindow)
, mClient(aClient)
, mDepthNear(0.01f) // Default value from WebVR Spec
, mDepthFar(10000.0f) // Default value from WebVR Spec
{
const gfx::VRDisplayInfo& info = aClient->GetDisplayInfo();
mDisplayId = info.GetDisplayID();
mDisplayName = NS_ConvertASCIItoUTF16(info.GetDisplayName());
mCapabilities = new VRDisplayCapabilities(aWindow, info.GetCapabilities());
if (info.GetCapabilities() & gfx::VRDisplayCapabilityFlags::Cap_StageParameters) {
mStageParameters = new VRStageParameters(aWindow,
info.GetSittingToStandingTransform(),
info.GetStageSize());
}
mozilla::HoldJSObjects(this);
}
VRDisplay::~VRDisplay()
{
ExitPresentInternal();
mozilla::DropJSObjects(this);
}
void
VRDisplay::LastRelease()
{
// We don't want to wait for the CC to free up the presentation
// for use in other documents, so we do this in LastRelease().
ExitPresentInternal();
}
already_AddRefed<VREyeParameters>
VRDisplay::GetEyeParameters(VREye aEye)
{
gfx::VRDisplayInfo::Eye eye = aEye == VREye::Left ? gfx::VRDisplayInfo::Eye_Left : gfx::VRDisplayInfo::Eye_Right;
RefPtr<VREyeParameters> params =
new VREyeParameters(GetParentObject(),
mClient->GetDisplayInfo().GetEyeTranslation(eye),
mClient->GetDisplayInfo().GetEyeFOV(eye),
mClient->GetDisplayInfo().SuggestedEyeResolution());
return params.forget();
}
VRDisplayCapabilities*
VRDisplay::Capabilities()
{
return mCapabilities;
}
VRStageParameters*
VRDisplay::GetStageParameters()
{
return mStageParameters;
}
void
VRDisplay::UpdateFrameInfo()
{
/**
* The WebVR 1.1 spec Requires that VRDisplay.getPose and VRDisplay.getFrameData
* must return the same values until the next VRDisplay.submitFrame.
*
* mFrameInfo is marked dirty at the end of the frame or start of a new
* composition and lazily created here in order to receive mid-frame
* pose-prediction updates while still ensuring conformance to the WebVR spec
* requirements.
*
* If we are not presenting WebVR content, the frame will never end and we should
* return the latest frame data always.
*/
if (mFrameInfo.IsDirty() || !mPresentation) {
gfx::VRHMDSensorState state = mClient->GetSensorState();
const gfx::VRDisplayInfo& info = mClient->GetDisplayInfo();
mFrameInfo.Update(info, state, mDepthNear, mDepthFar);
}
}
bool
VRDisplay::GetFrameData(VRFrameData& aFrameData)
{
UpdateFrameInfo();
aFrameData.Update(mFrameInfo);
return true;
}
already_AddRefed<VRPose>
VRDisplay::GetPose()
{
UpdateFrameInfo();
RefPtr<VRPose> obj = new VRPose(GetParentObject(), mFrameInfo.mVRState);
return obj.forget();
}
void
VRDisplay::ResetPose()
{
mClient->ZeroSensor();
}
already_AddRefed<Promise>
VRDisplay::RequestPresent(const nsTArray<VRLayer>& aLayers, ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
RefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE(obs, nullptr);
if (mClient->GetIsPresenting()) {
// Only one presentation allowed per VRDisplay
// on a first-come-first-serve basis.
promise->MaybeRejectWithUndefined();
} else {
mPresentation = mClient->BeginPresentation(aLayers);
mFrameInfo.Clear();
nsresult rv = obs->AddObserver(this, "inner-window-destroyed", false);
if (NS_WARN_IF(NS_FAILED(rv))) {
mPresentation = nullptr;
promise->MaybeRejectWithUndefined();
} else {
promise->MaybeResolve(JS::UndefinedHandleValue);
}
}
return promise.forget();
}
NS_IMETHODIMP
VRDisplay::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData)
{
MOZ_ASSERT(NS_IsMainThread());
if (strcmp(aTopic, "inner-window-destroyed") == 0) {
nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(aSubject);
NS_ENSURE_TRUE(wrapper, NS_ERROR_FAILURE);
uint64_t innerID;
nsresult rv = wrapper->GetData(&innerID);
NS_ENSURE_SUCCESS(rv, rv);
if (!GetOwner() || GetOwner()->WindowID() == innerID) {
ExitPresentInternal();
}
return NS_OK;
}
// This should not happen.
return NS_ERROR_FAILURE;
}
already_AddRefed<Promise>
VRDisplay::ExitPresent(ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
RefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
if (!IsPresenting()) {
// We can not exit a presentation outside of the context that
// started the presentation.
promise->MaybeRejectWithUndefined();
} else {
promise->MaybeResolve(JS::UndefinedHandleValue);
ExitPresentInternal();
}
return promise.forget();
}
void
VRDisplay::ExitPresentInternal()
{
mPresentation = nullptr;
}
void
VRDisplay::GetLayers(nsTArray<VRLayer>& result)
{
if (mPresentation) {
mPresentation->GetDOMLayers(result);
} else {
result = nsTArray<VRLayer>();
}
}
void
VRDisplay::SubmitFrame()
{
if (mPresentation) {
mPresentation->SubmitFrame();
}
mFrameInfo.Clear();