зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1406327) for bustage in tests that run after the VM tests
Backed out changeset 1784a194ced8 (bug 1406327) Backed out changeset 44cb5451bbde (bug 1406327) Backed out changeset e1e57d418c14 (bug 1406327) MozReview-Commit-ID: HUN1rEqAIWf
This commit is contained in:
Родитель
b95351167c
Коммит
1e756a27c8
|
@ -121,6 +121,8 @@ GPUParent::Init(base::ProcessId aParentPid,
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositorThreadHolder::Start();
|
CompositorThreadHolder::Start();
|
||||||
|
// TODO: Bug 1406327, Start VRListenerThreadHolder when loading VR content.
|
||||||
|
VRListenerThreadHolder::Start();
|
||||||
APZThreadUtils::SetControllerThread(CompositorThreadHolder::Loop());
|
APZThreadUtils::SetControllerThread(CompositorThreadHolder::Loop());
|
||||||
APZCTreeManager::InitializeGlobalState();
|
APZCTreeManager::InitializeGlobalState();
|
||||||
LayerTreeOwnerTracker::Initialize();
|
LayerTreeOwnerTracker::Initialize();
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "mozilla/gfx/Point.h" // for IntSize
|
#include "mozilla/gfx/Point.h" // for IntSize
|
||||||
#include "mozilla/gfx/Rect.h" // for IntSize
|
#include "mozilla/gfx/Rect.h" // for IntSize
|
||||||
#include "mozilla/gfx/gfxVars.h" // for gfxVars
|
#include "mozilla/gfx/gfxVars.h" // for gfxVars
|
||||||
|
#include "VRManager.h" // for VRManager
|
||||||
#include "mozilla/ipc/Transport.h" // for Transport
|
#include "mozilla/ipc/Transport.h" // for Transport
|
||||||
#include "mozilla/gfx/gfxVars.h"
|
#include "mozilla/gfx/gfxVars.h"
|
||||||
#include "mozilla/gfx/GPUParent.h"
|
#include "mozilla/gfx/GPUParent.h"
|
||||||
|
|
|
@ -133,37 +133,18 @@ CompositorVsyncScheduler::PostCompositeTask(TimeStamp aCompositeTimestamp)
|
||||||
mCurrentCompositeTask = task;
|
mCurrentCompositeTask = task;
|
||||||
ScheduleTask(task.forget(), 0);
|
ScheduleTask(task.forget(), 0);
|
||||||
}
|
}
|
||||||
if (mCurrentVRListenerTask == nullptr && VRListenerThreadHolder::IsActive()) {
|
if (mCurrentVRListenerTask == nullptr && VRListenerThreadHolder::Loop()) {
|
||||||
const TimeDuration timeout = TimeDuration::FromSeconds(45);
|
RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
|
||||||
VRManager* vm = VRManager::Get();
|
"layers::CompositorVsyncScheduler::DispatchVREvents",
|
||||||
TimeStamp activeTime(vm->GetLastVRListenerThreadActiveTime());
|
this,
|
||||||
|
&CompositorVsyncScheduler::DispatchVREvents,
|
||||||
// Shutdown VR listener thread when no VR content in 45 sec. Shutdown threads
|
aCompositeTimestamp);
|
||||||
// only allows to be run at the main thread.
|
mCurrentVRListenerTask = task;
|
||||||
if (!activeTime.IsNull() && ((aCompositeTimestamp - activeTime) > timeout)) {
|
MOZ_ASSERT(VRListenerThreadHolder::Loop());
|
||||||
RefPtr<Runnable> runnable = NewRunnableMethod(
|
VRListenerThreadHolder::Loop()->PostDelayedTask(Move(task.forget()), 0);
|
||||||
"layers::CompositorVsyncScheduler::ShutdownVRListenerThread",
|
|
||||||
this, &CompositorVsyncScheduler::ShutdownVRListenerThread);
|
|
||||||
NS_DispatchToMainThread(runnable.forget());
|
|
||||||
} else {
|
|
||||||
RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
|
|
||||||
"layers::CompositorVsyncScheduler::DispatchVREvents",
|
|
||||||
this,
|
|
||||||
&CompositorVsyncScheduler::DispatchVREvents,
|
|
||||||
aCompositeTimestamp);
|
|
||||||
mCurrentVRListenerTask = task;
|
|
||||||
MOZ_ASSERT(VRListenerThreadHolder::Loop());
|
|
||||||
VRListenerThreadHolder::Loop()->PostTask(Move(task.forget()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
CompositorVsyncScheduler::ShutdownVRListenerThread()
|
|
||||||
{
|
|
||||||
VRListenerThreadHolder::Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompositorVsyncScheduler::ScheduleComposition()
|
CompositorVsyncScheduler::ScheduleComposition()
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,7 +83,6 @@ private:
|
||||||
void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
|
void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
|
||||||
void DispatchVREvents(TimeStamp aVsyncTimestamp);
|
void DispatchVREvents(TimeStamp aVsyncTimestamp);
|
||||||
void CancelCurrentSetNeedsCompositeTask();
|
void CancelCurrentSetNeedsCompositeTask();
|
||||||
void ShutdownVRListenerThread();
|
|
||||||
|
|
||||||
class Observer final : public VsyncObserver
|
class Observer final : public VsyncObserver
|
||||||
{
|
{
|
||||||
|
|
|
@ -1044,6 +1044,7 @@ gfxPlatform::InitLayersIPC()
|
||||||
}
|
}
|
||||||
|
|
||||||
layers::CompositorThreadHolder::Start();
|
layers::CompositorThreadHolder::Start();
|
||||||
|
gfx::VRListenerThreadHolder::Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "ipc/VRLayerParent.h"
|
#include "ipc/VRLayerParent.h"
|
||||||
#include "mozilla/layers/TextureHost.h"
|
#include "mozilla/layers/TextureHost.h"
|
||||||
#include "mozilla/dom/GamepadBinding.h" // For GamepadMappingType
|
#include "mozilla/dom/GamepadBinding.h" // For GamepadMappingType
|
||||||
#include "mozilla/layers/CompositorThread.h"
|
|
||||||
#include "VRThread.h"
|
#include "VRThread.h"
|
||||||
|
|
||||||
#if defined(XP_WIN)
|
#if defined(XP_WIN)
|
||||||
|
@ -261,7 +260,6 @@ VRDisplayHost::SubmitFrame(VRLayerParent* aLayer,
|
||||||
{
|
{
|
||||||
AUTO_PROFILER_TRACING("VR", "SubmitFrameAtVRDisplayHost");
|
AUTO_PROFILER_TRACING("VR", "SubmitFrameAtVRDisplayHost");
|
||||||
|
|
||||||
MOZ_ASSERT(NS_IsInCompositorThread());
|
|
||||||
if ((mDisplayInfo.mGroupMask & aLayer->GetGroup()) == 0) {
|
if ((mDisplayInfo.mGroupMask & aLayer->GetGroup()) == 0) {
|
||||||
// Suppress layers hidden by the group mask
|
// Suppress layers hidden by the group mask
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -227,7 +227,6 @@ VRManager::NotifyVsync(const TimeStamp& aVsyncTimestamp)
|
||||||
if (bHaveEventListener || bHaveControllerListener) {
|
if (bHaveEventListener || bHaveControllerListener) {
|
||||||
// We are using a VR device, keep it alive
|
// We are using a VR device, keep it alive
|
||||||
mLastActiveTime = TimeStamp::Now();
|
mLastActiveTime = TimeStamp::Now();
|
||||||
mLastVRListenerThreadActiveTime = mLastActiveTime;
|
|
||||||
} else if (mLastActiveTime.IsNull()) {
|
} else if (mLastActiveTime.IsNull()) {
|
||||||
Shutdown();
|
Shutdown();
|
||||||
} else {
|
} else {
|
||||||
|
@ -260,7 +259,7 @@ void
|
||||||
VRManager::RefreshVRDisplays(bool aMustDispatch)
|
VRManager::RefreshVRDisplays(bool aMustDispatch)
|
||||||
{
|
{
|
||||||
nsTArray<RefPtr<gfx::VRDisplayHost> > displays;
|
nsTArray<RefPtr<gfx::VRDisplayHost> > displays;
|
||||||
mLastVRListenerThreadActiveTime = TimeStamp::Now();
|
|
||||||
/** We don't wish to enumerate the same display from multiple managers,
|
/** We don't wish to enumerate the same display from multiple managers,
|
||||||
* so stop as soon as we get a display.
|
* so stop as soon as we get a display.
|
||||||
* It is still possible to get multiple displays from a single manager,
|
* It is still possible to get multiple displays from a single manager,
|
||||||
|
@ -309,20 +308,13 @@ VRManager::RefreshVRDisplays(bool aMustDispatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayInfoChanged || displaySetChanged || aMustDispatch) {
|
if (displayInfoChanged || displaySetChanged || aMustDispatch) {
|
||||||
// Due to PVRManager is at Compositor thread. We have to post tasks
|
DispatchVRDisplayInfoUpdate();
|
||||||
// to Compositor thread when sending to them the content processes.
|
|
||||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
|
||||||
loop->PostTask(
|
|
||||||
NewRunnableMethod("gfx::VRManager::DispatchVRDisplayInfoUpdate",
|
|
||||||
this,
|
|
||||||
&VRManager::DispatchVRDisplayInfoUpdate));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VRManager::DispatchVRDisplayInfoUpdate()
|
VRManager::DispatchVRDisplayInfoUpdate()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsInCompositorThread());
|
|
||||||
nsTArray<VRDisplayInfo> update;
|
nsTArray<VRDisplayInfo> update;
|
||||||
GetVRDisplayInfo(update);
|
GetVRDisplayInfo(update);
|
||||||
|
|
||||||
|
@ -331,6 +323,7 @@ VRManager::DispatchVRDisplayInfoUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get any VR displays that have already been enumerated without
|
* Get any VR displays that have already been enumerated without
|
||||||
* activating any new devices.
|
* activating any new devices.
|
||||||
|
@ -375,12 +368,6 @@ VRManager::GetVRControllerInfo(nsTArray<VRControllerInfo>& aControllerInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeStamp
|
|
||||||
VRManager::GetLastVRListenerThreadActiveTime()
|
|
||||||
{
|
|
||||||
return mLastVRListenerThreadActiveTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VRManager::RefreshVRControllers()
|
VRManager::RefreshVRControllers()
|
||||||
{
|
{
|
||||||
|
@ -455,22 +442,8 @@ VRManager::NotifyGamepadChange(uint32_t aIndex, const T& aInfo)
|
||||||
dom::GamepadChangeEventBody body(aInfo);
|
dom::GamepadChangeEventBody body(aInfo);
|
||||||
dom::GamepadChangeEvent e(aIndex, dom::GamepadServiceType::VR, body);
|
dom::GamepadChangeEvent e(aIndex, dom::GamepadServiceType::VR, body);
|
||||||
|
|
||||||
// Due to PVRManager is at Compositor thread. We have to post
|
|
||||||
// tasks to Compositor thread.
|
|
||||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
|
||||||
loop->PostTask(
|
|
||||||
NewRunnableMethod<dom::GamepadChangeEvent>(
|
|
||||||
"gfx::VRManager::NotifyGamepadChangeEventsToContent",
|
|
||||||
this,
|
|
||||||
&VRManager::NotifyGamepadChangeEventsToContent, e));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
VRManager::NotifyGamepadChangeEventsToContent(const dom::GamepadChangeEvent& aEvent)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsInCompositorThread());
|
|
||||||
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
|
||||||
Unused << iter.Get()->GetKey()->SendGamepadUpdate(aEvent);
|
Unused << iter.Get()->GetKey()->SendGamepadUpdate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,20 +469,6 @@ VRManager::StopVibrateHaptic(uint32_t aControllerIdx)
|
||||||
void
|
void
|
||||||
VRManager::NotifyVibrateHapticCompleted(uint32_t aPromiseID)
|
VRManager::NotifyVibrateHapticCompleted(uint32_t aPromiseID)
|
||||||
{
|
{
|
||||||
// Due to PVRManager is at Compositor thread. We have to post
|
|
||||||
// tasks to Compositor thread.
|
|
||||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
|
||||||
loop->PostTask(
|
|
||||||
NewRunnableMethod<uint32_t>(
|
|
||||||
"gfx::VRManager::NotifyVibrateHapticCompletedToContent",
|
|
||||||
this,
|
|
||||||
&VRManager::NotifyVibrateHapticCompletedToContent, aPromiseID));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
VRManager::NotifyVibrateHapticCompletedToContent(uint32_t aPromiseID)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsInCompositorThread());
|
|
||||||
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
|
||||||
Unused << iter.Get()->GetKey()->SendReplyGamepadVibrateHaptic(aPromiseID);
|
Unused << iter.Get()->GetKey()->SendReplyGamepadVibrateHaptic(aPromiseID);
|
||||||
}
|
}
|
||||||
|
@ -518,7 +477,6 @@ VRManager::NotifyVibrateHapticCompletedToContent(uint32_t aPromiseID)
|
||||||
void
|
void
|
||||||
VRManager::DispatchSubmitFrameResult(uint32_t aDisplayID, const VRSubmitFrameResultInfo& aResult)
|
VRManager::DispatchSubmitFrameResult(uint32_t aDisplayID, const VRSubmitFrameResultInfo& aResult)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsInCompositorThread());
|
|
||||||
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
|
||||||
Unused << iter.Get()->GetKey()->SendDispatchSubmitFrameResult(aDisplayID, aResult);
|
Unused << iter.Get()->GetKey()->SendDispatchSubmitFrameResult(aDisplayID, aResult);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "gfxVR.h"
|
#include "gfxVR.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace layers {
|
||||||
class GamepadChangeEvent;
|
class TextureHost;
|
||||||
}
|
}
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ public:
|
||||||
void StopVibrateHaptic(uint32_t aControllerIdx);
|
void StopVibrateHaptic(uint32_t aControllerIdx);
|
||||||
void NotifyVibrateHapticCompleted(uint32_t aPromiseID);
|
void NotifyVibrateHapticCompleted(uint32_t aPromiseID);
|
||||||
void DispatchSubmitFrameResult(uint32_t aDisplayID, const VRSubmitFrameResultInfo& aResult);
|
void DispatchSubmitFrameResult(uint32_t aDisplayID, const VRSubmitFrameResultInfo& aResult);
|
||||||
TimeStamp GetLastVRListenerThreadActiveTime();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
VRManager();
|
VRManager();
|
||||||
|
@ -65,8 +64,6 @@ private:
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void DispatchVRDisplayInfoUpdate();
|
void DispatchVRDisplayInfoUpdate();
|
||||||
void NotifyGamepadChangeEventsToContent(const dom::GamepadChangeEvent& aEvent);
|
|
||||||
void NotifyVibrateHapticCompletedToContent(uint32_t aPromiseID);
|
|
||||||
|
|
||||||
typedef nsTHashtable<nsRefPtrHashKey<VRManagerParent>> VRManagerParentSet;
|
typedef nsTHashtable<nsRefPtrHashKey<VRManagerParent>> VRManagerParentSet;
|
||||||
VRManagerParentSet mVRManagerParents;
|
VRManagerParentSet mVRManagerParents;
|
||||||
|
@ -84,7 +81,6 @@ private:
|
||||||
|
|
||||||
TimeStamp mLastRefreshTime;
|
TimeStamp mLastRefreshTime;
|
||||||
TimeStamp mLastActiveTime;
|
TimeStamp mLastActiveTime;
|
||||||
TimeStamp mLastVRListenerThreadActiveTime;
|
|
||||||
bool mVRTestSystemCreated;
|
bool mVRTestSystemCreated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace mozilla {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
|
||||||
static StaticRefPtr<VRListenerThreadHolder> sVRListenerThreadHolder;
|
static StaticRefPtr<VRListenerThreadHolder> sVRListenerThreadHolder;
|
||||||
static TimeStamp sStartTime;
|
|
||||||
static bool sFinishedVRListenerShutDown = false;
|
static bool sFinishedVRListenerShutDown = false;
|
||||||
|
|
||||||
VRListenerThreadHolder* GetVRListenerThreadHolder()
|
VRListenerThreadHolder* GetVRListenerThreadHolder()
|
||||||
|
@ -95,22 +94,11 @@ VRListenerThreadHolder::Start()
|
||||||
MOZ_ASSERT(!sVRListenerThreadHolder, "The VR listener thread has already been started!");
|
MOZ_ASSERT(!sVRListenerThreadHolder, "The VR listener thread has already been started!");
|
||||||
|
|
||||||
sVRListenerThreadHolder = new VRListenerThreadHolder();
|
sVRListenerThreadHolder = new VRListenerThreadHolder();
|
||||||
sStartTime = TimeStamp::Now();
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeStamp
|
|
||||||
VRListenerThreadHolder::GetStartTime()
|
|
||||||
{
|
|
||||||
return sStartTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VRListenerThreadHolder::Shutdown()
|
VRListenerThreadHolder::Shutdown()
|
||||||
{
|
{
|
||||||
if (!IsActive()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(NS_IsMainThread(), "Should be on the main thread!");
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on the main thread!");
|
||||||
MOZ_ASSERT(sVRListenerThreadHolder, "The VR listener thread has already been shut down!");
|
MOZ_ASSERT(sVRListenerThreadHolder, "The VR listener thread has already been shut down!");
|
||||||
|
|
||||||
|
@ -123,7 +111,7 @@ VRListenerThreadHolder::Shutdown()
|
||||||
VRListenerThreadHolder::IsInVRListenerThread()
|
VRListenerThreadHolder::IsInVRListenerThread()
|
||||||
{
|
{
|
||||||
return VRListenerThread() &&
|
return VRListenerThread() &&
|
||||||
VRListenerThread()->thread_id() == PlatformThread::CurrentId();
|
VRListenerThread()->thread_id() == PlatformThread::CurrentId();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -27,22 +27,21 @@ public:
|
||||||
static VRListenerThreadHolder* GetSingleton();
|
static VRListenerThreadHolder* GetSingleton();
|
||||||
|
|
||||||
static bool IsActive() {
|
static bool IsActive() {
|
||||||
return !!GetSingleton() && !!Loop();
|
return !!GetSingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Start();
|
static void Start();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static MessageLoop* Loop();
|
static MessageLoop* Loop();
|
||||||
static bool IsInVRListenerThread();
|
static bool IsInVRListenerThread();
|
||||||
static TimeStamp GetStartTime();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~VRListenerThreadHolder();
|
~VRListenerThreadHolder();
|
||||||
|
|
||||||
|
base::Thread* const mThread;
|
||||||
|
|
||||||
static base::Thread* CreateThread();
|
static base::Thread* CreateThread();
|
||||||
static void DestroyThread(base::Thread* aThread);
|
static void DestroyThread(base::Thread* aThread);
|
||||||
|
|
||||||
base::Thread* const mThread;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
base::Thread* VRListenerThread();
|
base::Thread* VRListenerThread();
|
||||||
|
|
|
@ -364,10 +364,9 @@ VROculusSession::Refresh(bool aForceRefresh)
|
||||||
"gfx::VROculusSession::Refresh",
|
"gfx::VROculusSession::Refresh",
|
||||||
this,
|
this,
|
||||||
&VROculusSession::Refresh, true));
|
&VROculusSession::Refresh, true));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Calling ovr_SubmitFrame() must be at Compositor thread.
|
|
||||||
MOZ_ASSERT(NS_IsInCompositorThread());
|
|
||||||
ovrLayerEyeFov layer;
|
ovrLayerEyeFov layer;
|
||||||
memset(&layer, 0, sizeof(layer));
|
memset(&layer, 0, sizeof(layer));
|
||||||
layer.Header.Type = ovrLayerType_Disabled;
|
layer.Header.Type = ovrLayerType_Disabled;
|
||||||
|
|
|
@ -37,7 +37,7 @@ enum class OculusControllerAxisType : uint16_t {
|
||||||
|
|
||||||
class VROculusSession
|
class VROculusSession
|
||||||
{
|
{
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VROculusSession);
|
NS_INLINE_DECL_REFCOUNTING(VROculusSession);
|
||||||
friend class VRDisplayOculus;
|
friend class VRDisplayOculus;
|
||||||
public:
|
public:
|
||||||
VROculusSession();
|
VROculusSession();
|
||||||
|
|
|
@ -636,13 +636,6 @@ VRSystemManagerOpenVR::Shutdown()
|
||||||
bool
|
bool
|
||||||
VRSystemManagerOpenVR::GetHMDs(nsTArray<RefPtr<VRDisplayHost>>& aHMDResult)
|
VRSystemManagerOpenVR::GetHMDs(nsTArray<RefPtr<VRDisplayHost>>& aHMDResult)
|
||||||
{
|
{
|
||||||
// When running VR tests on local machines which have SteamVR runtime.
|
|
||||||
// VR_IsHmdPresent() would have chance to be true. Then, it makes us can't
|
|
||||||
// get the VRPuppet display.
|
|
||||||
if (gfxPrefs::VRPuppetEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!::vr::VR_IsHmdPresent() ||
|
if (!::vr::VR_IsHmdPresent() ||
|
||||||
(mOpenVRHMD && !mOpenVRHMD->GetIsHmdPresent())) {
|
(mOpenVRHMD && !mOpenVRHMD->GetIsHmdPresent())) {
|
||||||
// OpenVR runtime could be quit accidentally,
|
// OpenVR runtime could be quit accidentally,
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
#include "mozilla/Base64.h"
|
#include "mozilla/Base64.h"
|
||||||
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
||||||
#include "mozilla/layers/CompositorThread.h"
|
|
||||||
#include "gfxPrefs.h"
|
#include "gfxPrefs.h"
|
||||||
#include "gfxUtils.h"
|
#include "gfxUtils.h"
|
||||||
#include "gfxVRPuppet.h"
|
#include "gfxVRPuppet.h"
|
||||||
#include "VRManager.h"
|
#include "VRManager.h"
|
||||||
|
#include "VRThread.h"
|
||||||
|
|
||||||
#include "mozilla/dom/GamepadEventTypes.h"
|
#include "mozilla/dom/GamepadEventTypes.h"
|
||||||
#include "mozilla/dom/GamepadBinding.h"
|
#include "mozilla/dom/GamepadBinding.h"
|
||||||
|
@ -387,7 +387,11 @@ VRDisplayPuppet::SubmitFrame(ID3D11Texture2D* aSource,
|
||||||
mContext->Unmap(mappedTexture, 0);
|
mContext->Unmap(mappedTexture, 0);
|
||||||
// Dispatch the base64 encoded string to the DOM side. Then, it will be decoded
|
// Dispatch the base64 encoded string to the DOM side. Then, it will be decoded
|
||||||
// and convert to a PNG image there.
|
// and convert to a PNG image there.
|
||||||
vm->DispatchSubmitFrameResult(mDisplayInfo.mDisplayID, result);
|
MessageLoop* loop = VRListenerThreadHolder::Loop();
|
||||||
|
loop->PostTask(NewRunnableMethod<const uint32_t, VRSubmitFrameResultInfo>(
|
||||||
|
"VRManager::DispatchSubmitFrameResult",
|
||||||
|
vm, &VRManager::DispatchSubmitFrameResult, mDisplayInfo.mDisplayID, result
|
||||||
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -528,7 +532,11 @@ VRDisplayPuppet::SubmitFrame(MacIOSurface* aMacIOSurface,
|
||||||
}
|
}
|
||||||
// Dispatch the base64 encoded string to the DOM side. Then, it will be decoded
|
// Dispatch the base64 encoded string to the DOM side. Then, it will be decoded
|
||||||
// and convert to a PNG image there.
|
// and convert to a PNG image there.
|
||||||
vm->DispatchSubmitFrameResult(mDisplayInfo.mDisplayID, result);
|
MessageLoop* loop = VRListenerThreadHolder::Loop();
|
||||||
|
loop->PostTask(NewRunnableMethod<const uint32_t, VRSubmitFrameResultInfo>(
|
||||||
|
"VRManager::DispatchSubmitFrameResult",
|
||||||
|
vm, &VRManager::DispatchSubmitFrameResult, mDisplayInfo.mDisplayID, result
|
||||||
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "VRLayerParent.h"
|
#include "VRLayerParent.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
#include "VRDisplayHost.h"
|
#include "VRDisplayHost.h"
|
||||||
|
#include "mozilla/layers/CompositorThread.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
using namespace layers;
|
using namespace layers;
|
||||||
|
@ -64,11 +65,18 @@ VRLayerParent::RecvSubmitFrame(const layers::SurfaceDescriptor &aTexture,
|
||||||
const gfx::Rect& aRightEyeRect)
|
const gfx::Rect& aRightEyeRect)
|
||||||
{
|
{
|
||||||
if (mVRDisplayID) {
|
if (mVRDisplayID) {
|
||||||
|
MessageLoop* loop = layers::CompositorThreadHolder::Loop();
|
||||||
VRManager* vm = VRManager::Get();
|
VRManager* vm = VRManager::Get();
|
||||||
RefPtr<VRDisplayHost> display = vm->GetDisplay(mVRDisplayID);
|
RefPtr<VRDisplayHost> display = vm->GetDisplay(mVRDisplayID);
|
||||||
if (display) {
|
if (display) {
|
||||||
// TODO: Move SubmitFrame to VRSubmitFrame thread in Bug 1392217.
|
// Because VR compositor still shares the same graphics device with Compositor thread.
|
||||||
SubmitFrame(display, aTexture, aFrameId, aLeftEyeRect, aRightEyeRect);
|
// We have to post sumbit frame tasks to Compositor thread.
|
||||||
|
// TODO: Move SubmitFrame to Bug 1392217.
|
||||||
|
loop->PostTask(NewRunnableMethod<VRDisplayHost*, const layers::SurfaceDescriptor, uint64_t,
|
||||||
|
const gfx::Rect&, const gfx::Rect&>(
|
||||||
|
"gfx::VRLayerParent::SubmitFrame",
|
||||||
|
this,
|
||||||
|
&VRLayerParent::SubmitFrame, display, aTexture, aFrameId, aLeftEyeRect, aRightEyeRect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ VRManagerChild::InitSameProcess()
|
||||||
sVRManagerChildSingleton = new VRManagerChild();
|
sVRManagerChildSingleton = new VRManagerChild();
|
||||||
sVRManagerParentSingleton = VRManagerParent::CreateSameProcess();
|
sVRManagerParentSingleton = VRManagerParent::CreateSameProcess();
|
||||||
sVRManagerChildSingleton->Open(sVRManagerParentSingleton->GetIPCChannel(),
|
sVRManagerChildSingleton->Open(sVRManagerParentSingleton->GetIPCChannel(),
|
||||||
mozilla::layers::CompositorThreadHolder::Loop(),
|
VRListenerThreadHolder::Loop(),
|
||||||
mozilla::ipc::ChildSide);
|
mozilla::ipc::ChildSide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,13 +86,15 @@ VRManagerParent::UnregisterFromManager()
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint)
|
VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint)
|
||||||
{
|
{
|
||||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
MessageLoop* loop = VRListenerThreadHolder::Loop();
|
||||||
|
|
||||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), true);
|
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), true);
|
||||||
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||||
"gfx::VRManagerParent::Bind",
|
"gfx::VRManagerParent::Bind",
|
||||||
vmp,
|
vmp,
|
||||||
&VRManagerParent::Bind,
|
&VRManagerParent::Bind,
|
||||||
Move(aEndpoint)));
|
Move(aEndpoint)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +110,7 @@ VRManagerParent::Bind(Endpoint<PVRManagerParent>&& aEndpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
VRManagerParent::RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager)
|
VRManagerParent::RegisterVRManagerInVRListenerThread(VRManagerParent* aVRManager)
|
||||||
{
|
{
|
||||||
aVRManager->RegisterWithManager();
|
aVRManager->RegisterWithManager();
|
||||||
}
|
}
|
||||||
|
@ -116,21 +118,21 @@ VRManagerParent::RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager
|
||||||
/*static*/ VRManagerParent*
|
/*static*/ VRManagerParent*
|
||||||
VRManagerParent::CreateSameProcess()
|
VRManagerParent::CreateSameProcess()
|
||||||
{
|
{
|
||||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
MessageLoop* loop = VRListenerThreadHolder::Loop();
|
||||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(base::GetCurrentProcId(), false);
|
RefPtr<VRManagerParent> vmp = new VRManagerParent(base::GetCurrentProcId(), false);
|
||||||
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
vmp->mVRListenerThreadHolder = VRListenerThreadHolder::GetSingleton();
|
||||||
vmp->mSelfRef = vmp;
|
vmp->mSelfRef = vmp;
|
||||||
loop->PostTask(NewRunnableFunction(RegisterVRManagerInCompositorThread, vmp.get()));
|
loop->PostTask(NewRunnableFunction(RegisterVRManagerInVRListenerThread, vmp.get()));
|
||||||
return vmp.get();
|
return vmp.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VRManagerParent::CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint)
|
VRManagerParent::CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint)
|
||||||
{
|
{
|
||||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
MessageLoop* loop = VRListenerThreadHolder::Loop();
|
||||||
|
|
||||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), false);
|
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), false);
|
||||||
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
vmp->mVRListenerThreadHolder = VRListenerThreadHolder::GetSingleton();
|
||||||
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||||
"gfx::VRManagerParent::Bind",
|
"gfx::VRManagerParent::Bind",
|
||||||
vmp,
|
vmp,
|
||||||
|
@ -142,25 +144,10 @@ VRManagerParent::CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint)
|
||||||
void
|
void
|
||||||
VRManagerParent::DeferredDestroy()
|
VRManagerParent::DeferredDestroy()
|
||||||
{
|
{
|
||||||
mCompositorThreadHolder = nullptr;
|
mVRListenerThreadHolder = nullptr;
|
||||||
mSelfRef = nullptr;
|
mSelfRef = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
VRManagerParent::RefreshDisplays()
|
|
||||||
{
|
|
||||||
// This is called to refresh the VR Displays for Navigator.GetVRDevices().
|
|
||||||
// We must pass "true" to VRManager::RefreshVRDisplays()
|
|
||||||
// to ensure that the promise returned by Navigator.GetVRDevices
|
|
||||||
// can resolve even if there are no changes to the VR Displays.
|
|
||||||
VRManager* vm = VRManager::Get();
|
|
||||||
MessageLoop* loop = VRListenerThreadHolder::Loop();
|
|
||||||
loop->PostTask(
|
|
||||||
NewRunnableMethod<bool>(
|
|
||||||
"gfx::VRManager::RefreshVRDisplays",
|
|
||||||
vm, &VRManager::RefreshVRDisplays, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VRManagerParent::ActorDestroy(ActorDestroyReason why)
|
VRManagerParent::ActorDestroy(ActorDestroyReason why)
|
||||||
{
|
{
|
||||||
|
@ -174,25 +161,21 @@ VRManagerParent::ActorDestroy(ActorDestroyReason why)
|
||||||
void
|
void
|
||||||
VRManagerParent::OnChannelConnected(int32_t aPid)
|
VRManagerParent::OnChannelConnected(int32_t aPid)
|
||||||
{
|
{
|
||||||
mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
mVRListenerThreadHolder = VRListenerThreadHolder::GetSingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult
|
mozilla::ipc::IPCResult
|
||||||
VRManagerParent::RecvRefreshDisplays()
|
VRManagerParent::RecvRefreshDisplays()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsInCompositorThread());
|
// TODO: Bug 1406327, Launch VR listener thread here.
|
||||||
|
MOZ_ASSERT(VRListenerThreadHolder::IsInVRListenerThread());
|
||||||
|
|
||||||
// When receiving refresh display messages at the first time,
|
// This is called to refresh the VR Displays for Navigator.GetVRDevices().
|
||||||
// it is time to start the VR listener thread.
|
// We must pass "true" to VRManager::RefreshVRDisplays()
|
||||||
// Spawning threads needs to be at the main thread.
|
// to ensure that the promise returned by Navigator.GetVRDevices
|
||||||
if (!VRListenerThreadHolder::IsActive()) {
|
// can resolve even if there are no changes to the VR Displays.
|
||||||
RefPtr<Runnable> runnable = NewRunnableMethod(
|
VRManager* vm = VRManager::Get();
|
||||||
"gfx::VRManagerParent::StartVRListenerThread",
|
vm->RefreshVRDisplays(true);
|
||||||
this, &VRManagerParent::StartVRListenerThread);
|
|
||||||
NS_DispatchToMainThread(runnable.forget());
|
|
||||||
} else {
|
|
||||||
RefreshDisplays();
|
|
||||||
}
|
|
||||||
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
@ -220,13 +203,6 @@ VRManagerParent::RecvSetGroupMask(const uint32_t& aDisplayID, const uint32_t& aG
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
VRManagerParent::StartVRListenerThread()
|
|
||||||
{
|
|
||||||
VRListenerThreadHolder::Start();
|
|
||||||
RefreshDisplays();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VRManagerParent::HaveEventListener()
|
VRManagerParent::HaveEventListener()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
#ifndef MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
||||||
#define MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
#define MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
||||||
|
|
||||||
#include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder
|
#include "mozilla/layers/CompositableTransactionParent.h" // need?
|
||||||
#include "mozilla/gfx/PVRManagerParent.h" // for PVRManagerParent
|
#include "mozilla/gfx/PVRManagerParent.h" // for PVRManagerParent
|
||||||
#include "mozilla/gfx/PVRLayerParent.h" // for PVRLayerParent
|
#include "mozilla/gfx/PVRLayerParent.h" // for PVRLayerParent
|
||||||
#include "mozilla/ipc/ProtocolUtils.h" // for IToplevelProtocol
|
#include "mozilla/ipc/ProtocolUtils.h" // for IToplevelProtocol
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
#include "VRThread.h" // for VRListenerThreadHolder
|
#include "VRThread.h" // for VRListenerThreadHolder
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
using namespace layers;
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
|
||||||
class VRManager;
|
class VRManager;
|
||||||
|
@ -40,7 +41,6 @@ public:
|
||||||
bool HaveControllerListener();
|
bool HaveControllerListener();
|
||||||
bool SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent);
|
bool SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent);
|
||||||
bool SendReplyGamepadVibrateHaptic(const uint32_t& aPromiseID);
|
bool SendReplyGamepadVibrateHaptic(const uint32_t& aPromiseID);
|
||||||
void StartVRListenerThread();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~VRManagerParent();
|
~VRManagerParent();
|
||||||
|
@ -80,17 +80,14 @@ private:
|
||||||
|
|
||||||
void Bind(Endpoint<PVRManagerParent>&& aEndpoint);
|
void Bind(Endpoint<PVRManagerParent>&& aEndpoint);
|
||||||
|
|
||||||
static void RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager);
|
static void RegisterVRManagerInVRListenerThread(VRManagerParent* aVRManager);
|
||||||
|
|
||||||
void DeferredDestroy();
|
void DeferredDestroy();
|
||||||
void RefreshDisplays();
|
|
||||||
|
|
||||||
// This keeps us alive until ActorDestroy(), at which point we do a
|
// This keeps us alive until ActorDestroy(), at which point we do a
|
||||||
// deferred destruction of ourselves.
|
// deferred destruction of ourselves.
|
||||||
RefPtr<VRManagerParent> mSelfRef;
|
RefPtr<VRManagerParent> mSelfRef;
|
||||||
|
RefPtr<VRListenerThreadHolder> mVRListenerThreadHolder;
|
||||||
// Keep the compositor thread alive, until we have destroyed ourselves.
|
|
||||||
RefPtr<layers::CompositorThreadHolder> mCompositorThreadHolder;
|
|
||||||
|
|
||||||
// Keep the VRManager alive, until we have destroyed ourselves.
|
// Keep the VRManager alive, until we have destroyed ourselves.
|
||||||
RefPtr<VRManager> mVRManagerHolder;
|
RefPtr<VRManager> mVRManagerHolder;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче