Bug 1392216 - Part 4: Move drawing black layer commaneds to Compositor thread when stopping presentation; r=kip

MozReview-Commit-ID: 6YmQ9DYp79O

--HG--
extra : rebase_source : 45898a15fd2648db977647556d8cf120a67ff9d1
This commit is contained in:
Daosheng Mu 2017-10-16 13:30:46 +08:00
parent 9210bba13b
commit 820e14cb33
3 changed files with 26 additions and 3 deletions

View File

@ -352,7 +352,7 @@ VRDisplayHost::SubmitFrame(VRLayerParent* aLayer,
MessageLoop* loop = VRListenerThreadHolder::Loop();
loop->PostTask(NewRunnableMethod<const uint32_t>(
"gfx::VRLayerParent::SubmitFrame",
"gfx::VRManager::NotifyVRVsync",
vm, &VRManager::NotifyVRVsync, mDisplayInfo.mDisplayID
));
#endif

View File

@ -18,6 +18,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/gfx/DeviceManagerDx.h"
#include "mozilla/layers/CompositorThread.h"
#include "ipc/VRLayerParent.h"
#include "mozilla/gfx/Quaternion.h"
@ -198,6 +199,7 @@ VROculusSession::VROculusSession()
, mInitFlags((ovrInitFlags)0)
, mTextureSet(nullptr)
, mPresenting(false)
, mDrawBlack(false)
{
}
@ -321,8 +323,14 @@ VROculusSession::StopLib()
}
void
VROculusSession::Refresh()
VROculusSession::Refresh(bool aForceRefresh)
{
// We are waiting for drawing the black layer command for
// Compositor thread. Ignore Refresh() calls from other threads.
if (mDrawBlack && !aForceRefresh) {
return;
}
ovrInitFlags flags = (ovrInitFlags)(ovrInit_RequestVersion | ovrInit_MixedRendering);
bool bInvisible = true;
if (mPresenting) {
@ -340,11 +348,25 @@ VROculusSession::Refresh()
// While we are waiting for either the timeout or a new presentation,
// fill the HMD with black / no layers.
if (mSession && mTextureSet) {
if (!aForceRefresh) {
// ovr_SubmitFrame is only allowed been run at Compositor thread,
// so we post this task to Compositor thread and let it determine
// if reloading library.
mDrawBlack = true;
MessageLoop* loop = layers::CompositorThreadHolder::Loop();
loop->PostTask(NewRunnableMethod<bool>(
"gfx::VROculusSession::Refresh",
this,
&VROculusSession::Refresh, true));
return;
}
ovrLayerEyeFov layer;
memset(&layer, 0, sizeof(layer));
layer.Header.Type = ovrLayerType_Disabled;
ovrLayerHeader *layers = &layer.Header;
ovr_SubmitFrame(mSession, 0, nullptr, &layers, 1);
mDrawBlack = false;
}
}
}

View File

@ -40,7 +40,7 @@ class VROculusSession
friend class VRDisplayOculus;
public:
VROculusSession();
void Refresh();
void Refresh(bool aForceRefresh = false);
bool IsTrackingReady() const;
bool IsRenderReady() const;
ovrSession Get();
@ -65,6 +65,7 @@ private:
TimeStamp mLastPresentationEnd;
VRTelemetry mTelemetry;
bool mPresenting;
bool mDrawBlack;
~VROculusSession();
void Uninitialize(bool aUnloadLib);