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