Skip to content

Commit

Permalink
Bug 1406327 - Part 3: VRSystemManager for multi-threads; r=kip
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 4bE5hruFcT2

--HG--
extra : rebase_source : 3aa00d81127c90974f00571bd89174bd62a9d117
  • Loading branch information
daoshengmu committed Oct 26, 2017
1 parent 10a11e3 commit c32ea83
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions gfx/vr/VRDisplayHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#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)
Expand Down Expand Up @@ -257,6 +258,7 @@ 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;
Expand Down
3 changes: 2 additions & 1 deletion gfx/vr/gfxVROculus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,10 @@ 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;
Expand Down
2 changes: 1 addition & 1 deletion gfx/vr/gfxVROculus.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum class OculusControllerAxisType : uint16_t {

class VROculusSession
{
NS_INLINE_DECL_REFCOUNTING(VROculusSession);
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VROculusSession);
friend class VRDisplayOculus;
public:
VROculusSession();
Expand Down
7 changes: 7 additions & 0 deletions gfx/vr/gfxVROpenVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ 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,
Expand Down
14 changes: 3 additions & 11 deletions gfx/vr/gfxVRPuppet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -378,11 +378,7 @@ 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.
MessageLoop* loop = VRListenerThreadHolder::Loop();
loop->PostTask(NewRunnableMethod<const uint32_t, VRSubmitFrameResultInfo>(
"VRManager::DispatchSubmitFrameResult",
vm, &VRManager::DispatchSubmitFrameResult, mDisplayInfo.mDisplayID, result
));
vm->DispatchSubmitFrameResult(mDisplayInfo.mDisplayID, result);
break;
}
case 2:
Expand Down Expand Up @@ -523,11 +519,7 @@ 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.
MessageLoop* loop = VRListenerThreadHolder::Loop();
loop->PostTask(NewRunnableMethod<const uint32_t, VRSubmitFrameResultInfo>(
"VRManager::DispatchSubmitFrameResult",
vm, &VRManager::DispatchSubmitFrameResult, mDisplayInfo.mDisplayID, result
));
vm->DispatchSubmitFrameResult(mDisplayInfo.mDisplayID, result);
}
break;
}
Expand Down

0 comments on commit c32ea83

Please sign in to comment.