Merge branch 'master' of https://github.com/highfidelity/hifi into punk

This commit is contained in:
Sam Gateau 2018-11-27 18:13:31 -08:00
commit 199fe2178d
15 changed files with 201 additions and 89 deletions

View file

@ -16,9 +16,9 @@ if (HIFI_MEMORY_DEBUGGING)
if (UNIX)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# for clang on Linux
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -shared-libasan -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -shared-libasan -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -shared-libasan -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
else ()
# for gcc on Linux
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fsanitize=address -U_FORTIFY_SOURCE -fno-stack-protector -fno-omit-frame-pointer")

View file

@ -927,7 +927,9 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
#endif
DependencyManager::set<DiscoverabilityManager>();
DependencyManager::set<SceneScriptingInterface>();
#if !defined(DISABLE_QML)
DependencyManager::set<OffscreenUi>();
#endif
DependencyManager::set<Midi>();
DependencyManager::set<PathUtils>();
DependencyManager::set<InterfaceDynamicFactory>();
@ -1000,6 +1002,14 @@ const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
const QString DEFAULT_CURSOR_NAME = "DEFAULT";
const bool DEFAULT_MINI_TABLET_ENABLED = true;
QSharedPointer<OffscreenUi> getOffscreenUI() {
#if !defined(DISABLE_QML)
return DependencyManager::get<OffscreenUi>();
#else
return nullptr;
#endif
}
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) :
QApplication(argc, argv),
_window(new MainWindow(desktop())),
@ -1604,7 +1614,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
auto userInputMapper = DependencyManager::get<UserInputMapper>();
connect(userInputMapper.data(), &UserInputMapper::actionEvent, [this](int action, float state) {
using namespace controller;
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
{
auto actionEnum = static_cast<Action>(action);
@ -1743,7 +1752,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
return qApp->getMyAvatar()->getCharacterController()->onGround() ? 1 : 0;
});
_applicationStateDevice->setInputVariant(STATE_NAV_FOCUSED, []() -> float {
return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0;
auto offscreenUi = getOffscreenUI();
return offscreenUi ? (offscreenUi->navigationFocused() ? 1 : 0) : 0;
});
_applicationStateDevice->setInputVariant(STATE_PLATFORM_WINDOWS, []() -> float {
#if defined(Q_OS_WIN)
@ -1809,9 +1819,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// Now that we've loaded the menu and thus switched to the previous display plugin
// we can unlock the desktop repositioning code, since all the positions will be
// relative to the desktop size for this plugin
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto offscreenUi = getOffscreenUI();
connect(offscreenUi.data(), &OffscreenUi::desktopReady, []() {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto offscreenUi = getOffscreenUI();
auto desktop = offscreenUi->getDesktop();
if (desktop) {
desktop->setProperty("repositionLocked", false);
@ -2372,6 +2382,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
AndroidHelper::instance().notifyLoadComplete();
#else
#if !defined(DISABLE_QML)
// Do not show login dialog if requested not to on the command line
const QString HIFI_NO_LOGIN_COMMAND_LINE_KEY = "--no-login-suggestion";
int index = arguments().indexOf(HIFI_NO_LOGIN_COMMAND_LINE_KEY);
@ -2396,6 +2407,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
checkLoginTimer->start();
}
#endif
#endif
}
void Application::updateVerboseLogging() {
@ -2546,7 +2558,9 @@ void Application::onAboutToQuit() {
DependencyManager::get<CloseEventSender>()->startThread();
// Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
#if !defined(DISABLE_QML)
getOffscreenUI()->hide("RunningScripts");
#endif
_aboutToQuit = true;
@ -2784,10 +2798,10 @@ void Application::initializeGL() {
_glWidget->windowHandle()->setFormat(getDefaultOpenGLSurfaceFormat());
// When loading QtWebEngineWidgets, it creates a global share context on startup.
// We have to account for this possibility by checking here for an existing
// We have to account for this possibility by checking here for an existing
// global share context
auto globalShareContext = qt_gl_global_share_context();
#if !defined(DISABLE_QML)
// Build a shared canvas / context for the Chromium processes
if (!globalShareContext) {
@ -2974,7 +2988,9 @@ void Application::initializeRenderEngine() {
}
extern void setupPreferences();
#if !defined(DISABLE_QML)
static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, int index, bool active = false);
#endif
void Application::initializeUi() {
AddressBarDialog::registerType();
@ -3024,12 +3040,13 @@ void Application::initializeUi() {
tabletScriptingInterface->getTablet(SYSTEM_TABLET);
}
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto offscreenUi = getOffscreenUI();
connect(offscreenUi.data(), &hifi::qml::OffscreenSurface::rootContextCreated,
this, &Application::onDesktopRootContextCreated);
connect(offscreenUi.data(), &hifi::qml::OffscreenSurface::rootItemCreated,
this, &Application::onDesktopRootItemCreated);
#if !defined(DISABLE_QML)
offscreenUi->setProxyWindow(_window->windowHandle());
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
// support the window management and scripting proxies for VR use
@ -3039,9 +3056,13 @@ void Application::initializeUi() {
// FIXME either expose so that dialogs can set this themselves or
// do better detection in the offscreen UI of what has focus
offscreenUi->setNavigationFocused(false);
#else
_window->setMenuBar(new Menu());
#endif
setupPreferences();
#if !defined(DISABLE_QML)
_glWidget->installEventFilter(offscreenUi.data());
offscreenUi->setMouseTranslator([=](const QPointF& pt) {
QPointF result = pt;
@ -3054,6 +3075,7 @@ void Application::initializeUi() {
return result.toPoint();
});
offscreenUi->resume();
#endif
connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){
resizeGL();
if (_touchscreenVirtualPadDevice) {
@ -3092,6 +3114,7 @@ void Application::initializeUi() {
}
});
#if !defined(DISABLE_QML)
// Pre-create a couple of Web3D overlays to speed up tablet UI
auto offscreenSurfaceCache = DependencyManager::get<OffscreenQmlSurfaceCache>();
offscreenSurfaceCache->setOnRootContextCreated([&](const QString& rootObject, QQmlContext* surfaceContext) {
@ -3105,9 +3128,11 @@ void Application::initializeUi() {
offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1);
offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2);
#endif
flushMenuUpdates();
#if !defined(DISABLE_QML)
// Now that the menu is instantiated, ensure the display plugin menu is properly updated
{
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
@ -3126,6 +3151,7 @@ void Application::initializeUi() {
auto parent = getPrimaryMenu()->getMenu(MenuOption::OutputMenu);
parent->addSeparator();
}
#endif
// The display plugins are created before the menu now, so we need to do this here to hide the menu bar
// now that it exists
@ -3230,12 +3256,12 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) {
void Application::onDesktopRootItemCreated(QQuickItem* rootItem) {
Stats::show();
AnimStats::show();
auto surfaceContext = DependencyManager::get<OffscreenUi>()->getSurfaceContext();
auto surfaceContext = getOffscreenUI()->getSurfaceContext();
surfaceContext->setContextProperty("Stats", Stats::getInstance());
surfaceContext->setContextProperty("AnimStats", AnimStats::getInstance());
#if !defined(Q_OS_ANDROID)
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto offscreenUi = getOffscreenUI();
auto qml = PathUtils::qmlUrl("AvatarInputsBar.qml");
offscreenUi->show(qml, "AvatarInputsBar");
#endif
@ -3418,7 +3444,7 @@ void Application::setPreferredCursor(const QString& cursorName) {
void Application::setSettingConstrainToolbarPosition(bool setting) {
_constrainToolbarPosition.set(setting);
DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
getOffscreenUI()->setConstrainToolbarToCenterX(setting);
}
void Application::setMiniTabletEnabled(bool enabled) {
@ -3512,7 +3538,9 @@ void Application::resizeGL() {
_myCamera.loadViewFrustum(_viewFrustum);
}
DependencyManager::get<OffscreenUi>()->resize(fromGlm(displayPlugin->getRecommendedUiSize()));
#if !defined(DISABLE_QML)
getOffscreenUI()->resize(fromGlm(displayPlugin->getRecommendedUiSize()));
#endif
}
void Application::handleSandboxStatus(QNetworkReply* reply) {
@ -3912,10 +3940,12 @@ bool Application::eventFilter(QObject* object, QEvent* event) {
}
if (event->type() == QEvent::ShortcutOverride) {
if (DependencyManager::get<OffscreenUi>()->shouldSwallowShortcut(event)) {
#if !defined(DISABLE_QML)
if (getOffscreenUI()->shouldSwallowShortcut(event)) {
event->accept();
return true;
}
#endif
// Filter out captured keys before they're used for shortcut actions.
if (_controllerScriptingInterface->isKeyCaptured(static_cast<QKeyEvent*>(event))) {
@ -3998,7 +4028,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
case Qt::Key_X:
if (isShifted && isMeta) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto offscreenUi = getOffscreenUI();
offscreenUi->togglePinned();
//offscreenUi->getSurfaceContext()->engine()->clearComponentCache();
//OffscreenUi::information("Debugging", "Component cache cleared");
@ -4014,7 +4044,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
case Qt::Key_B:
if (isMeta) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto offscreenUi = getOffscreenUI();
offscreenUi->load("Browser.qml");
} else if (isOption) {
controller::InputRecorder* inputRecorder = controller::InputRecorder::getInstance();
@ -4036,7 +4066,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
case Qt::Key_R:
if (isMeta && !event->isAutoRepeat()) {
DependencyManager::get<ScriptEngines>()->reloadAllScripts();
DependencyManager::get<OffscreenUi>()->clearCache();
getOffscreenUI()->clearCache();
}
break;
@ -4233,9 +4263,13 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
return; // bail
}
auto offscreenUi = DependencyManager::get<OffscreenUi>();
#if !defined(DISABLE_QML)
auto offscreenUi = getOffscreenUI();
auto eventPosition = compositor.getMouseEventPosition(event);
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
QPointF transformedPos = offscreenUi ? offscreenUi->mapToVirtualScreen(eventPosition) : QPointF();
#else
QPointF transformedPos;
#endif
auto button = event->button();
auto buttons = event->buttons();
// Determine if the ReticleClick Action is 1 and if so, fake include the LeftMouseButton
@ -4273,7 +4307,8 @@ void Application::mousePressEvent(QMouseEvent* event) {
// Inhibit the menu if the user is using alt-mouse dragging
_altPressed = false;
auto offscreenUi = DependencyManager::get<OffscreenUi>();
#if !defined(DISABLE_QML)
auto offscreenUi = getOffscreenUI();
// If we get a mouse press event it means it wasn't consumed by the offscreen UI,
// hence, we should defocus all of the offscreen UI windows, in order to allow
// keyboard shortcuts not to be swallowed by them. In particular, WebEngineViews
@ -4282,6 +4317,9 @@ void Application::mousePressEvent(QMouseEvent* event) {
auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
#else
QPointF transformedPos;
#endif
QMouseEvent mappedEvent(event->type(),
transformedPos,
event->screenPos(), event->button(),
@ -4318,9 +4356,13 @@ void Application::mousePressEvent(QMouseEvent* event) {
}
void Application::mouseDoublePressEvent(QMouseEvent* event) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
#if !defined(DISABLE_QML)
auto offscreenUi = getOffscreenUI();
auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
#else
QPointF transformedPos;
#endif
QMouseEvent mappedEvent(event->type(),
transformedPos,
event->screenPos(), event->button(),
@ -4341,9 +4383,13 @@ void Application::mouseDoublePressEvent(QMouseEvent* event) {
void Application::mouseReleaseEvent(QMouseEvent* event) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
#if !defined(DISABLE_QML)
auto offscreenUi = getOffscreenUI();
auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
#else
QPointF transformedPos;
#endif
QMouseEvent mappedEvent(event->type(),
transformedPos,
event->screenPos(), event->button(),
@ -4739,7 +4785,8 @@ void Application::idle() {
// Update the deadlock watchdog
updateHeartbeat();
auto offscreenUi = DependencyManager::get<OffscreenUi>();
#if !defined(DISABLE_QML)
auto offscreenUi = getOffscreenUI();
// These tasks need to be done on our first idle, because we don't want the showing of
// overlay subwindows to do a showDesktop() until after the first time through
@ -4748,6 +4795,7 @@ void Application::idle() {
firstIdle = false;
connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop);
}
#endif
#ifdef Q_OS_WIN
// If tracing is enabled then monitor the CPU in a separate thread
@ -4764,6 +4812,7 @@ void Application::idle() {
#endif
auto displayPlugin = getActiveDisplayPlugin();
#if !defined(DISABLE_QML)
if (displayPlugin) {
auto uiSize = displayPlugin->getRecommendedUiSize();
// Bit of a hack since there's no device pixel ratio change event I can find.
@ -4772,6 +4821,7 @@ void Application::idle() {
offscreenUi->resize(fromGlm(uiSize));
}
}
#endif
if (displayPlugin) {
PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate());
@ -4806,6 +4856,7 @@ void Application::idle() {
float secondsSinceLastUpdate = (float)_lastTimeUpdated.nsecsElapsed() / NSECS_PER_MSEC / MSECS_PER_SECOND;
_lastTimeUpdated.start();
#if !defined(DISABLE_QML)
// If the offscreen Ui has something active that is NOT the root, then assume it has keyboard focus.
if (offscreenUi && offscreenUi->getWindow()) {
auto activeFocusItem = offscreenUi->getWindow()->activeFocusItem();
@ -4817,9 +4868,11 @@ void Application::idle() {
_keyboardDeviceHasFocus = true;
}
}
#endif
checkChangeCursor();
#if !defined(DISABLE_QML)
auto stats = Stats::getInstance();
if (stats) {
stats->updateStats();
@ -4828,6 +4881,7 @@ void Application::idle() {
if (animStats) {
animStats->updateStats();
}
#endif
// Normally we check PipelineWarnings, but since idle will often take more than 10ms we only show these idle timing
// details if we're in ExtraDebugging mode. However, the ::update() and its subcomponents will show their timing
@ -5163,7 +5217,9 @@ QVector<EntityItemID> Application::pasteEntities(float x, float y, float z) {
void Application::init() {
// Make sure Login state is up to date
#if !defined(DISABLE_QML)
DependencyManager::get<DialogsManager>()->toggleLoginDialog();
#endif
if (!DISABLE_DEFERRED) {
DependencyManager::get<DeferredLightingEffect>()->init();
}
@ -6702,8 +6758,9 @@ void Application::nodeActivated(SharedNodePointer node) {
if (node->getType() == NodeType::AssetServer) {
// asset server just connected - check if we have the asset browser showing
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto assetDialog = offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer");
#if !defined(DISABLE_QML)
auto offscreenUi = getOffscreenUI();
auto assetDialog = offscreenUi ? offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer") : nullptr;
if (assetDialog) {
auto nodeList = DependencyManager::get<NodeList>();
@ -6716,6 +6773,7 @@ void Application::nodeActivated(SharedNodePointer node) {
assetDialog->setVisible(false);
}
}
#endif
}
// If we get a new EntityServer activated, reset lastQueried time
@ -6773,13 +6831,15 @@ void Application::nodeKilled(SharedNodePointer node) {
} else if (node->getType() == NodeType::AssetServer) {
// asset server going away - check if we have the asset browser showing
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto assetDialog = offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer");
#if !defined(DISABLE_QML)
auto offscreenUi = getOffscreenUI();
auto assetDialog = offscreenUi ? offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer") : nullptr;
if (assetDialog) {
// call reload on the shown asset browser dialog
QMetaObject::invokeMethod(assetDialog, "clear");
}
#endif
}
}
@ -6886,8 +6946,10 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
qScriptRegisterMetaType(scriptEngine.data(), RayToOverlayIntersectionResultToScriptValue,
RayToOverlayIntersectionResultFromScriptValue);
scriptEngine->registerGlobalObject("OffscreenFlags", DependencyManager::get<OffscreenUi>()->getFlags());
#if !defined(DISABLE_QML)
scriptEngine->registerGlobalObject("OffscreenFlags", getOffscreenUI()->getFlags());
scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
#endif
qScriptRegisterMetaType(scriptEngine.data(), wrapperToScriptValue<ToolbarProxy>, wrapperFromScriptValue<ToolbarProxy>);
qScriptRegisterMetaType(scriptEngine.data(),
@ -6913,14 +6975,16 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
bool clientScript = scriptEngine->isClientScript();
scriptEngine->registerFunction("OverlayWindow", clientScript ? QmlWindowClass::constructor : QmlWindowClass::restricted_constructor);
#if !defined(Q_OS_ANDROID)
#if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML)
scriptEngine->registerFunction("OverlayWebWindow", clientScript ? QmlWebWindowClass::constructor : QmlWebWindowClass::restricted_constructor);
#endif
scriptEngine->registerFunction("QmlFragment", clientScript ? QmlFragmentClass::constructor : QmlFragmentClass::restricted_constructor);
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("DesktopPreviewProvider", DependencyManager::get<DesktopPreviewProvider>().data());
#if !defined(DISABLE_QML)
scriptEngine->registerGlobalObject("Stats", Stats::getInstance());
#endif
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("Snapshot", DependencyManager::get<Snapshot>().data());
scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
@ -7116,7 +7180,7 @@ bool Application::askToSetAvatarUrl(const QString& url) {
qCDebug(interfaceapp) << "Declined to agree to avatar license";
}
//auto offscreenUi = DependencyManager::get<OffscreenUi>();
//auto offscreenUi = getOffscreenUI();
});
} else {
setAvatar(url, modelName);
@ -7314,7 +7378,9 @@ void Application::showDialog(const QUrl& widgetUrl, const QUrl& tabletUrl, const
toggleTabletUI(true);
}
} else {
DependencyManager::get<OffscreenUi>()->show(widgetUrl, name);
#if !defined(DISABLE_QML)
getOffscreenUI()->show(widgetUrl, name);
#endif
}
}
@ -7339,10 +7405,10 @@ void Application::showAssetServerWidget(QString filePath) {
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
auto hmd = DependencyManager::get<HMDScriptingInterface>();
if (tablet->getToolbarMode()) {
DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
getOffscreenUI()->show(url, "AssetServer", startUpload);
} else {
if (!hmd->getShouldShowTablet() && !isHMDMode()) {
DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
getOffscreenUI()->show(url, "AssetServer", startUpload);
} else {
static const QUrl url("hifi/dialogs/TabletAssetServer.qml");
if (!tablet->isPathLoaded(url)) {
@ -7697,7 +7763,7 @@ void Application::addAssetToWorldInfo(QString modelName, QString infoText) {
if (!_addAssetToWorldErrorTimer.isActive()) {
if (!_addAssetToWorldMessageBox) {
_addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION,
_addAssetToWorldMessageBox = getOffscreenUI()->createMessageBox(OffscreenUi::ICON_INFORMATION,
"Downloading Model", "", QMessageBox::NoButton, QMessageBox::NoButton);
connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed()));
}
@ -7780,7 +7846,7 @@ void Application::addAssetToWorldError(QString modelName, QString errorText) {
addAssetToWorldInfoClear(modelName);
if (!_addAssetToWorldMessageBox) {
_addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION,
_addAssetToWorldMessageBox = getOffscreenUI()->createMessageBox(OffscreenUi::ICON_INFORMATION,
"Downloading Model", "", QMessageBox::NoButton, QMessageBox::NoButton);
connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed()));
}
@ -8274,6 +8340,8 @@ DisplayPluginPointer Application::getActiveDisplayPlugin() const {
return _displayPlugin;
}
#if !defined(DISABLE_QML)
static const char* EXCLUSION_GROUP_KEY = "exclusionGroup";
static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, int index, bool active) {
@ -8314,6 +8382,7 @@ static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, in
action->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(displayPluginGroup));
Q_ASSERT(menu->menuItemExists(MenuOption::OutputMenu, name));
}
#endif
void Application::updateDisplayMode() {
// Unsafe to call this method from anything but the main thread
@ -8358,8 +8427,8 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) {
// instead emit a signal that the display plugin is changing and let
// the desktop lock itself. Reduces coupling between the UI and display
// plugins
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto desktop = offscreenUi->getDesktop();
auto offscreenUi = getOffscreenUI();
auto desktop = offscreenUi ? offscreenUi->getDesktop() : nullptr;
auto menu = Menu::getInstance();
// Make the switch atomic from the perspective of other threads
@ -8405,7 +8474,9 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) {
}
}
offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize()));
if (offscreenUi) {
offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize()));
}
getApplicationCompositor().setDisplayPlugin(newDisplayPlugin);
_displayPlugin = newDisplayPlugin;
connect(_displayPlugin.get(), &DisplayPlugin::presented, this, &Application::onPresent, Qt::DirectConnection);

View file

@ -156,12 +156,14 @@ void Application::paintGL() {
renderArgs._blitFramebuffer.reset();
renderArgs._context->enableStereo(false);
#if !defined(DISABLE_QML)
{
auto stats = Stats::getInstance();
if (stats) {
stats->setRenderDetails(renderArgs._details);
}
}
#endif
uint64_t lastPaintDuration = usecTimestampNow() - lastPaintBegin;
_frameTimingsScriptingInterface.addValue(lastPaintDuration);

View file

@ -48,7 +48,9 @@ void ConnectionMonitor::init() {
emit setRedirectErrorState(REDIRECT_HIFI_ADDRESS, "", 5);
} else {
qDebug() << "ConnectionMonitor: Showing connection failure window";
#if !defined(DISABLE_QML)
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(true);
#endif
}
});
}
@ -59,8 +61,10 @@ void ConnectionMonitor::startTimer() {
void ConnectionMonitor::stopTimer() {
_timer.stop();
#if !defined(DISABLE_QML)
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
if (!enableInterstitial) {
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false);
}
#endif
}

View file

@ -83,7 +83,9 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
// Now render the overlay components together into a single texture
renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
#if !defined(DISABLE_QML)
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
#endif
});
renderArgs->_batch = nullptr; // so future users of renderArgs don't try to use our batch

View file

@ -74,6 +74,7 @@ void OverlayConductor::centerUI() {
}
void OverlayConductor::update(float dt) {
#if !defined(DISABLE_QML)
auto offscreenUi = DependencyManager::get<OffscreenUi>();
if (!offscreenUi) {
return;
@ -115,4 +116,5 @@ void OverlayConductor::update(float dt) {
if (shouldRecenter && !_suppressedByHead) {
centerUI();
}
#endif
}

View file

@ -25,8 +25,10 @@ private:
bool headOutsideOverlay() const;
bool updateAvatarIsAtRest();
#if !defined(DISABLE_QML)
bool _suppressedByHead { false };
bool _hmdMode { false };
#endif
// used by updateAvatarIsAtRest
uint64_t _desiredAtRestTimer { 0 };

View file

@ -232,11 +232,15 @@ OverlayID Overlays::addOverlay(const QString& type, const QVariant& properties)
*/
if (type == ImageOverlay::TYPE) {
#if !defined(DISABLE_QML)
thisOverlay = Overlay::Pointer(new ImageOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
#endif
} else if (type == Image3DOverlay::TYPE || type == "billboard") { // "billboard" for backwards compatibility
thisOverlay = Overlay::Pointer(new Image3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
} else if (type == TextOverlay::TYPE) {
#if !defined(DISABLE_QML)
thisOverlay = Overlay::Pointer(new TextOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
#endif
} else if (type == Text3DOverlay::TYPE) {
thisOverlay = Overlay::Pointer(new Text3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
} else if (type == Shape3DOverlay::TYPE) {

View file

@ -223,8 +223,8 @@ void SunSkyStage::setSunDirection(const Vec3& direction) {
}
}
// THe sun declinaison calculus is taken from https://en.wikipedia.org/wiki/Position_of_the_Sun
double evalSunDeclinaison(double dayNumber) {
// The sun declination calculus is taken from https://en.wikipedia.org/wiki/Position_of_the_Sun
double evalSunDeclination(double dayNumber) {
return -(23.0 + 44.0/60.0)*cos(glm::radians((360.0/365.0)*(dayNumber + 10.0)));
}
@ -235,8 +235,8 @@ void SunSkyStage::updateGraphicsObject() const {
float sunLongitude = _earthSunModel.getLongitude() + (MAX_LONGITUDE * signedNormalizedDayTime);
_earthSunModel.setSunLongitude(sunLongitude);
// And update the sunLAtitude as the declinaison depending of the time of the year
_earthSunModel.setSunLatitude(evalSunDeclinaison(_yearTime));
// And update the sunLatitude as the declination depending of the time of the year
_earthSunModel.setSunLatitude(evalSunDeclination(_yearTime));
if (isSunModelEnabled()) {
Vec3d sunLightDir = -_earthSunModel.getSurfaceSunDir();

View file

@ -27,16 +27,16 @@
class Dependency {
public:
typedef std::function<void(Dependency* pointer)> DeleterFunction;
protected:
virtual ~Dependency() {}
virtual void customDeleter() {
_customDeleter(this);
}
void setCustomDeleter(DeleterFunction customDeleter) { _customDeleter = customDeleter; }
DeleterFunction _customDeleter = [](Dependency* pointer) { delete pointer; };
friend class DependencyManager;
};
@ -49,10 +49,10 @@ class DependencyManager {
public:
template<typename T>
static QSharedPointer<T> get();
template<typename T>
static bool isSet();
template<typename T, typename ...Args>
static QSharedPointer<T> set(Args&&... args);
@ -61,10 +61,10 @@ public:
template<typename T>
static void destroy();
template<typename Base, typename Derived>
static void registerInheritance();
template <typename T>
static size_t typeHash() {
#ifdef Q_OS_ANDROID
@ -79,9 +79,9 @@ private:
template<typename T>
size_t getHashCode();
QSharedPointer<Dependency>& safeGet(size_t hashCode);
QHash<size_t, QSharedPointer<Dependency>> _instanceHash;
QHash<size_t, size_t> _inheritanceHash;
};
@ -90,15 +90,17 @@ template <typename T>
QSharedPointer<T> DependencyManager::get() {
static size_t hashCode = manager().getHashCode<T>();
static QWeakPointer<T> instance;
if (instance.isNull()) {
instance = qSharedPointerCast<T>(manager().safeGet(hashCode));
#ifndef QT_NO_DEBUG
if (instance.isNull()) {
qWarning() << "DependencyManager::get(): No instance available for" << typeid(T).name();
}
#endif
}
return instance.toStrongRef();
}
@ -159,12 +161,12 @@ template<typename T>
size_t DependencyManager::getHashCode() {
size_t hashCode = typeHash<T>();
auto derivedHashCode = _inheritanceHash.find(hashCode);
while (derivedHashCode != _inheritanceHash.end()) {
hashCode = derivedHashCode.value();
derivedHashCode = _inheritanceHash.find(hashCode);
}
return hashCode;
}

View file

@ -616,7 +616,9 @@ bool OffscreenUi::navigationFocused() {
}
void OffscreenUi::setNavigationFocused(bool focused) {
offscreenFlags->setNavigationFocused(focused);
if (offscreenFlags) {
offscreenFlags->setNavigationFocused(focused);
}
}
// FIXME HACK....

View file

@ -422,9 +422,11 @@ void Menu::removeMenu(const QString& menuName) {
} else {
QMenuBar::removeAction(action);
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->removeAction(action);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->removeAction(action);
});
}
}
QMenuBar::repaint();
@ -532,9 +534,11 @@ void Menu::setGroupingIsVisible(const QString& grouping, bool isVisible) {
MenuWrapper::MenuWrapper(ui::Menu& rootMenu, QMenu* menu) : _rootMenu(rootMenu), _realMenu(menu) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addMenu(menu);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addMenu(menu);
});
}
_rootMenu._backMap[menu] = this;
}
@ -553,50 +557,62 @@ void MenuWrapper::setEnabled(bool enabled) {
QAction* MenuWrapper::addSeparator() {
QAction* action = _realMenu->addSeparator();
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addSeparator(_realMenu);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addSeparator(_realMenu);
});
}
return action;
}
void MenuWrapper::addAction(QAction* action) {
_realMenu->addAction(action);
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addAction(_realMenu, action);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addAction(_realMenu, action);
});
}
}
QAction* MenuWrapper::addAction(const QString& menuName) {
QAction* action = _realMenu->addAction(menuName);
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addAction(_realMenu, action);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addAction(_realMenu, action);
});
}
return action;
}
QAction* MenuWrapper::addAction(const QString& menuName, const QObject* receiver, const char* member, const QKeySequence& shortcut) {
QAction* action = _realMenu->addAction(menuName, receiver, member, shortcut);
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addAction(_realMenu, action);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->addAction(_realMenu, action);
});
}
return action;
}
void MenuWrapper::removeAction(QAction* action) {
_realMenu->removeAction(action);
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->removeAction(action);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->removeAction(action);
});
}
}
void MenuWrapper::insertAction(QAction* before, QAction* action) {
_realMenu->insertAction(before, action);
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->insertAction(before, action);
});
if (offscreenUi) {
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
vrMenu->insertAction(before, action);
});
}
}

View file

@ -366,6 +366,7 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
if (toolbarMode) {
#if !defined(DISABLE_QML)
// create new desktop window
auto tabletRootWindow = new TabletRootWindow();
tabletRootWindow->initQml(QVariantMap());
@ -379,6 +380,7 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
// forward qml surface events to interface js
connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
#endif
} else {
if (_currentPathLoaded != TABLET_HOME_SOURCE_URL) {
loadHomeScreen(true);

View file

@ -83,12 +83,17 @@ class VcpkgRepo:
self.sourcePortsPath = os.path.join(scriptPath, 'cmake', 'ports')
# FIXME Revert to ports hash before release
self.id = hashFolder(self.sourcePortsPath)[:8]
# OS dependent information
system = platform.system()
if args.vcpkg_root is not None:
print("override vcpkg path with " + args.vcpkg_root)
self.path = args.vcpkg_root
else:
defaultBasePath = os.path.join(tempfile.gettempdir(), 'hifi', 'vcpkg')
if 'Darwin' == system:
defaultBasePath = os.path.expanduser('~/hifi/vcpkg')
else:
defaultBasePath = os.path.join(tempfile.gettempdir(), 'hifi', 'vcpkg')
basePath = os.getenv('HIFI_VCPKG_BASE', defaultBasePath)
if (not os.path.isdir(basePath)):
os.makedirs(basePath)
@ -101,8 +106,6 @@ class VcpkgRepo:
self.tagContents = "{}_{}".format(self.id, self.version)
print("prebuild path: " + self.path)
# OS dependent information
system = platform.system()
if 'Windows' == system:
self.exe = os.path.join(self.path, 'vcpkg.exe')
self.vcpkgUrl = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/vcpkg-win32.tar.gz?versionId=YZYkDejDRk7L_hrK_WVFthWvisAhbDzZ'

View file

@ -39,9 +39,9 @@ p_hfudt.fields = {
local control_types = {
[0] = { "ACK", "Acknowledgement" },
[5] = { "Handshake", "Handshake" },
[6] = { "HandshakeACK", "Acknowledgement of Handshake" },
[8] = { "HandshakeRequest", "Request a Handshake" }
[1] = { "Handshake", "Handshake" },
[2] = { "HandshakeACK", "Acknowledgement of Handshake" },
[3] = { "HandshakeRequest", "Request a Handshake" }
}
local message_positions = {