2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2017-10-28 01:55:37 +03:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2016-02-25 02:54:50 +03:00
|
|
|
|
|
|
|
#include "VRDisplayHost.h"
|
2017-10-06 12:56:53 +03:00
|
|
|
#include "gfxPrefs.h"
|
2016-02-25 02:54:50 +03:00
|
|
|
#include "gfxVR.h"
|
2017-05-09 02:01:36 +03:00
|
|
|
#include "ipc/VRLayerParent.h"
|
2018-10-03 00:17:05 +03:00
|
|
|
#include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder
|
2017-07-04 23:50:40 +03:00
|
|
|
#include "mozilla/layers/TextureHost.h"
|
|
|
|
#include "mozilla/dom/GamepadBinding.h" // For GamepadMappingType
|
2017-10-05 13:16:16 +03:00
|
|
|
#include "VRThread.h"
|
2016-02-25 02:54:50 +03:00
|
|
|
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
|
|
|
|
#include <d3d11.h>
|
|
|
|
#include "gfxWindowsPlatform.h"
|
|
|
|
#include "../layers/d3d11/CompositorD3D11.h"
|
2017-09-19 02:19:49 +03:00
|
|
|
#include "mozilla/gfx/DeviceManagerDx.h"
|
2016-02-25 02:54:50 +03:00
|
|
|
#include "mozilla/layers/TextureD3D11.h"
|
|
|
|
|
2017-07-04 23:50:40 +03:00
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
|
|
|
|
#include "mozilla/gfx/MacIOSurface.h"
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
#endif
|
|
|
|
|
2018-06-05 01:45:04 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2017-12-19 04:40:47 +03:00
|
|
|
#include "mozilla/layers/CompositorThread.h"
|
2018-08-24 18:32:12 +03:00
|
|
|
// Max frame duration on Android before the watchdog submits a new one.
|
|
|
|
// Probably we can get rid of this when we enforce that SubmitFrame can only be
|
|
|
|
// called in a VRDisplay loop.
|
|
|
|
#define ANDROID_MAX_FRAME_DURATION 4000
|
2018-06-05 01:45:04 +03:00
|
|
|
#endif // defined(MOZ_WIDGET_ANDROID)
|
2017-12-19 04:40:47 +03:00
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
2017-09-19 02:19:49 +03:00
|
|
|
VRDisplayHost::AutoRestoreRenderState::AutoRestoreRenderState(
|
|
|
|
VRDisplayHost* aDisplay)
|
|
|
|
: mDisplay(aDisplay), mSuccess(true) {
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
ID3D11DeviceContext1* context = mDisplay->GetD3DDeviceContext();
|
|
|
|
ID3DDeviceContextState* state = mDisplay->GetD3DDeviceContextState();
|
|
|
|
if (!context || !state) {
|
|
|
|
mSuccess = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
context->SwapDeviceContextState(state,
|
|
|
|
getter_AddRefs(mPrevDeviceContextState));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
VRDisplayHost::AutoRestoreRenderState::~AutoRestoreRenderState() {
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
ID3D11DeviceContext1* context = mDisplay->GetD3DDeviceContext();
|
|
|
|
if (context && mSuccess) {
|
|
|
|
context->SwapDeviceContextState(mPrevDeviceContextState, nullptr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VRDisplayHost::AutoRestoreRenderState::IsSuccess() { return mSuccess; }
|
|
|
|
|
2016-10-04 11:22:42 +03:00
|
|
|
VRDisplayHost::VRDisplayHost(VRDeviceType aType)
|
2017-10-30 15:51:32 +03:00
|
|
|
: mDisplayInfo{}, mLastUpdateDisplayInfo{}, mFrameStarted(false) {
|
2016-02-25 02:54:50 +03:00
|
|
|
MOZ_COUNT_CTOR(VRDisplayHost);
|
|
|
|
mDisplayInfo.mType = aType;
|
2017-01-24 12:49:11 +03:00
|
|
|
mDisplayInfo.mDisplayID = VRSystemManager::AllocateDisplayID();
|
2017-05-09 02:01:36 +03:00
|
|
|
mDisplayInfo.mPresentingGroups = 0;
|
|
|
|
mDisplayInfo.mGroupMask = kVRGroupContent;
|
|
|
|
mDisplayInfo.mFrameId = 0;
|
2018-06-05 01:45:04 +03:00
|
|
|
mDisplayInfo.mDisplayState.mPresentingGeneration = 0;
|
2018-03-14 03:09:54 +03:00
|
|
|
mDisplayInfo.mDisplayState.mDisplayName[0] = '\0';
|
2018-08-24 18:32:12 +03:00
|
|
|
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
mLastSubmittedFrameId = 0;
|
|
|
|
mLastStartedFrame = 0;
|
|
|
|
#endif // defined(MOZ_WIDGET_ANDROID)
|
2016-02-25 02:54:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
VRDisplayHost::~VRDisplayHost() {
|
2017-11-17 11:06:59 +03:00
|
|
|
if (mSubmitThread) {
|
|
|
|
mSubmitThread->Shutdown();
|
|
|
|
mSubmitThread = nullptr;
|
|
|
|
}
|
2016-02-25 02:54:50 +03:00
|
|
|
MOZ_COUNT_DTOR(VRDisplayHost);
|
|
|
|
}
|
|
|
|
|
2017-09-19 02:19:49 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
bool VRDisplayHost::CreateD3DObjects() {
|
|
|
|
if (!mDevice) {
|
2017-08-29 01:56:43 +03:00
|
|
|
RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetVRDevice();
|
2017-09-19 02:19:49 +03:00
|
|
|
if (!device) {
|
|
|
|
NS_WARNING("VRDisplayHost::CreateD3DObjects failed to get a D3D11Device");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (FAILED(device->QueryInterface(__uuidof(ID3D11Device1),
|
|
|
|
getter_AddRefs(mDevice)))) {
|
|
|
|
NS_WARNING(
|
|
|
|
"VRDisplayHost::CreateD3DObjects failed to get a D3D11Device1");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!mContext) {
|
|
|
|
mDevice->GetImmediateContext1(getter_AddRefs(mContext));
|
|
|
|
if (!mContext) {
|
|
|
|
NS_WARNING(
|
|
|
|
"VRDisplayHost::CreateD3DObjects failed to get an immediate context");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!mDeviceContextState) {
|
|
|
|
D3D_FEATURE_LEVEL featureLevels[]{D3D_FEATURE_LEVEL_11_1,
|
|
|
|
D3D_FEATURE_LEVEL_11_0};
|
|
|
|
mDevice->CreateDeviceContextState(0, featureLevels, 2, D3D11_SDK_VERSION,
|
|
|
|
__uuidof(ID3D11Device1), nullptr,
|
|
|
|
getter_AddRefs(mDeviceContextState));
|
|
|
|
}
|
|
|
|
if (!mDeviceContextState) {
|
|
|
|
NS_WARNING(
|
|
|
|
"VRDisplayHost::CreateD3DObjects failed to get a "
|
|
|
|
"D3D11DeviceContextState");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ID3D11Device1* VRDisplayHost::GetD3DDevice() { return mDevice; }
|
|
|
|
|
|
|
|
ID3D11DeviceContext1* VRDisplayHost::GetD3DDeviceContext() { return mContext; }
|
|
|
|
|
|
|
|
ID3DDeviceContextState* VRDisplayHost::GetD3DDeviceContextState() {
|
|
|
|
return mDeviceContextState;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // defined(XP_WIN)
|
|
|
|
|
2017-05-09 02:01:36 +03:00
|
|
|
void VRDisplayHost::SetGroupMask(uint32_t aGroupMask) {
|
|
|
|
mDisplayInfo.mGroupMask = aGroupMask;
|
|
|
|
}
|
|
|
|
|
2017-06-22 09:32:18 +03:00
|
|
|
bool VRDisplayHost::GetIsConnected() {
|
2018-03-14 03:09:54 +03:00
|
|
|
return mDisplayInfo.mDisplayState.mIsConnected;
|
2017-06-22 09:32:18 +03:00
|
|
|
}
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
void VRDisplayHost::AddLayer(VRLayerParent* aLayer) {
|
|
|
|
mLayers.AppendElement(aLayer);
|
2017-05-09 02:01:36 +03:00
|
|
|
mDisplayInfo.mPresentingGroups |= aLayer->GetGroup();
|
2016-02-25 02:54:50 +03:00
|
|
|
if (mLayers.Length() == 1) {
|
|
|
|
StartPresentation();
|
|
|
|
}
|
2016-09-03 00:45:54 +03:00
|
|
|
|
|
|
|
// Ensure that the content process receives the change immediately
|
|
|
|
VRManager* vm = VRManager::Get();
|
|
|
|
vm->RefreshVRDisplays();
|
2016-02-25 02:54:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void VRDisplayHost::RemoveLayer(VRLayerParent* aLayer) {
|
|
|
|
mLayers.RemoveElement(aLayer);
|
|
|
|
if (mLayers.Length() == 0) {
|
|
|
|
StopPresentation();
|
|
|
|
}
|
2017-05-09 02:01:36 +03:00
|
|
|
mDisplayInfo.mPresentingGroups = 0;
|
|
|
|
for (auto layer : mLayers) {
|
|
|
|
mDisplayInfo.mPresentingGroups |= layer->GetGroup();
|
|
|
|
}
|
2016-09-03 00:45:54 +03:00
|
|
|
|
|
|
|
// Ensure that the content process receives the change immediately
|
|
|
|
VRManager* vm = VRManager::Get();
|
|
|
|
vm->RefreshVRDisplays();
|
2016-02-25 02:54:50 +03:00
|
|
|
}
|
|
|
|
|
2017-05-09 02:01:36 +03:00
|
|
|
void VRDisplayHost::StartFrame() {
|
2017-10-04 01:11:18 +03:00
|
|
|
AUTO_PROFILER_TRACING("VR", "GetSensorState");
|
2017-09-06 11:08:21 +03:00
|
|
|
|
2018-09-26 01:56:10 +03:00
|
|
|
TimeStamp now = TimeStamp::Now();
|
2018-08-24 18:32:12 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2018-09-26 01:56:10 +03:00
|
|
|
const TimeStamp lastFrameStart =
|
|
|
|
mDisplayInfo.mLastFrameStart[mDisplayInfo.mFrameId % kVRMaxLatencyFrames];
|
2018-08-24 18:32:12 +03:00
|
|
|
const bool isPresenting = mLastUpdateDisplayInfo.GetPresentingGroups() != 0;
|
2018-09-26 01:56:10 +03:00
|
|
|
double duration =
|
|
|
|
lastFrameStart.IsNull() ? 0.0 : (now - lastFrameStart).ToMilliseconds();
|
2018-08-24 18:32:12 +03:00
|
|
|
/**
|
|
|
|
* Do not start more VR frames until the last submitted frame is already
|
|
|
|
* processed.
|
|
|
|
*/
|
|
|
|
if (isPresenting && mLastStartedFrame > 0 &&
|
|
|
|
mDisplayInfo.mDisplayState.mLastSubmittedFrameId < mLastStartedFrame &&
|
|
|
|
duration < (double)ANDROID_MAX_FRAME_DURATION) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif // !defined(MOZ_WIDGET_ANDROID)
|
|
|
|
|
2017-05-09 02:01:36 +03:00
|
|
|
++mDisplayInfo.mFrameId;
|
2018-09-26 01:56:10 +03:00
|
|
|
size_t bufferIndex = mDisplayInfo.mFrameId % kVRMaxLatencyFrames;
|
|
|
|
mDisplayInfo.mLastSensorState[bufferIndex] = GetSensorState();
|
|
|
|
mDisplayInfo.mLastFrameStart[bufferIndex] = now;
|
2017-07-15 02:08:49 +03:00
|
|
|
mFrameStarted = true;
|
2018-08-24 18:32:12 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
mLastStartedFrame = mDisplayInfo.mFrameId;
|
|
|
|
#endif // !defined(MOZ_WIDGET_ANDROID)
|
2017-05-09 02:01:36 +03:00
|
|
|
}
|
2016-02-25 02:54:50 +03:00
|
|
|
|
2017-05-09 02:01:36 +03:00
|
|
|
void VRDisplayHost::NotifyVSync() {
|
2018-09-26 01:56:10 +03:00
|
|
|
/**
|
|
|
|
* If this display isn't presenting, refresh the sensors and trigger
|
|
|
|
* VRDisplay.requestAnimationFrame at the normal 2d display refresh rate.
|
|
|
|
*/
|
|
|
|
if (mDisplayInfo.mPresentingGroups == 0) {
|
|
|
|
VRManager* vm = VRManager::Get();
|
|
|
|
MOZ_ASSERT(vm);
|
|
|
|
vm->NotifyVRVsync(mDisplayInfo.mDisplayID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VRDisplayHost::CheckWatchDog() {
|
2017-05-09 02:01:36 +03:00
|
|
|
/**
|
|
|
|
* We will trigger a new frame immediately after a successful frame texture
|
|
|
|
* submission. If content fails to call VRDisplay.submitFrame after
|
2017-10-06 12:56:53 +03:00
|
|
|
* dom.vr.display.rafMaxDuration milliseconds has elapsed since the last
|
2017-05-09 02:01:36 +03:00
|
|
|
* VRDisplay.requestAnimationFrame, we act as a "watchdog" and kick-off
|
|
|
|
* a new VRDisplay.requestAnimationFrame to avoid a render loop stall and
|
|
|
|
* to give content a chance to recover.
|
|
|
|
*
|
|
|
|
* If the lower level VR platform API's are rejecting submitted frames,
|
|
|
|
* such as when the Oculus "Health and Safety Warning" is displayed,
|
|
|
|
* we will not kick off the next frame immediately after VRDisplay.submitFrame
|
|
|
|
* as it would result in an unthrottled render loop that would free run at
|
|
|
|
* potentially extreme frame rates. To ensure that content has a chance to
|
|
|
|
* resume its presentation when the frames are accepted once again, we rely
|
|
|
|
* on this "watchdog" to act as a VR refresh driver cycling at a rate defined
|
2017-10-06 12:56:53 +03:00
|
|
|
* by dom.vr.display.rafMaxDuration.
|
2017-05-09 02:01:36 +03:00
|
|
|
*
|
|
|
|
* This number must be larger than the slowest expected frame time during
|
|
|
|
* normal VR presentation, but small enough not to break content that
|
|
|
|
* makes assumptions of reasonably minimal VSync rate.
|
|
|
|
*
|
|
|
|
* The slowest expected refresh rate for a VR display currently is an
|
|
|
|
* Oculus CV1 when ASW (Asynchronous Space Warp) is enabled, at 45hz.
|
2017-10-06 12:56:53 +03:00
|
|
|
* A dom.vr.display.rafMaxDuration value of 50 milliseconds results in a 20hz
|
2017-05-09 02:01:36 +03:00
|
|
|
* rate, which avoids inadvertent triggering of the watchdog during
|
|
|
|
* Oculus ASW even if every second frame is dropped.
|
|
|
|
*/
|
|
|
|
bool bShouldStartFrame = false;
|
|
|
|
|
2018-09-26 01:56:10 +03:00
|
|
|
// If content fails to call VRDisplay.submitFrame, we must eventually
|
|
|
|
// time-out and trigger a new frame.
|
|
|
|
TimeStamp lastFrameStart =
|
|
|
|
mDisplayInfo.mLastFrameStart[mDisplayInfo.mFrameId % kVRMaxLatencyFrames];
|
|
|
|
if (lastFrameStart.IsNull()) {
|
2017-05-09 02:01:36 +03:00
|
|
|
bShouldStartFrame = true;
|
|
|
|
} else {
|
2018-09-26 01:56:10 +03:00
|
|
|
TimeDuration duration = TimeStamp::Now() - lastFrameStart;
|
|
|
|
if (duration.ToMilliseconds() > gfxPrefs::VRDisplayRafMaxDuration()) {
|
2017-05-09 02:01:36 +03:00
|
|
|
bShouldStartFrame = true;
|
|
|
|
}
|
2016-02-25 02:54:50 +03:00
|
|
|
}
|
2017-05-09 02:01:36 +03:00
|
|
|
|
|
|
|
if (bShouldStartFrame) {
|
|
|
|
VRManager* vm = VRManager::Get();
|
|
|
|
MOZ_ASSERT(vm);
|
|
|
|
vm->NotifyVRVsync(mDisplayInfo.mDisplayID);
|
2016-02-25 02:54:50 +03:00
|
|
|
}
|
2017-05-09 02:01:36 +03:00
|
|
|
}
|
|
|
|
|
2018-09-26 01:56:10 +03:00
|
|
|
void VRDisplayHost::Run1msTasks(double aDeltaTime) {
|
|
|
|
// To override in children
|
|
|
|
}
|
|
|
|
|
|
|
|
void VRDisplayHost::Run10msTasks() { CheckWatchDog(); }
|
|
|
|
|
|
|
|
void VRDisplayHost::Run100msTasks() {
|
|
|
|
// to override in children
|
|
|
|
}
|
|
|
|
|
2017-11-17 11:06:59 +03:00
|
|
|
void VRDisplayHost::SubmitFrameInternal(
|
|
|
|
const layers::SurfaceDescriptor& aTexture, uint64_t aFrameId,
|
|
|
|
const gfx::Rect& aLeftEyeRect, const gfx::Rect& aRightEyeRect) {
|
2018-06-05 01:45:04 +03:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID)
|
2017-11-17 11:06:59 +03:00
|
|
|
MOZ_ASSERT(mSubmitThread->GetThread() == NS_GetCurrentThread());
|
2018-06-05 01:45:04 +03:00
|
|
|
#endif // !defined(MOZ_WIDGET_ANDROID)
|
2017-10-04 01:11:18 +03:00
|
|
|
AUTO_PROFILER_TRACING("VR", "SubmitFrameAtVRDisplayHost");
|
2017-09-06 11:08:21 +03:00
|
|
|
|
2018-05-08 21:31:28 +03:00
|
|
|
if (!SubmitFrame(aTexture, aFrameId, aLeftEyeRect, aRightEyeRect)) {
|
|
|
|
return;
|
2017-07-22 03:30:34 +03:00
|
|
|
}
|
2017-07-04 23:50:40 +03:00
|
|
|
|
2018-06-05 01:45:04 +03:00
|
|
|
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
|
2017-11-01 03:25:40 +03:00
|
|
|
|
2017-05-09 02:01:36 +03:00
|
|
|
/**
|
|
|
|
* Trigger the next VSync immediately after we are successfully
|
|
|
|
* submitting frames. As SubmitFrame is responsible for throttling
|
|
|
|
* the render loop, if we don't successfully call it, we shouldn't trigger
|
|
|
|
* NotifyVRVsync immediately, as it will run unbounded.
|
|
|
|
* If NotifyVRVsync is not called here due to SubmitFrame failing, the
|
|
|
|
* fallback "watchdog" code in VRDisplayHost::NotifyVSync() will cause
|
|
|
|
* frames to continue at a lower refresh rate until frame submission
|
|
|
|
* succeeds again.
|
|
|
|
*/
|
2017-10-05 13:16:16 +03:00
|
|
|
VRManager* vm = VRManager::Get();
|
2018-10-03 00:17:05 +03:00
|
|
|
MessageLoop* loop = CompositorThreadHolder::Loop();
|
2017-10-05 13:16:16 +03:00
|
|
|
|
|
|
|
loop->PostTask(NewRunnableMethod<const uint32_t>(
|
2017-10-16 08:30:46 +03:00
|
|
|
"gfx::VRManager::NotifyVRVsync", vm, &VRManager::NotifyVRVsync,
|
2017-10-05 13:16:16 +03:00
|
|
|
mDisplayInfo.mDisplayID));
|
2016-02-25 02:54:50 +03:00
|
|
|
#endif
|
2017-07-04 23:50:40 +03:00
|
|
|
}
|
2016-02-25 02:54:50 +03:00
|
|
|
|
2017-11-17 11:06:59 +03:00
|
|
|
void VRDisplayHost::SubmitFrame(VRLayerParent* aLayer,
|
|
|
|
const layers::SurfaceDescriptor& aTexture,
|
|
|
|
uint64_t aFrameId,
|
|
|
|
const gfx::Rect& aLeftEyeRect,
|
|
|
|
const gfx::Rect& aRightEyeRect) {
|
|
|
|
if ((mDisplayInfo.mGroupMask & aLayer->GetGroup()) == 0) {
|
|
|
|
// Suppress layers hidden by the group mask
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure that we only accept the first SubmitFrame call per RAF cycle.
|
|
|
|
if (!mFrameStarted || aFrameId != mDisplayInfo.mFrameId) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-24 18:32:12 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
/**
|
|
|
|
* Do not queue more submit frames until the last submitted frame is already
|
|
|
|
* processed and the new WebGL texture is ready.
|
|
|
|
*/
|
|
|
|
if (mLastSubmittedFrameId > 0 &&
|
|
|
|
mLastSubmittedFrameId !=
|
|
|
|
mDisplayInfo.mDisplayState.mLastSubmittedFrameId) {
|
|
|
|
mLastStartedFrame = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mLastSubmittedFrameId = aFrameId;
|
|
|
|
#endif // !defined(MOZ_WIDGET_ANDROID)
|
|
|
|
|
2018-05-08 21:31:28 +03:00
|
|
|
mFrameStarted = false;
|
|
|
|
|
2017-12-19 04:40:47 +03:00
|
|
|
RefPtr<Runnable> submit =
|
2017-11-17 11:06:59 +03:00
|
|
|
NewRunnableMethod<StoreCopyPassByConstLRef<layers::SurfaceDescriptor>,
|
|
|
|
uint64_t, StoreCopyPassByConstLRef<gfx::Rect>,
|
|
|
|
StoreCopyPassByConstLRef<gfx::Rect>>(
|
|
|
|
"gfx::VRDisplayHost::SubmitFrameInternal", this,
|
|
|
|
&VRDisplayHost::SubmitFrameInternal, aTexture, aFrameId, aLeftEyeRect,
|
2017-12-19 04:40:47 +03:00
|
|
|
aRightEyeRect);
|
2018-05-08 21:31:28 +03:00
|
|
|
|
2018-06-05 01:45:04 +03:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID)
|
2018-05-08 21:31:28 +03:00
|
|
|
if (!mSubmitThread) {
|
|
|
|
mSubmitThread = new VRThread(NS_LITERAL_CSTRING("VR_SubmitFrame"));
|
|
|
|
}
|
2017-12-19 04:40:47 +03:00
|
|
|
mSubmitThread->Start();
|
|
|
|
mSubmitThread->PostTask(submit.forget());
|
|
|
|
#else
|
|
|
|
CompositorThreadHolder::Loop()->PostTask(submit.forget());
|
2018-06-05 01:45:04 +03:00
|
|
|
#endif // defined(MOZ_WIDGET_ANDROID)
|
2017-11-17 11:06:59 +03:00
|
|
|
}
|
|
|
|
|
2016-02-25 02:54:50 +03:00
|
|
|
bool VRDisplayHost::CheckClearDisplayInfoDirty() {
|
|
|
|
if (mDisplayInfo == mLastUpdateDisplayInfo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mLastUpdateDisplayInfo = mDisplayInfo;
|
|
|
|
return true;
|
|
|
|
}
|
2016-10-07 11:58:01 +03:00
|
|
|
|
2018-07-31 04:41:25 +03:00
|
|
|
void VRDisplayHost::StartVRNavigation() {}
|
|
|
|
|
|
|
|
void VRDisplayHost::StopVRNavigation(const TimeDuration& aTimeout) {}
|
|
|
|
|
2017-07-14 12:01:09 +03:00
|
|
|
VRControllerHost::VRControllerHost(VRDeviceType aType, dom::GamepadHand aHand,
|
|
|
|
uint32_t aDisplayID)
|
2018-03-14 03:09:54 +03:00
|
|
|
: mControllerInfo{}, mVibrateIndex(0) {
|
2016-10-07 11:58:01 +03:00
|
|
|
MOZ_COUNT_CTOR(VRControllerHost);
|
|
|
|
mControllerInfo.mType = aType;
|
2018-07-11 22:20:51 +03:00
|
|
|
mControllerInfo.mControllerState.hand = aHand;
|
2017-07-14 12:01:09 +03:00
|
|
|
mControllerInfo.mMappingType = dom::GamepadMappingType::_empty;
|
|
|
|
mControllerInfo.mDisplayID = aDisplayID;
|
|
|
|
mControllerInfo.mControllerID = VRSystemManager::AllocateControllerID();
|
2016-10-07 11:58:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
VRControllerHost::~VRControllerHost() { MOZ_COUNT_DTOR(VRControllerHost); }
|
2016-10-13 09:30:26 +03:00
|
|
|
|
|
|
|
const VRControllerInfo& VRControllerHost::GetControllerInfo() const {
|
|
|
|
return mControllerInfo;
|
|
|
|
}
|
|
|
|
|
2016-11-08 03:15:01 +03:00
|
|
|
void VRControllerHost::SetButtonPressed(uint64_t aBit) {
|
2018-07-11 22:20:51 +03:00
|
|
|
mControllerInfo.mControllerState.buttonPressed = aBit;
|
2016-11-08 03:15:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t VRControllerHost::GetButtonPressed() {
|
2018-07-11 22:20:51 +03:00
|
|
|
return mControllerInfo.mControllerState.buttonPressed;
|
2016-11-08 03:15:01 +03:00
|
|
|
}
|
2016-10-24 13:09:11 +03:00
|
|
|
|
2017-04-06 14:00:20 +03:00
|
|
|
void VRControllerHost::SetButtonTouched(uint64_t aBit) {
|
2018-07-11 22:20:51 +03:00
|
|
|
mControllerInfo.mControllerState.buttonTouched = aBit;
|
2017-04-06 14:00:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t VRControllerHost::GetButtonTouched() {
|
2018-07-11 22:20:51 +03:00
|
|
|
return mControllerInfo.mControllerState.buttonTouched;
|
2017-04-06 14:00:20 +03:00
|
|
|
}
|
|
|
|
|
2016-10-24 13:09:11 +03:00
|
|
|
void VRControllerHost::SetPose(const dom::GamepadPoseState& aPose) {
|
|
|
|
mPose = aPose;
|
|
|
|
}
|
|
|
|
|
|
|
|
const dom::GamepadPoseState& VRControllerHost::GetPose() { return mPose; }
|
|
|
|
|
2017-02-06 11:07:20 +03:00
|
|
|
dom::GamepadHand VRControllerHost::GetHand() {
|
2018-07-11 22:20:51 +03:00
|
|
|
return mControllerInfo.mControllerState.hand;
|
2017-02-06 11:07:20 +03:00
|
|
|
}
|
|
|
|
|
2017-02-02 09:57:58 +03:00
|
|
|
void VRControllerHost::SetVibrateIndex(uint64_t aIndex) {
|
|
|
|
mVibrateIndex = aIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t VRControllerHost::GetVibrateIndex() { return mVibrateIndex; }
|