Merge mozilla-central to mozilla-autoland. r=merge a=merge on a CLOSED TREE

This commit is contained in:
Coroiu Cristina 2017-10-30 15:00:45 +02:00
Родитель 12e0c4a11e 9ca76dcb7a
Коммит 362301f0de
18 изменённых файлов: 70 добавлений и 166 удалений

Просмотреть файл

@ -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,19 +133,7 @@ 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 {
if (mCurrentVRListenerTask == nullptr && VRListenerThreadHolder::Loop()) {
RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
"layers::CompositorVsyncScheduler::DispatchVREvents",
this,
@ -153,15 +141,8 @@ CompositorVsyncScheduler::PostCompositeTask(TimeStamp aCompositeTimestamp)
aCompositeTimestamp);
mCurrentVRListenerTask = task;
MOZ_ASSERT(VRListenerThreadHolder::Loop());
VRListenerThreadHolder::Loop()->PostTask(Move(task.forget()));
VRListenerThreadHolder::Loop()->PostDelayedTask(Move(task.forget()), 0);
}
}
}
void
CompositorVsyncScheduler::ShutdownVRListenerThread()
{
VRListenerThreadHolder::Shutdown();
}
void

Просмотреть файл

@ -83,7 +83,6 @@ private:
void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
void DispatchVREvents(TimeStamp aVsyncTimestamp);
void CancelCurrentSetNeedsCompositeTask();
void ShutdownVRListenerThread();
class Observer final : public VsyncObserver
{

Просмотреть файл

@ -1042,6 +1042,7 @@ gfxPlatform::InitLayersIPC()
}
layers::CompositorThreadHolder::Start();
gfx::VRListenerThreadHolder::Start();
}
}

Просмотреть файл

@ -9,7 +9,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)
@ -258,7 +257,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;

Просмотреть файл

@ -226,7 +226,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 {
@ -259,7 +258,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,
@ -308,20 +307,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);
@ -330,6 +322,7 @@ VRManager::DispatchVRDisplayInfoUpdate()
}
}
/**
* Get any VR displays that have already been enumerated without
* activating any new devices.
@ -374,12 +367,6 @@ VRManager::GetVRControllerInfo(nsTArray<VRControllerInfo>& aControllerInfo)
}
}
TimeStamp
VRManager::GetLastVRListenerThreadActiveTime()
{
return mLastVRListenerThreadActiveTime;
}
void
VRManager::RefreshVRControllers()
{
@ -454,22 +441,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);
}
}
@ -495,20 +468,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);
}
@ -517,7 +476,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);
}

Просмотреть файл

@ -14,8 +14,8 @@
#include "gfxVR.h"
namespace mozilla {
namespace dom {
class GamepadChangeEvent;
namespace layers {
class TextureHost;
}
namespace gfx {
@ -51,7 +51,6 @@ public:
void StopVibrateHaptic(uint32_t aControllerIdx);
void NotifyVibrateHapticCompleted(uint32_t aPromiseID);
void DispatchSubmitFrameResult(uint32_t aDisplayID, const VRSubmitFrameResultInfo& aResult);
TimeStamp GetLastVRListenerThreadActiveTime();
protected:
VRManager();
@ -64,8 +63,6 @@ private:
void Shutdown();
void DispatchVRDisplayInfoUpdate();
void NotifyGamepadChangeEventsToContent(const dom::GamepadChangeEvent& aEvent);
void NotifyVibrateHapticCompletedToContent(uint32_t aPromiseID);
typedef nsTHashtable<nsRefPtrHashKey<VRManagerParent>> VRManagerParentSet;
VRManagerParentSet mVRManagerParents;
@ -83,7 +80,6 @@ private:
TimeStamp mLastRefreshTime;
TimeStamp mLastActiveTime;
TimeStamp mLastVRListenerThreadActiveTime;
bool mVRTestSystemCreated;
};

Просмотреть файл

@ -12,7 +12,6 @@ namespace mozilla {
namespace gfx {
static StaticRefPtr<VRListenerThreadHolder> sVRListenerThreadHolder;
static TimeStamp sStartTime;
static bool sFinishedVRListenerShutDown = false;
VRListenerThreadHolder* GetVRListenerThreadHolder()
@ -94,22 +93,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!");

Просмотреть файл

@ -26,22 +26,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();

Просмотреть файл

@ -358,10 +358,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;

Просмотреть файл

@ -36,7 +36,7 @@ enum class OculusControllerAxisType : uint16_t {
class VROculusSession
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VROculusSession);
NS_INLINE_DECL_REFCOUNTING(VROculusSession);
friend class VRDisplayOculus;
public:
VROculusSession();

Просмотреть файл

@ -610,13 +610,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,

Просмотреть файл

@ -13,11 +13,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"
@ -378,7 +378,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:
@ -519,7 +523,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;
}

Просмотреть файл

@ -7,6 +7,7 @@
#include "VRLayerParent.h"
#include "mozilla/Unused.h"
#include "VRDisplayHost.h"
#include "mozilla/layers/CompositorThread.h"
namespace mozilla {
using namespace layers;
@ -63,11 +64,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));
}
}

Просмотреть файл

@ -120,7 +120,7 @@ VRManagerChild::InitSameProcess()
sVRManagerChildSingleton = new VRManagerChild();
sVRManagerParentSingleton = VRManagerParent::CreateSameProcess();
sVRManagerChildSingleton->Open(sVRManagerParentSingleton->GetIPCChannel(),
mozilla::layers::CompositorThreadHolder::Loop(),
VRListenerThreadHolder::Loop(),
mozilla::ipc::ChildSide);
}

Просмотреть файл

@ -87,13 +87,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;
}
@ -109,7 +111,7 @@ VRManagerParent::Bind(Endpoint<PVRManagerParent>&& aEndpoint)
}
/*static*/ void
VRManagerParent::RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager)
VRManagerParent::RegisterVRManagerInVRListenerThread(VRManagerParent* aVRManager)
{
aVRManager->RegisterWithManager();
}
@ -117,21 +119,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,
@ -143,25 +145,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)
{
@ -175,25 +162,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();
}
@ -221,13 +204,6 @@ VRManagerParent::RecvSetGroupMask(const uint32_t& aDisplayID, const uint32_t& aG
return IPC_OK();
}
void
VRManagerParent::StartVRListenerThread()
{
VRListenerThreadHolder::Start();
RefreshDisplays();
}
bool
VRManagerParent::HaveEventListener()
{

Просмотреть файл

@ -8,7 +8,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
@ -17,6 +17,7 @@
#include "VRThread.h" // for VRListenerThreadHolder
namespace mozilla {
using namespace layers;
namespace gfx {
class VRManager;
@ -41,7 +42,6 @@ public:
bool HaveControllerListener();
bool SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent);
bool SendReplyGamepadVibrateHaptic(const uint32_t& aPromiseID);
void StartVRListenerThread();
protected:
~VRManagerParent();
@ -81,17 +81,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;