Bug 1581855:Part 2 - Present VR output to VR Host r=kip,jrmuizel,sotaro,bryce
This change is a continuation of Part 1 (Bug 1570128), 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 (Bug 1581881) 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
2019-09-26 15:50:44 +03:00
|
|
|
/* -*- 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"
|
|
|
|
|
2019-10-18 04:24:56 +03:00
|
|
|
#include "nsWindow.h"
|
|
|
|
|
Bug 1581855:Part 2 - Present VR output to VR Host r=kip,jrmuizel,sotaro,bryce
This change is a continuation of Part 1 (Bug 1570128), 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 (Bug 1581881) 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
2019-09-26 15:50:44 +03:00
|
|
|
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);
|
|
|
|
}
|
2019-10-18 04:24:56 +03:00
|
|
|
|
|
|
|
// Returns true if the window was created for Firefox Reality
|
|
|
|
bool FxRWindowManager::IsFxRWindow(const nsWindow* aWindow) const {
|
|
|
|
return (mWindow != nullptr) &&
|
|
|
|
(aWindow ==
|
|
|
|
mozilla::widget::WidgetUtils::DOMWindowToWidget(mWindow).take());
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t FxRWindowManager::GetWindowID() const {
|
|
|
|
MOZ_ASSERT(mWindow);
|
|
|
|
return mWindow->WindowID();
|
2021-01-07 11:53:08 +03:00
|
|
|
}
|