gecko-dev/gfx/vr/FxRWindowManager.cpp
thomasmo ab2f648351 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 12:50:44 +00:00

37 lines
1.2 KiB
C++

/* -*- 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);
}