mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1581855:Part 2 - Present VR output to VR Host r=kip,jrmuizel,sotaro,bryce
This change is a continuation of Part 1 (Bug1570128
), where the 2D content rendered by Firefox for Firefox Reality on Desktop is marshalled through VRHost so that it can be presented in a VR environment. A new class, FxrOutputHandler, is created to manage creating a sharable texture, sharing it through VRShMem, and updating it when content updates. This class updates content with both WebRender and conventional rendering output. This initial iteration of FxrOutputHandler does not have synchronization between reading and writing this shared texture across processes. A subsequent fix (Bug1581881
) is pending, which will reuse WebVR code to manage writing to and reading from a pool of textures. This also presents issues with rendering protected media, so an additional class, FxrWindowManager, is created to manage all windows created for Firefox Reality on Desktop so that it can inform whether or not protected media can be presented. The automated manual tests in vrhosttest.cpp now show the real shared texture handle rather than a fake value, which shows that marshaling succeeded. Differential Revision: https://phabricator.services.mozilla.com/D46179 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
216d51dfc1
commit
ab2f648351
@ -395,7 +395,13 @@ BrowserChild::BrowserChild(ContentChild* aManager, const TabId& aTabId,
|
||||
mPendingLayersObserverEpoch{0},
|
||||
mPendingDocShellBlockers(0),
|
||||
mCancelContentJSEpoch(0),
|
||||
mWidgetNativeData(0) {
|
||||
mWidgetNativeData(0)
|
||||
#ifdef XP_WIN
|
||||
,
|
||||
mWindowSupportsProtectedMedia(true),
|
||||
mWindowSupportsProtectedMediaChecked(false)
|
||||
#endif
|
||||
{
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
nsWeakPtr weakPtrThis(do_GetWeakReference(
|
||||
@ -600,7 +606,8 @@ nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent,
|
||||
mPuppetWidget->CreateCompositor();
|
||||
}
|
||||
|
||||
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_THUNDERBIRD) && !defined(MOZ_SUITE)
|
||||
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_THUNDERBIRD) && \
|
||||
!defined(MOZ_SUITE)
|
||||
mSessionStoreListener = new TabListener(docShell, nullptr);
|
||||
rv = mSessionStoreListener->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -3894,6 +3901,27 @@ bool BrowserChild::UpdateSessionStore(uint32_t aFlushId, bool aIsFinal) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Cache the response to the IPC call to IsWindowSupportingProtectedMedia,
|
||||
// since it will not change for the lifetime of this object
|
||||
void BrowserChild::UpdateIsWindowSupportingProtectedMedia(bool aIsSupported) {
|
||||
mWindowSupportsProtectedMediaChecked = true;
|
||||
mWindowSupportsProtectedMedia = aIsSupported;
|
||||
}
|
||||
|
||||
// Reuse the cached response to the IPC call IsWindowSupportingProtectedMedia
|
||||
// when available
|
||||
bool BrowserChild::RequiresIsWindowSupportingProtectedMediaCheck(
|
||||
bool& aIsSupported) {
|
||||
if (mWindowSupportsProtectedMediaChecked) {
|
||||
aIsSupported = mWindowSupportsProtectedMedia;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
BrowserChildMessageManager::BrowserChildMessageManager(
|
||||
BrowserChild* aBrowserChild)
|
||||
: ContentFrameMessageManager(new nsFrameMessageManager(aBrowserChild)),
|
||||
|
@ -663,6 +663,11 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
|
||||
|
||||
bool UpdateSessionStore(uint32_t aFlushId, bool aIsFinal = false);
|
||||
|
||||
#ifdef XP_WIN
|
||||
void UpdateIsWindowSupportingProtectedMedia(bool aIsSupported);
|
||||
bool RequiresIsWindowSupportingProtectedMediaCheck(bool& aIsSupported);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual ~BrowserChild();
|
||||
|
||||
@ -910,6 +915,11 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
|
||||
Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;
|
||||
ScreenRect mRemoteDocumentRect;
|
||||
|
||||
#ifdef XP_WIN
|
||||
bool mWindowSupportsProtectedMedia;
|
||||
bool mWindowSupportsProtectedMediaChecked;
|
||||
#endif
|
||||
|
||||
// This state is used to keep track of the current visible tabs (the ones
|
||||
// rendering layers). There may be more than one if there are multiple browser
|
||||
// windows open, or tabs are being warmed up. There may be none if this
|
||||
|
@ -118,6 +118,7 @@
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include "mozilla/plugins/PluginWidgetParent.h"
|
||||
# include "FxRWindowManager.h"
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
||||
@ -3979,5 +3980,19 @@ void BrowserParent::OnSubFrameCrashed() {
|
||||
}
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult BrowserParent::RecvIsWindowSupportingProtectedMedia(
|
||||
const uint64_t& aOuterWindowID,
|
||||
IsWindowSupportingProtectedMediaResolver&& aResolve) {
|
||||
#ifdef XP_WIN
|
||||
bool isFxrWindow =
|
||||
FxRWindowManager::GetInstance()->IsFxRWindow(aOuterWindowID);
|
||||
aResolve(!isFxrWindow);
|
||||
#else
|
||||
MOZ_CRASH("Should only be called on Windows");
|
||||
#endif
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -500,6 +500,10 @@ class BrowserParent final : public PBrowserParent,
|
||||
const nsString& aRemoteType, BrowsingContext* aBrowsingContext,
|
||||
const uint32_t& aChromeFlags, const TabId& aTabId) override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvIsWindowSupportingProtectedMedia(
|
||||
const uint64_t& aOuterWindowID,
|
||||
IsWindowSupportingProtectedMediaResolver&& aResolve);
|
||||
|
||||
void LoadURL(nsIURI* aURI);
|
||||
|
||||
void ResumeLoad(uint64_t aPendingSwitchID);
|
||||
|
@ -1031,7 +1031,13 @@ child:
|
||||
async GetContentBlockingLog() returns(IPCStream ipcStream, bool success);
|
||||
|
||||
async SkipBrowsingContextDetach() returns (bool success);
|
||||
|
||||
parent:
|
||||
/**
|
||||
* Fetches whether this window supports protected media, which is sent back in response.
|
||||
*/
|
||||
async IsWindowSupportingProtectedMedia(uint64_t aOuterWindowID) returns(bool isSupported);
|
||||
|
||||
/** Records a history visit. */
|
||||
async VisitURI(URIParams aURI, URIParams? aLastVisitedURI,
|
||||
uint32_t aFlags);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "nsIScriptError.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "mozilla/dom/BrowserChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -72,6 +73,51 @@ void MediaKeySystemAccessManager::Request(
|
||||
EME_LOG("MediaKeySystemAccessManager::Request %s",
|
||||
NS_ConvertUTF16toUTF8(aKeySystem).get());
|
||||
|
||||
bool isSupported = true;
|
||||
#ifdef XP_WIN
|
||||
// In Windows OS, some Firefox windows that host content cannot support
|
||||
// protected content, so check the status of support for this window.
|
||||
RefPtr<BrowserChild> browser(BrowserChild::GetFrom(mWindow));
|
||||
if (browser->RequiresIsWindowSupportingProtectedMediaCheck(isSupported)) {
|
||||
int browserID = browser->ChromeOuterWindowID();
|
||||
|
||||
RefPtr<MediaKeySystemAccessManager> self(this);
|
||||
nsString keySystem(aKeySystem);
|
||||
RefPtr<DetailedPromise> promise(aPromise);
|
||||
Sequence<MediaKeySystemConfiguration> configs(aConfigs);
|
||||
|
||||
browser->SendIsWindowSupportingProtectedMedia(browserID)->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[self, browser, promise, keySystem, configs,
|
||||
aType](bool isSupportedLambda) {
|
||||
browser->UpdateIsWindowSupportingProtectedMedia(isSupportedLambda);
|
||||
self->RequestCallback(isSupportedLambda, promise, keySystem, configs,
|
||||
aType);
|
||||
},
|
||||
[](const mozilla::ipc::ResponseRejectReason) {
|
||||
MOZ_CRASH(
|
||||
"Failed to make IPC call to IsWindowSupportingProtectedMedia");
|
||||
});
|
||||
} else {
|
||||
#endif
|
||||
RequestCallback(isSupported, aPromise, aKeySystem, aConfigs, aType);
|
||||
#ifdef XP_WIN
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MediaKeySystemAccessManager::RequestCallback(
|
||||
bool aIsSupportedInWindow, DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs, RequestType aType) {
|
||||
if (!aIsSupportedInWindow) {
|
||||
aPromise->MaybeReject(
|
||||
NS_ERROR_DOM_NOT_SUPPORTED_ERR,
|
||||
NS_LITERAL_CSTRING("EME is not supported in this window"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (aKeySystem.IsEmpty()) {
|
||||
aPromise->MaybeRejectWithTypeError(u"Key system string is empty");
|
||||
// Don't notify DecoderDoctor, as there's nothing we or the user can
|
||||
|
@ -53,6 +53,11 @@ class MediaKeySystemAccessManager final : public nsIObserver {
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfig,
|
||||
RequestType aType);
|
||||
|
||||
void RequestCallback(bool aIsSupportedInWindow, DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs,
|
||||
RequestType aType);
|
||||
|
||||
~MediaKeySystemAccessManager();
|
||||
|
||||
bool EnsureObserversAdded();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "TextureD3D11.h"
|
||||
#include "gfxConfig.h"
|
||||
#include "mozilla/StaticPrefs_layers.h"
|
||||
#include "FxROutputHandler.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -415,6 +416,17 @@ void MLGSwapChainD3D11::Present() {
|
||||
// See bug 1260611 comment #28 for why we do this.
|
||||
mParent->InsertPresentWaitQuery();
|
||||
|
||||
if (mWidget->AsWindows()->HasFxrOutputHandler()) {
|
||||
// There is a Firefox Reality handler for this swapchain. Update this
|
||||
// window's contents to the VR window.
|
||||
FxROutputHandler* fxrHandler = mWidget->AsWindows()->GetFxrOutputHandler();
|
||||
if (fxrHandler->TryInitialize(mSwapChain, mDevice)) {
|
||||
RefPtr<ID3D11DeviceContext> context;
|
||||
mDevice->GetImmediateContext(getter_AddRefs(context));
|
||||
fxrHandler->UpdateOutput(context);
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
if (mCanUsePartialPresents && mSwapChain1) {
|
||||
StackArray<RECT, 4> rects(mBackBufferInvalid.GetNumRects());
|
||||
|
96
gfx/vr/FxROutputHandler.cpp
Normal file
96
gfx/vr/FxROutputHandler.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#include "FxROutputHandler.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "moz_external_vr.h"
|
||||
#include "VRShMem.h"
|
||||
|
||||
// TryInitialize is responsible for associating this output handler with the
|
||||
// calling window's swapchain for subsequent updates. This also creates a
|
||||
// texture that can be shared across processes and updates VRShMem with the
|
||||
// shared texture handle.
|
||||
// See nsFxrCommandLineHandler::Handle for more information about the
|
||||
// bootstrap process.
|
||||
bool FxROutputHandler::TryInitialize(IDXGISwapChain* aSwapChain,
|
||||
ID3D11Device* aDevice) {
|
||||
if (mSwapChain == nullptr) {
|
||||
RefPtr<ID3D11Texture2D> texOrig = nullptr;
|
||||
HRESULT hr =
|
||||
aSwapChain->GetBuffer(0, IID_ID3D11Texture2D, getter_AddRefs(texOrig));
|
||||
if (hr != S_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create shareable texture, which will be copied to
|
||||
D3D11_TEXTURE2D_DESC descOrig = {0};
|
||||
texOrig->GetDesc(&descOrig);
|
||||
descOrig.MiscFlags |= D3D11_RESOURCE_MISC_SHARED;
|
||||
hr = aDevice->CreateTexture2D(&descOrig, nullptr,
|
||||
mTexCopy.StartAssignment());
|
||||
if (hr != S_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now, share the texture to a handle that can be marshaled to another
|
||||
// process
|
||||
HANDLE hCopy = nullptr;
|
||||
RefPtr<IDXGIResource> texResource;
|
||||
hr = mTexCopy->QueryInterface(IID_IDXGIResource,
|
||||
getter_AddRefs(texResource));
|
||||
if (hr != S_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = texResource->GetSharedHandle(&hCopy);
|
||||
if (hr != S_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The texture is successfully created and shared, so cache a
|
||||
// pointer to the swapchain to indicate this success.
|
||||
mSwapChain = aSwapChain;
|
||||
|
||||
// Finally, marshal the shared texture handle via VRShMem
|
||||
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/);
|
||||
if (shmem.JoinShMem()) {
|
||||
mozilla::gfx::VRWindowState windowState = {0};
|
||||
shmem.PullWindowState(windowState);
|
||||
|
||||
// The CLH should have populated hwndFx first
|
||||
MOZ_ASSERT(windowState.hwndFx != 0);
|
||||
MOZ_ASSERT(windowState.textureFx == nullptr);
|
||||
|
||||
windowState.textureFx = (HANDLE)hCopy;
|
||||
|
||||
shmem.PushWindowState(windowState);
|
||||
shmem.LeaveShMem();
|
||||
|
||||
// Notify the waiting host process that the data is now available
|
||||
HANDLE hSignal = ::OpenEventA(EVENT_ALL_ACCESS, // dwDesiredAccess
|
||||
FALSE, // bInheritHandle
|
||||
windowState.signalName // lpName
|
||||
);
|
||||
::SetEvent(hSignal);
|
||||
::CloseHandle(hSignal);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(aSwapChain == mSwapChain);
|
||||
}
|
||||
|
||||
return mSwapChain != nullptr && aSwapChain == mSwapChain;
|
||||
}
|
||||
|
||||
// Update the contents of the shared texture.
|
||||
void FxROutputHandler::UpdateOutput(ID3D11DeviceContext* aCtx) {
|
||||
MOZ_ASSERT(mSwapChain != nullptr);
|
||||
|
||||
ID3D11Texture2D* texOrig = nullptr;
|
||||
HRESULT hr = mSwapChain->GetBuffer(0, IID_PPV_ARGS(&texOrig));
|
||||
if (hr == S_OK) {
|
||||
aCtx->CopyResource(mTexCopy, texOrig);
|
||||
texOrig->Release();
|
||||
}
|
||||
}
|
30
gfx/vr/FxROutputHandler.h
Normal file
30
gfx/vr/FxROutputHandler.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#pragma once
|
||||
|
||||
struct ID3D11Texture2D;
|
||||
struct IDXGISwapChain;
|
||||
struct ID3D11DeviceContext;
|
||||
struct ID3D11Device;
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d11_1.h>
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
// FxROutputHandler is responsible for managing resources to share a Desktop
|
||||
// browser window with a Firefox Reality VR window.
|
||||
// Note: this object is created on the Compositor thread, but its usage should
|
||||
// only be on the RenderThread.
|
||||
class FxROutputHandler final {
|
||||
public:
|
||||
bool TryInitialize(IDXGISwapChain* aSwapChain, ID3D11Device* aDevice);
|
||||
void UpdateOutput(ID3D11DeviceContext* aCtx);
|
||||
|
||||
private:
|
||||
RefPtr<IDXGISwapChain> mSwapChain = nullptr;
|
||||
RefPtr<ID3D11Texture2D> mTexCopy = nullptr;
|
||||
};
|
36
gfx/vr/FxRWindowManager.cpp
Normal file
36
gfx/vr/FxRWindowManager.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#include "FxRWindowManager.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
|
||||
static mozilla::StaticAutoPtr<FxRWindowManager> sFxrWinMgrInstance;
|
||||
|
||||
FxRWindowManager* FxRWindowManager::GetInstance() {
|
||||
if (sFxrWinMgrInstance == nullptr) {
|
||||
sFxrWinMgrInstance = new FxRWindowManager();
|
||||
ClearOnShutdown(&sFxrWinMgrInstance);
|
||||
}
|
||||
|
||||
return sFxrWinMgrInstance;
|
||||
}
|
||||
|
||||
FxRWindowManager::FxRWindowManager() : mWindow(nullptr) {}
|
||||
|
||||
// Track this new Firefox Reality window instance
|
||||
void FxRWindowManager::AddWindow(nsPIDOMWindowOuter* aWindow) {
|
||||
if (mWindow != nullptr) {
|
||||
MOZ_CRASH("Only one window is supported");
|
||||
}
|
||||
|
||||
mWindow = aWindow;
|
||||
}
|
||||
|
||||
// Returns true if the window at the provided ID was created for Firefox Reality
|
||||
bool FxRWindowManager::IsFxRWindow(uint64_t aOuterWindowID) {
|
||||
return (mWindow != nullptr) && (mWindow->WindowID() == aOuterWindowID);
|
||||
}
|
28
gfx/vr/FxRWindowManager.h
Normal file
28
gfx/vr/FxRWindowManager.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
class nsPIDOMWindowOuter;
|
||||
|
||||
// FxRWindowManager is a singleton that is responsible for tracking all of
|
||||
// the top-level windows created for Firefox Reality on Desktop. Only a
|
||||
// single window is initially supported.
|
||||
class FxRWindowManager final {
|
||||
public:
|
||||
static FxRWindowManager* GetInstance();
|
||||
|
||||
void AddWindow(nsPIDOMWindowOuter* aWindow);
|
||||
bool IsFxRWindow(uint64_t aOuterWindowID);
|
||||
|
||||
private:
|
||||
FxRWindowManager();
|
||||
|
||||
// Only a single window is supported for tracking. Support for multiple
|
||||
// windows will require a data structure to collect windows as they are
|
||||
// created.
|
||||
nsPIDOMWindowOuter* mWindow;
|
||||
};
|
@ -6,6 +6,8 @@
|
||||
|
||||
EXPORTS += [
|
||||
'external_api/moz_external_vr.h',
|
||||
'FxROutputHandler.h',
|
||||
'FxRWindowManager.h',
|
||||
'gfxVR.h',
|
||||
'ipc/VRChild.h',
|
||||
'ipc/VRGPUChild.h',
|
||||
@ -90,6 +92,12 @@ if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['NIGHTLY_BUILD']:
|
||||
'nsFxrCommandLineHandler.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
SOURCES += [
|
||||
'FxROutputHandler.cpp',
|
||||
'FxRWindowManager.cpp'
|
||||
]
|
||||
|
||||
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
|
||||
CXXFLAGS += CONFIG['TK_CFLAGS']
|
||||
CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
|
||||
|
@ -9,6 +9,7 @@
|
||||
#endif
|
||||
|
||||
#include "nsFxrCommandLineHandler.h"
|
||||
#include "FxRWindowManager.h"
|
||||
|
||||
#include "nsICommandLine.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
@ -51,9 +52,12 @@ NS_IMPL_ISUPPORTS(nsFxrCommandLineHandler, nsICommandLineHandler)
|
||||
// | | share texture handle to
|
||||
// | | VRShMem and set signal
|
||||
// CreateVRWindow returns | |
|
||||
// to host | |
|
||||
// to host with relevant | |
|
||||
// return data from VRShMem | |
|
||||
// | Fx continues to run |
|
||||
// | | Fx continues to render
|
||||
// | | |
|
||||
//
|
||||
// ... ... ...
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFxrCommandLineHandler::Handle(nsICommandLine* aCmdLine) {
|
||||
@ -77,6 +81,9 @@ nsFxrCommandLineHandler::Handle(nsICommandLine* aCmdLine) {
|
||||
|
||||
MOZ_ASSERT(result == NS_OK);
|
||||
|
||||
nsPIDOMWindowOuter* newWindowOuter = nsPIDOMWindowOuter::From(newWindow);
|
||||
FxRWindowManager::GetInstance()->AddWindow(newWindowOuter);
|
||||
|
||||
// Send the window's HWND to vrhost through VRShMem
|
||||
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/);
|
||||
if (shmem.JoinShMem()) {
|
||||
@ -84,8 +91,7 @@ nsFxrCommandLineHandler::Handle(nsICommandLine* aCmdLine) {
|
||||
shmem.PullWindowState(windowState);
|
||||
|
||||
nsCOMPtr<nsIWidget> newWidget =
|
||||
mozilla::widget::WidgetUtils::DOMWindowToWidget(
|
||||
nsPIDOMWindowOuter::From(newWindow));
|
||||
mozilla::widget::WidgetUtils::DOMWindowToWidget(newWindowOuter);
|
||||
HWND hwndWidget = (HWND)newWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
|
||||
// The CLH should populate these members first
|
||||
@ -100,7 +106,9 @@ nsFxrCommandLineHandler::Handle(nsICommandLine* aCmdLine) {
|
||||
// after output data is set in VRShMem
|
||||
newWidget->RequestFxrOutput();
|
||||
} else {
|
||||
#ifndef NIGHTLY_BUILD
|
||||
MOZ_CRASH("failed to start with --fxr");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
#include "mozilla/widget/WinCompositorWidget.h"
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#include "FxROutputHandler.h"
|
||||
|
||||
#undef NTDDI_VERSION
|
||||
#define NTDDI_VERSION NTDDI_WIN8
|
||||
@ -336,6 +337,15 @@ bool RenderCompositorANGLE::BeginFrame(layers::NativeLayer* aNativeLayer) {
|
||||
void RenderCompositorANGLE::EndFrame() {
|
||||
InsertPresentWaitQuery();
|
||||
|
||||
if (mWidget->AsWindows()->HasFxrOutputHandler()) {
|
||||
// There is a Firefox Reality handler for this swapchain. Update this
|
||||
// window's contents to the VR window.
|
||||
FxROutputHandler* fxrHandler = mWidget->AsWindows()->GetFxrOutputHandler();
|
||||
if (fxrHandler->TryInitialize(mSwapChain, mDevice)) {
|
||||
fxrHandler->UpdateOutput(mCtx);
|
||||
}
|
||||
}
|
||||
|
||||
mSwapChain->Present(0, 0);
|
||||
}
|
||||
|
||||
|
@ -338,33 +338,12 @@ void WinCompositorWidget::UpdateCompositorWndSizeIfNecessary() {
|
||||
mLastCompositorWndSize = size;
|
||||
}
|
||||
|
||||
// TODO: Bug 1570128 - Forward request to swapchain
|
||||
// For now, this simply validates that data can be passed to Firefox Reality
|
||||
// host from the GPU process
|
||||
// Creates a new instance of FxROutputHandler so that this compositor widget
|
||||
// can send its output to Firefox Reality for Desktop.
|
||||
void WinCompositorWidget::RequestFxrOutput() {
|
||||
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/);
|
||||
if (shmem.JoinShMem()) {
|
||||
mozilla::gfx::VRWindowState windowState = {0};
|
||||
shmem.PullWindowState(windowState);
|
||||
MOZ_ASSERT(mFxrHandler == nullptr);
|
||||
|
||||
// The CLH should have populated hwndFx first
|
||||
MOZ_ASSERT(windowState.hwndFx != 0);
|
||||
MOZ_ASSERT(windowState.textureFx == nullptr);
|
||||
|
||||
windowState.textureFx = (HANDLE)0xFFFFFFFF;
|
||||
|
||||
shmem.PushWindowState(windowState);
|
||||
shmem.LeaveShMem();
|
||||
|
||||
// Notify the waiting host process that the data is now available
|
||||
HANDLE hSignal = ::OpenEventA(EVENT_ALL_ACCESS, // dwDesiredAccess
|
||||
FALSE, // bInheritHandle
|
||||
windowState.signalName // lpName
|
||||
);
|
||||
|
||||
::SetEvent(hSignal);
|
||||
::CloseHandle(hSignal);
|
||||
}
|
||||
mFxrHandler.reset(new FxROutputHandler());
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/widget/WinCompositorWindowThread.h"
|
||||
#include "FxROutputHandler.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
class nsWindow;
|
||||
@ -105,6 +106,8 @@ class WinCompositorWidget : public CompositorWidget,
|
||||
}
|
||||
|
||||
void RequestFxrOutput();
|
||||
bool HasFxrOutputHandler() const { return mFxrHandler != nullptr; }
|
||||
FxROutputHandler* GetFxrOutputHandler() const { return mFxrHandler.get(); }
|
||||
|
||||
protected:
|
||||
private:
|
||||
@ -133,6 +136,8 @@ class WinCompositorWidget : public CompositorWidget,
|
||||
uint8_t* mLockedBackBufferData;
|
||||
|
||||
bool mNotDeferEndRemoteDrawing;
|
||||
|
||||
UniquePtr<FxROutputHandler> mFxrHandler;
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
@ -422,7 +422,6 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel) {
|
||||
// call for RequesetFxrOutput as soon as the compositor for this widget is
|
||||
// available.
|
||||
void nsWindow::CreateCompositor() {
|
||||
// there's no super??
|
||||
nsWindowBase::CreateCompositor();
|
||||
|
||||
if (mRequestFxrOutputPending) {
|
||||
|
Loading…
Reference in New Issue
Block a user