summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-11-26 16:41:20 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-11-26 16:41:20 +0100
commit7504ca8ab4b0a145488f03c51a0f78ffd5682174 (patch)
tree29f30a39758d9a5dbb31dfd006f4d837b2f18e34 /dom
parent083c6b7b99107f5f107b3c86487d13d04184afac (diff)
downloadUXP-7504ca8ab4b0a145488f03c51a0f78ffd5682174.tar
UXP-7504ca8ab4b0a145488f03c51a0f78ffd5682174.tar.gz
UXP-7504ca8ab4b0a145488f03c51a0f78ffd5682174.tar.lz
UXP-7504ca8ab4b0a145488f03c51a0f78ffd5682174.tar.xz
UXP-7504ca8ab4b0a145488f03c51a0f78ffd5682174.zip
Remove VR hardware support.
This resolves #881
Diffstat (limited to 'dom')
-rw-r--r--dom/base/Element.cpp1
-rw-r--r--dom/base/Navigator.cpp78
-rw-r--r--dom/base/Navigator.h7
-rw-r--r--dom/base/nsGlobalWindow.cpp66
-rw-r--r--dom/base/nsGlobalWindow.h22
-rw-r--r--dom/canvas/WebGLContext.cpp79
-rw-r--r--dom/canvas/WebGLContext.h3
-rw-r--r--dom/html/HTMLCanvasElement.cpp41
-rw-r--r--dom/html/HTMLCanvasElement.h4
-rw-r--r--dom/ipc/ContentChild.cpp9
-rw-r--r--dom/ipc/ContentChild.h6
-rw-r--r--dom/ipc/ContentParent.cpp6
-rw-r--r--dom/ipc/PContent.ipdl3
-rw-r--r--dom/ipc/TabChild.cpp2
-rw-r--r--dom/moz.build1
-rw-r--r--dom/vr/VRDisplay.cpp802
-rw-r--r--dom/vr/VRDisplay.h362
-rw-r--r--dom/vr/VREventObserver.cpp79
-rw-r--r--dom/vr/VREventObserver.h33
-rw-r--r--dom/vr/moz.build22
-rw-r--r--dom/webidl/Navigator.webidl8
-rw-r--r--dom/webidl/VRDisplay.webidl286
-rw-r--r--dom/webidl/moz.build1
23 files changed, 3 insertions, 1918 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp
index 79b36a314..3760dc43f 100644
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.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"
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
index 1bc4f82f4..286cd0e79 100644
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -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
//*****************************************************************************
diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h
index d47a80bc1..91b7fc15c 100644
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -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();
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index 86160c77c..677e1a0ea 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -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)
@@ -10508,24 +10496,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)
{
MOZ_ASSERT(IsOuterWindow());
@@ -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)
diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h
index 80bf33b80..1cb825a77 100644
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -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;
diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp
index 14bc7e3e3..e2e05e5fd 100644
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -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
diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h
index b4d416a33..3ec307b00 100644
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -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
diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp
index 88b41bce0..527135a80 100644
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -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
diff --git a/dom/html/HTMLCanvasElement.h b/dom/html/HTMLCanvasElement.h
index 81c141d3c..746fab198 100644
--- a/dom/html/HTMLCanvasElement.h
+++ b/dom/html/HTMLCanvasElement.h
@@ -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();
diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
index fc288e2c5..fdf0fcf3e 100644
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -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) {
diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h
index ba590b58e..f29d17e7f 100644
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -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,
diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
index 5c6aadb77..417420ecb 100644
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -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));
}
diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl
index c01ad59c1..9298f9d02 100644
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -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);
/**
diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp
index 244fa9969..3fe94001e 100644
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -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;
diff --git a/dom/moz.build b/dom/moz.build
index 358fc6411..54dc0510e 100644
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -94,7 +94,6 @@ DIRS += [
'xslt',
'xul',
'manifest',
- 'vr',
'u2f',
'console',
'performance',
diff --git a/dom/vr/VRDisplay.cpp b/dom/vr/VRDisplay.cpp
deleted file mode 100644
index 80922422f..000000000
--- a/dom/vr/VRDisplay.cpp
+++ /dev/null
@@ -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();
-}
-
-int32_t
-VRDisplay::RequestAnimationFrame(FrameRequestCallback& aCallback,
-ErrorResult& aError)
-{
- gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
-
- int32_t handle;
- aError = vm->ScheduleFrameRequestCallback(aCallback, &handle);
- return handle;
-}
-
-void
-VRDisplay::CancelAnimationFrame(int32_t aHandle, ErrorResult& aError)
-{
- gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
- vm->CancelFrameRequestCallback(aHandle);
-}
-
-
-bool
-VRDisplay::IsPresenting() const
-{
- // IsPresenting returns true only if this Javascript context is presenting
- // and will return false if another context is presenting.
- return mPresentation != nullptr;
-}
-
-bool
-VRDisplay::IsConnected() const
-{
- return mClient->GetIsConnected();
-}
-
-NS_IMPL_CYCLE_COLLECTION_INHERITED(VRDisplay, DOMEventTargetHelper, mCapabilities, mStageParameters)
-
-NS_IMPL_ADDREF_INHERITED(VRDisplay, DOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(VRDisplay, DOMEventTargetHelper)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(VRDisplay)
-NS_INTERFACE_MAP_ENTRY(nsIObserver)
-NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, DOMEventTargetHelper)
-NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(VRFrameData)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(VRFrameData)
- NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent, mPose)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
- tmp->mLeftProjectionMatrix = nullptr;
- tmp->mLeftViewMatrix = nullptr;
- tmp->mRightProjectionMatrix = nullptr;
- tmp->mRightViewMatrix = nullptr;
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(VRFrameData)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent, mPose)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(VRFrameData)
- NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
- NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mLeftProjectionMatrix)
- NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mLeftViewMatrix)
- NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mRightProjectionMatrix)
- NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mRightViewMatrix)
-NS_IMPL_CYCLE_COLLECTION_TRACE_END
-
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRFrameData, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRFrameData, Release)
-
-VRFrameData::VRFrameData(nsISupports* aParent)
- : mParent(aParent)
- , mLeftProjectionMatrix(nullptr)
- , mLeftViewMatrix(nullptr)
- , mRightProjectionMatrix(nullptr)
- , mRightViewMatrix(nullptr)
-{
- mozilla::HoldJSObjects(this);
- mPose = new VRPose(aParent);
-}
-
-VRFrameData::~VRFrameData()
-{
- mozilla::DropJSObjects(this);
-}
-
-/* static */ already_AddRefed<VRFrameData>
-VRFrameData::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
-{
- RefPtr<VRFrameData> obj = new VRFrameData(aGlobal.GetAsSupports());
- return obj.forget();
-}
-
-JSObject*
-VRFrameData::WrapObject(JSContext* aCx,
- JS::Handle<JSObject*> aGivenProto)
-{
- return VRFrameDataBinding::Wrap(aCx, this, aGivenProto);
-}
-
-VRPose*
-VRFrameData::Pose()
-{
- return mPose;
-}
-
-void
-VRFrameData::LazyCreateMatrix(JS::Heap<JSObject*>& aArray, gfx::Matrix4x4& aMat, JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval, ErrorResult& aRv)
-{
- if (!aArray) {
- // Lazily create the Float32Array
- aArray = dom::Float32Array::Create(aCx, this, 16, aMat.components);
- if (!aArray) {
- aRv.NoteJSContextException(aCx);
- return;
- }
- }
- if (aArray) {
- JS::ExposeObjectToActiveJS(aArray);
- }
- aRetval.set(aArray);
-}
-
-double
-VRFrameData::Timestamp() const
-{
- // Converting from seconds to milliseconds
- return mFrameInfo.mVRState.timestamp * 1000.0f;
-}
-
-void
-VRFrameData::GetLeftProjectionMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv)
-{
- LazyCreateMatrix(mLeftProjectionMatrix, mFrameInfo.mLeftProjection, aCx,
- aRetval, aRv);
-}
-
-void
-VRFrameData::GetLeftViewMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv)
-{
- LazyCreateMatrix(mLeftViewMatrix, mFrameInfo.mLeftView, aCx, aRetval, aRv);
-}
-
-void
-VRFrameData::GetRightProjectionMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv)
-{
- LazyCreateMatrix(mRightProjectionMatrix, mFrameInfo.mRightProjection, aCx,
- aRetval, aRv);
-}
-
-void
-VRFrameData::GetRightViewMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv)
-{
- LazyCreateMatrix(mRightViewMatrix, mFrameInfo.mRightView, aCx, aRetval, aRv);
-}
-
-void
-VRFrameData::Update(const VRFrameInfo& aFrameInfo)
-{
- mFrameInfo = aFrameInfo;
-
- mLeftProjectionMatrix = nullptr;
- mLeftViewMatrix = nullptr;
- mRightProjectionMatrix = nullptr;
- mRightViewMatrix = nullptr;
-
- mPose = new VRPose(GetParentObject(), mFrameInfo.mVRState);
-}
-
-void
-VRFrameInfo::Update(const gfx::VRDisplayInfo& aInfo,
- const gfx::VRHMDSensorState& aState,
- float aDepthNear,
- float aDepthFar)
-{
- mVRState = aState;
-
- gfx::Quaternion qt;
- if (mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Orientation) {
- qt.x = mVRState.orientation[0];
- qt.y = mVRState.orientation[1];
- qt.z = mVRState.orientation[2];
- qt.w = mVRState.orientation[3];
- }
- gfx::Point3D pos;
- if (mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Position) {
- pos.x = -mVRState.position[0];
- pos.y = -mVRState.position[1];
- pos.z = -mVRState.position[2];
- }
- gfx::Matrix4x4 matHead;
- matHead.SetRotationFromQuaternion(qt);
- matHead.PreTranslate(pos);
-
- mLeftView = matHead;
- mLeftView.PostTranslate(-aInfo.mEyeTranslation[gfx::VRDisplayInfo::Eye_Left]);
-
- mRightView = matHead;
- mRightView.PostTranslate(-aInfo.mEyeTranslation[gfx::VRDisplayInfo::Eye_Right]);
-
- // Avoid division by zero within ConstructProjectionMatrix
- const float kEpsilon = 0.00001f;
- if (fabs(aDepthFar - aDepthNear) < kEpsilon) {
- aDepthFar = aDepthNear + kEpsilon;
- }
-
- const gfx::VRFieldOfView leftFOV = aInfo.mEyeFOV[gfx::VRDisplayInfo::Eye_Left];
- mLeftProjection = leftFOV.ConstructProjectionMatrix(aDepthNear, aDepthFar, true);
- const gfx::VRFieldOfView rightFOV = aInfo.mEyeFOV[gfx::VRDisplayInfo::Eye_Right];
- mRightProjection = rightFOV.ConstructProjectionMatrix(aDepthNear, aDepthFar, true);
-}
-
-VRFrameInfo::VRFrameInfo()
-{
- mVRState.Clear();
-}
-
-bool
-VRFrameInfo::IsDirty()
-{
- return mVRState.timestamp == 0;
-}
-
-void
-VRFrameInfo::Clear()
-{
- mVRState.Clear();
-}
-
-} // namespace dom
-} // namespace mozilla
diff --git a/dom/vr/VRDisplay.h b/dom/vr/VRDisplay.h
deleted file mode 100644
index d40d3d8ac..000000000
--- a/dom/vr/VRDisplay.h
+++ /dev/null
@@ -1,362 +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/. */
-
-#ifndef mozilla_dom_VRDisplay_h_
-#define mozilla_dom_VRDisplay_h_
-
-#include <stdint.h>
-
-#include "mozilla/ErrorResult.h"
-#include "mozilla/dom/TypedArray.h"
-#include "mozilla/dom/VRDisplayBinding.h"
-#include "mozilla/DOMEventTargetHelper.h"
-#include "mozilla/dom/DOMPoint.h"
-#include "mozilla/dom/DOMRect.h"
-#include "mozilla/dom/Pose.h"
-
-#include "nsCOMPtr.h"
-#include "nsString.h"
-#include "nsTArray.h"
-
-#include "gfxVR.h"
-
-namespace mozilla {
-namespace gfx {
-class VRDisplayClient;
-class VRDisplayPresentation;
-struct VRFieldOfView;
-enum class VRDisplayCapabilityFlags : uint16_t;
-struct VRHMDSensorState;
-}
-namespace dom {
-class Navigator;
-
-class VRFieldOfView final : public nsWrapperCache
-{
-public:
- VRFieldOfView(nsISupports* aParent,
- double aUpDegrees, double aRightDegrees,
- double aDownDegrees, double aLeftDegrees);
- VRFieldOfView(nsISupports* aParent, const gfx::VRFieldOfView& aSrc);
-
- NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRFieldOfView)
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRFieldOfView)
-
- double UpDegrees() const { return mUpDegrees; }
- double RightDegrees() const { return mRightDegrees; }
- double DownDegrees() const { return mDownDegrees; }
- double LeftDegrees() const { return mLeftDegrees; }
-
- nsISupports* GetParentObject() const { return mParent; }
- virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-protected:
- virtual ~VRFieldOfView() {}
-
- nsCOMPtr<nsISupports> mParent;
-
- double mUpDegrees;
- double mRightDegrees;
- double mDownDegrees;
- double mLeftDegrees;
-};
-
-class VRDisplayCapabilities final : public nsWrapperCache
-{
-public:
- VRDisplayCapabilities(nsISupports* aParent, const gfx::VRDisplayCapabilityFlags& aFlags)
- : mParent(aParent)
- , mFlags(aFlags)
- {
- }
-
- NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRDisplayCapabilities)
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRDisplayCapabilities)
-
- nsISupports* GetParentObject() const
- {
- return mParent;
- }
-
- virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
- bool HasPosition() const;
- bool HasOrientation() const;
- bool HasExternalDisplay() const;
- bool CanPresent() const;
- uint32_t MaxLayers() const;
-
-protected:
- ~VRDisplayCapabilities() {}
- nsCOMPtr<nsISupports> mParent;
- gfx::VRDisplayCapabilityFlags mFlags;
-};
-
-class VRPose final : public Pose
-{
-
-public:
- VRPose(nsISupports* aParent, const gfx::VRHMDSensorState& aState);
- explicit VRPose(nsISupports* aParent);
-
- uint32_t FrameID() const { return mFrameId; }
-
- virtual void GetPosition(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv) override;
- virtual void GetLinearVelocity(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv) override;
- virtual void GetLinearAcceleration(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv) override;
- virtual void GetOrientation(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv) override;
- virtual void GetAngularVelocity(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv) override;
- virtual void GetAngularAcceleration(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv) override;
-
- virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-protected:
- ~VRPose();
-
- uint32_t mFrameId;
- gfx::VRHMDSensorState mVRState;
-};
-
-struct VRFrameInfo
-{
- VRFrameInfo();
-
- void Update(const gfx::VRDisplayInfo& aInfo,
- const gfx::VRHMDSensorState& aState,
- float aDepthNear,
- float aDepthFar);
-
- void Clear();
- bool IsDirty();
-
- gfx::VRHMDSensorState mVRState;
- gfx::Matrix4x4 mLeftProjection;
- gfx::Matrix4x4 mLeftView;
- gfx::Matrix4x4 mRightProjection;
- gfx::Matrix4x4 mRightView;
-
-};
-
-class VRFrameData final : public nsWrapperCache
-{
-public:
- NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRFrameData)
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRFrameData)
-
- explicit VRFrameData(nsISupports* aParent);
- static already_AddRefed<VRFrameData> Constructor(const GlobalObject& aGlobal,
- ErrorResult& aRv);
-
- void Update(const VRFrameInfo& aFrameInfo);
-
- // WebIDL Members
- double Timestamp() const;
- void GetLeftProjectionMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv);
- void GetLeftViewMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv);
- void GetRightProjectionMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv);
- void GetRightViewMatrix(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv);
-
- VRPose* Pose();
-
- // WebIDL Boilerplate
- nsISupports* GetParentObject() const { return mParent; }
- virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-protected:
- ~VRFrameData();
- nsCOMPtr<nsISupports> mParent;
-
- VRFrameInfo mFrameInfo;
- RefPtr<VRPose> mPose;
- JS::Heap<JSObject*> mLeftProjectionMatrix;
- JS::Heap<JSObject*> mLeftViewMatrix;
- JS::Heap<JSObject*> mRightProjectionMatrix;
- JS::Heap<JSObject*> mRightViewMatrix;
-
- void LazyCreateMatrix(JS::Heap<JSObject*>& aArray, gfx::Matrix4x4& aMat,
- JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv);
-};
-
-class VRStageParameters final : public nsWrapperCache
-{
-public:
- VRStageParameters(nsISupports* aParent,
- const gfx::Matrix4x4& aSittingToStandingTransform,
- const gfx::Size& aSize);
-
- NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRStageParameters)
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRStageParameters)
-
- void GetSittingToStandingTransform(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRetval,
- ErrorResult& aRv);
- float SizeX() const { return mSize.width; }
- float SizeZ() const { return mSize.height; }
-
- nsISupports* GetParentObject() const { return mParent; }
- virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-protected:
- ~VRStageParameters();
-
- nsCOMPtr<nsISupports> mParent;
-
- gfx::Matrix4x4 mSittingToStandingTransform;
- JS::Heap<JSObject*> mSittingToStandingTransformArray;
- gfx::Size mSize;
-};
-
-class VREyeParameters final : public nsWrapperCache
-{
-public:
- VREyeParameters(nsISupports* aParent,
- const gfx::Point3D& aEyeTranslation,
- const gfx::VRFieldOfView& aFOV,
- const gfx::IntSize& aRenderSize);
-
- NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VREyeParameters)
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VREyeParameters)
-
- void GetOffset(JSContext* aCx, JS::MutableHandle<JSObject*> aRetVal,
- ErrorResult& aRv);
-
- VRFieldOfView* FieldOfView();
-
- uint32_t RenderWidth() const { return mRenderSize.width; }
- uint32_t RenderHeight() const { return mRenderSize.height; }
-
- nsISupports* GetParentObject() const { return mParent; }
- virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-protected:
- ~VREyeParameters();
-
- nsCOMPtr<nsISupports> mParent;
-
-
- gfx::Point3D mEyeTranslation;
- gfx::IntSize mRenderSize;
- JS::Heap<JSObject*> mOffset;
- RefPtr<VRFieldOfView> mFOV;
-};
-
-class VRDisplay final : public DOMEventTargetHelper
- , public nsIObserver
-{
-public:
- NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_NSIOBSERVER
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRDisplay, DOMEventTargetHelper)
-
- virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
- bool IsPresenting() const;
- bool IsConnected() const;
-
- VRDisplayCapabilities* Capabilities();
- VRStageParameters* GetStageParameters();
-
- uint32_t DisplayId() const { return mDisplayId; }
- void GetDisplayName(nsAString& aDisplayName) const { aDisplayName = mDisplayName; }
-
- static bool RefreshVRDisplays(uint64_t aWindowId);
- static void UpdateVRDisplays(nsTArray<RefPtr<VRDisplay> >& aDisplays,
- nsPIDOMWindowInner* aWindow);
-
- gfx::VRDisplayClient *GetClient() {
- return mClient;
- }
-
- virtual already_AddRefed<VREyeParameters> GetEyeParameters(VREye aEye);
-
- bool GetFrameData(VRFrameData& aFrameData);
- already_AddRefed<VRPose> GetPose();
- void ResetPose();
-
- double DepthNear() {
- return mDepthNear;
- }
-
- double DepthFar() {
- return mDepthFar;
- }
-
- void SetDepthNear(double aDepthNear) {
- // XXX When we start sending depth buffers to VRLayer's we will want
- // to communicate this with the VRDisplayHost
- mDepthNear = aDepthNear;
- }
-
- void SetDepthFar(double aDepthFar) {
- // XXX When we start sending depth buffers to VRLayer's we will want
- // to communicate this with the VRDisplayHost
- mDepthFar = aDepthFar;
- }
-
- already_AddRefed<Promise> RequestPresent(const nsTArray<VRLayer>& aLayers, ErrorResult& aRv);
- already_AddRefed<Promise> ExitPresent(ErrorResult& aRv);
- void GetLayers(nsTArray<VRLayer>& result);
- void SubmitFrame();
-
- int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback,
- mozilla::ErrorResult& aError);
- void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError);
-
-protected:
- VRDisplay(nsPIDOMWindowInner* aWindow, gfx::VRDisplayClient* aClient);
- virtual ~VRDisplay();
- virtual void LastRelease() override;
-
- void ExitPresentInternal();
- void UpdateFrameInfo();
-
- RefPtr<gfx::VRDisplayClient> mClient;
-
- uint32_t mDisplayId;
- nsString mDisplayName;
-
- RefPtr<VRDisplayCapabilities> mCapabilities;
- RefPtr<VRStageParameters> mStageParameters;
-
- double mDepthNear;
- double mDepthFar;
-
- RefPtr<gfx::VRDisplayPresentation> mPresentation;
-
- /**
- * The WebVR 1.1 spec Requires that VRDisplay.getPose and VRDisplay.getFrameData
- * must return the same values until the next VRDisplay.submitFrame.
- * mFrameInfo is updated only on the first call to either function within one
- * frame. Subsequent calls before the next SubmitFrame or ExitPresent call
- * will use these cached values.
- */
- VRFrameInfo mFrameInfo;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif
diff --git a/dom/vr/VREventObserver.cpp b/dom/vr/VREventObserver.cpp
deleted file mode 100644
index 1b6d1b978..000000000
--- a/dom/vr/VREventObserver.cpp
+++ /dev/null
@@ -1,79 +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 "VREventObserver.h"
-
-#include "nsContentUtils.h"
-#include "nsGlobalWindow.h"
-#include "VRManagerChild.h"
-
-namespace mozilla {
-namespace dom {
-
-using namespace gfx;
-
-/**
- * This class is used by nsGlobalWindow to implement window.onvrdisplayconnected,
- * window.onvrdisplaydisconnected, and window.onvrdisplaypresentchange.
- */
-VREventObserver::VREventObserver(nsGlobalWindow* aGlobalWindow)
- : mWindow(aGlobalWindow)
-{
- MOZ_ASSERT(aGlobalWindow && aGlobalWindow->IsInnerWindow());
-
- VRManagerChild* vmc = VRManagerChild::Get();
- if (vmc) {
- vmc->AddListener(this);
- }
-}
-
-VREventObserver::~VREventObserver()
-{
- VRManagerChild* vmc = VRManagerChild::Get();
- if (vmc) {
- vmc->RemoveListener(this);
- }
-}
-
-void
-VREventObserver::NotifyVRDisplayConnect()
-{
- /**
- * We do not call nsGlobalWindow::NotifyActiveVRDisplaysChanged here, as we
- * can assume that a newly enumerated display is not presenting WebVR
- * content.
- */
- if (mWindow->AsInner()->IsCurrentInnerWindow()) {
- MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
- mWindow->GetOuterWindow()->DispatchCustomEvent(
- NS_LITERAL_STRING("vrdisplayconnected"));
- }
-}
-
-void
-VREventObserver::NotifyVRDisplayDisconnect()
-{
- if (mWindow->AsInner()->IsCurrentInnerWindow()) {
- mWindow->NotifyActiveVRDisplaysChanged();
- MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
- mWindow->GetOuterWindow()->DispatchCustomEvent(
- NS_LITERAL_STRING("vrdisplaydisconnected"));
- }
-}
-
-void
-VREventObserver::NotifyVRDisplayPresentChange()
-{
- if (mWindow->AsInner()->IsCurrentInnerWindow()) {
- mWindow->NotifyActiveVRDisplaysChanged();
- MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
- mWindow->GetOuterWindow()->DispatchCustomEvent(
- NS_LITERAL_STRING("vrdisplaypresentchange"));
- }
-}
-
-} // namespace dom
-} // namespace mozilla
diff --git a/dom/vr/VREventObserver.h b/dom/vr/VREventObserver.h
deleted file mode 100644
index a30bb5960..000000000
--- a/dom/vr/VREventObserver.h
+++ /dev/null
@@ -1,33 +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/. */
-
-#ifndef mozilla_dom_VREventObserver_h
-#define mozilla_dom_VREventObserver_h
-
-class nsGlobalWindow;
-
-namespace mozilla {
-namespace dom {
-
-class VREventObserver final
-{
-public:
- ~VREventObserver();
- explicit VREventObserver(nsGlobalWindow* aGlobalWindow);
-
- void NotifyVRDisplayConnect();
- void NotifyVRDisplayDisconnect();
- void NotifyVRDisplayPresentChange();
-
-private:
- // Weak pointer, instance is owned by mWindow.
- nsGlobalWindow* MOZ_NON_OWNING_REF mWindow;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_VREventObserver_h
diff --git a/dom/vr/moz.build b/dom/vr/moz.build
deleted file mode 100644
index a4aa8d69b..000000000
--- a/dom/vr/moz.build
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-EXPORTS.mozilla.dom += [
- 'VRDisplay.h',
- 'VREventObserver.h',
- ]
-
-UNIFIED_SOURCES = [
- 'VRDisplay.cpp',
- 'VREventObserver.cpp',
- ]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-FINAL_LIBRARY = 'xul'
-LOCAL_INCLUDES += [
- '/dom/base'
-]
diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl
index 5452f3247..c353e8be7 100644
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -268,14 +268,6 @@ partial interface Navigator {
};
#endif // MOZ_GAMEPAD
-partial interface Navigator {
- [Throws, Pref="dom.vr.enabled"]
- Promise<sequence<VRDisplay>> getVRDisplays();
- // TODO: Use FrozenArray once available. (Bug 1236777)
- [Frozen, Cached, Pure, Pref="dom.vr.enabled"]
- readonly attribute sequence<VRDisplay> activeVRDisplays;
-};
-
#ifdef MOZ_TIME_MANAGER
// nsIDOMMozNavigatorTime
partial interface Navigator {
diff --git a/dom/webidl/VRDisplay.webidl b/dom/webidl/VRDisplay.webidl
deleted file mode 100644
index 63ebd1205..000000000
--- a/dom/webidl/VRDisplay.webidl
+++ /dev/null
@@ -1,286 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-enum VREye {
- "left",
- "right"
-};
-
-[Pref="dom.vr.enabled",
- HeaderFile="mozilla/dom/VRDisplay.h"]
-interface VRFieldOfView {
- readonly attribute double upDegrees;
- readonly attribute double rightDegrees;
- readonly attribute double downDegrees;
- readonly attribute double leftDegrees;
-};
-
-typedef (HTMLCanvasElement or OffscreenCanvas) VRSource;
-
-dictionary VRLayer {
- /**
- * XXX - When WebVR in WebWorkers is implemented, HTMLCanvasElement below
- * should be replaced with VRSource.
- */
- HTMLCanvasElement? source = null;
-
- /**
- * The left and right viewports contain 4 values defining the viewport
- * rectangles within the canvas to present to the eye in UV space.
- * [0] left offset of the viewport (0.0 - 1.0)
- * [1] top offset of the viewport (0.0 - 1.0)
- * [2] width of the viewport (0.0 - 1.0)
- * [3] height of the viewport (0.0 - 1.0)
- *
- * When no values are passed, they will be processed as though the left
- * and right sides of the viewport were passed:
- *
- * leftBounds: [0.0, 0.0, 0.5, 1.0]
- * rightBounds: [0.5, 0.0, 0.5, 1.0]
- */
- sequence<float> leftBounds = [];
- sequence<float> rightBounds = [];
-};
-
-/**
- * Values describing the capabilities of a VRDisplay.
- * These are expected to be static per-device/per-user.
- */
-[Pref="dom.vr.enabled",
- HeaderFile="mozilla/dom/VRDisplay.h"]
-interface VRDisplayCapabilities {
- /**
- * hasPosition is true if the VRDisplay is capable of tracking its position.
- */
- readonly attribute boolean hasPosition;
-
- /**
- * hasOrientation is true if the VRDisplay is capable of tracking its orientation.
- */
- readonly attribute boolean hasOrientation;
-
- /**
- * Whether the VRDisplay is separate from the device’s
- * primary display. If presenting VR content will obscure
- * other content on the device, this should be false. When
- * false, the application should not attempt to mirror VR content
- * or update non-VR UI because that content will not be visible.
- */
- readonly attribute boolean hasExternalDisplay;
-
- /**
- * Whether the VRDisplay is capable of presenting content to an HMD or similar device.
- * Can be used to indicate “magic window” devices that are capable of 6DoF tracking but for
- * which requestPresent is not meaningful. If false then calls to requestPresent should
- * always fail, and getEyeParameters should return null.
- */
- readonly attribute boolean canPresent;
-
- /**
- * Indicates the maximum length of the array that requestPresent() will accept. MUST be 1 if
- canPresent is true, 0 otherwise.
- */
- readonly attribute unsigned long maxLayers;
-};
-
-/**
- * Values describing the the stage / play area for devices
- * that support room-scale experiences.
- */
-[Pref="dom.vr.enabled",
- HeaderFile="mozilla/dom/VRDisplay.h"]
-interface VRStageParameters {
- /**
- * A 16-element array containing the components of a column-major 4x4
- * affine transform matrix. This matrix transforms the sitting-space position
- * returned by get{Immediate}Pose() to a standing-space position.
- */
- [Throws] readonly attribute Float32Array sittingToStandingTransform;
-
- /**
- * Dimensions of the play-area bounds. The bounds are defined
- * as an axis-aligned rectangle on the floor.
- * The center of the rectangle is at (0,0,0) in standing-space
- * coordinates.
- * These bounds are defined for safety purposes.
- * Content should not require the user to move beyond these
- * bounds; however, it is possible for the user to ignore
- * the bounds resulting in position values outside of
- * this rectangle.
- */
- readonly attribute float sizeX;
- readonly attribute float sizeZ;
-};
-
-[Pref="dom.vr.enabled",
- HeaderFile="mozilla/dom/VRDisplay.h"]
-interface VRPose
-{
- /**
- * position, linearVelocity, and linearAcceleration are 3-component vectors.
- * position is relative to a sitting space. Transforming this point with
- * VRStageParameters.sittingToStandingTransform converts this to standing space.
- */
- [Constant, Throws] readonly attribute Float32Array? position;
- [Constant, Throws] readonly attribute Float32Array? linearVelocity;
- [Constant, Throws] readonly attribute Float32Array? linearAcceleration;
-
- /* orientation is a 4-entry array representing the components of a quaternion. */
- [Constant, Throws] readonly attribute Float32Array? orientation;
- /* angularVelocity and angularAcceleration are the components of 3-dimensional vectors. */
- [Constant, Throws] readonly attribute Float32Array? angularVelocity;
- [Constant, Throws] readonly attribute Float32Array? angularAcceleration;
-};
-
-[Constructor,
- Pref="dom.vr.enabled",
- HeaderFile="mozilla/dom/VRDisplay.h"]
-interface VRFrameData {
- readonly attribute DOMHighResTimeStamp timestamp;
-
- [Throws, Pure] readonly attribute Float32Array leftProjectionMatrix;
- [Throws, Pure] readonly attribute Float32Array leftViewMatrix;
-
- [Throws, Pure] readonly attribute Float32Array rightProjectionMatrix;
- [Throws, Pure] readonly attribute Float32Array rightViewMatrix;
-
- [Pure] readonly attribute VRPose pose;
-};
-
-[Pref="dom.vr.enabled",
- HeaderFile="mozilla/dom/VRDisplay.h"]
-interface VREyeParameters {
- /**
- * offset is a 3-component vector representing an offset to
- * translate the eye. This value may vary from frame
- * to frame if the user adjusts their headset ipd.
- */
- [Constant, Throws] readonly attribute Float32Array offset;
-
- /* These values may vary as the user adjusts their headset ipd. */
- [Constant] readonly attribute VRFieldOfView fieldOfView;
-
- /**
- * renderWidth and renderHeight specify the recommended render target
- * size of each eye viewport, in pixels. If multiple eyes are rendered
- * in a single render target, then the render target should be made large
- * enough to fit both viewports.
- */
- [Constant] readonly attribute unsigned long renderWidth;
- [Constant] readonly attribute unsigned long renderHeight;
-};
-
-[Pref="dom.vr.enabled",
- HeaderFile="mozilla/dom/VRDisplay.h"]
-interface VRDisplay : EventTarget {
- readonly attribute boolean isConnected;
- readonly attribute boolean isPresenting;
-
- /**
- * Dictionary of capabilities describing the VRDisplay.
- */
- [Constant] readonly attribute VRDisplayCapabilities capabilities;
-
- /**
- * If this VRDisplay supports room-scale experiences, the optional
- * stage attribute contains details on the room-scale parameters.
- */
- readonly attribute VRStageParameters? stageParameters;
-
- /* Return the current VREyeParameters for the given eye. */
- VREyeParameters getEyeParameters(VREye whichEye);
-
- /**
- * An identifier for this distinct VRDisplay. Used as an
- * association point in the Gamepad API.
- */
- [Constant] readonly attribute unsigned long displayId;
-
- /**
- * A display name, a user-readable name identifying it.
- */
- [Constant] readonly attribute DOMString displayName;
-
- /**
- * Populates the passed VRFrameData with the information required to render
- * the current frame.
- */
- boolean getFrameData(VRFrameData frameData);
-
- /**
- * Return a VRPose containing the future predicted pose of the VRDisplay
- * when the current frame will be presented. Subsequent calls to getPose()
- * MUST return a VRPose with the same values until the next call to
- * submitFrame().
- *
- * The VRPose will contain the position, orientation, velocity,
- * and acceleration of each of these properties.
- */
- [NewObject] VRPose getPose();
-
- /**
- * Reset the pose for this display, treating its current position and
- * orientation as the "origin/zero" values. VRPose.position,
- * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
- * updated when calling resetPose(). This should be called in only
- * sitting-space experiences.
- */
- void resetPose();
-
- /**
- * z-depth defining the near plane of the eye view frustum
- * enables mapping of values in the render target depth
- * attachment to scene coordinates. Initially set to 0.01.
- */
- attribute double depthNear;
-
- /**
- * z-depth defining the far plane of the eye view frustum
- * enables mapping of values in the render target depth
- * attachment to scene coordinates. Initially set to 10000.0.
- */
- attribute double depthFar;
-
- /**
- * The callback passed to `requestAnimationFrame` will be called
- * any time a new frame should be rendered. When the VRDisplay is
- * presenting the callback will be called at the native refresh
- * rate of the HMD. When not presenting this function acts
- * identically to how window.requestAnimationFrame acts. Content should
- * make no assumptions of frame rate or vsync behavior as the HMD runs
- * asynchronously from other displays and at differing refresh rates.
- */
- [Throws] long requestAnimationFrame(FrameRequestCallback callback);
-
- /**
- * Passing the value returned by `requestAnimationFrame` to
- * `cancelAnimationFrame` will unregister the callback.
- */
- [Throws] void cancelAnimationFrame(long handle);
-
- /**
- * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
- * Repeat calls while already presenting will update the VRLayers being displayed.
- */
- [Throws] Promise<void> requestPresent(sequence<VRLayer> layers);
-
- /**
- * Stops presenting to the VRDisplay.
- */
- [Throws] Promise<void> exitPresent();
-
- /**
- * Get the layers currently being presented.
- */
- sequence<VRLayer> getLayers();
-
- /**
- * The VRLayer provided to the VRDisplay will be captured and presented
- * in the HMD. Calling this function has the same effect on the source
- * canvas as any other operation that uses its source image, and canvases
- * created without preserveDrawingBuffer set to true will be cleared.
- */
- void submitFrame();
-};
diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build
index 4c2567a1c..06fea2f20 100644
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -555,7 +555,6 @@ WEBIDL_FILES = [
'VideoStreamTrack.webidl',
'VideoTrack.webidl',
'VideoTrackList.webidl',
- 'VRDisplay.webidl',
'VTTCue.webidl',
'VTTRegion.webidl',
'WaveShaperNode.webidl',