History

Merge branch 'master' into multiSphereAvatar04

luiscuenca committed 7 years ago

Commit cc736492 parents 49659f0 b5a1dc5125 files · +5011 −4152Browse files

Showing the changes to interface/src/Application.cpp (1 of 125 files). Show all

Unified · Split

interface/src/Application.cpp+166−4
@@ -120,6 +120,7 @@ · 119 unmodified lines
120#include <plugins/PluginManager.h>120#include <plugins/PluginManager.h>
121#include <plugins/PluginUtils.h>121#include <plugins/PluginUtils.h>
122#include <plugins/SteamClientPlugin.h>122#include <plugins/SteamClientPlugin.h>
123#include <plugins/OculusPlatformPlugin.h>
123#include <plugins/InputConfiguration.h>124#include <plugins/InputConfiguration.h>
124#include <RecordingScriptingInterface.h>125#include <RecordingScriptingInterface.h>
125#include <render/EngineStats.h>126#include <render/EngineStats.h>
@@ -151,6 +152,7 @@ · 25 unmodified lines
151#include <trackers/EyeTracker.h>152#include <trackers/EyeTracker.h>
152#include <avatars-renderer/ScriptAvatar.h>153#include <avatars-renderer/ScriptAvatar.h>
153#include <RenderableEntityItem.h>154#include <RenderableEntityItem.h>
155#include <RenderableWebEntityItem.h>
154#include <model-networking/MaterialCache.h>156#include <model-networking/MaterialCache.h>
155#include "recording/ClipCache.h"157#include "recording/ClipCache.h"
156 158
@@ -800,7 +802,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 643 unmodified lines
800 if (auto steamClient = pluginManager->getSteamClientPlugin()) {802 if (auto steamClient = pluginManager->getSteamClientPlugin()) {
801 steamClient->init();803 steamClient->init();
802 }804 }
803
804 PROFILE_SET_THREAD_NAME("Main Thread");805 PROFILE_SET_THREAD_NAME("Main Thread");
805 806
806#if defined(Q_OS_WIN)807#if defined(Q_OS_WIN)
@@ -2321,6 +2322,76 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1514 unmodified lines
2321 return DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldOrientation() * Vectors::UP;2322 return DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldOrientation() * Vectors::UP;
2322 });2323 });
2323 2324
2325 render::entities::WebEntityRenderer::setAcquireWebSurfaceOperator([this](const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
2326 bool isTablet = url == TabletScriptingInterface::QML;
2327 if (htmlContent) {
2328 webSurface = DependencyManager::get<OffscreenQmlSurfaceCache>()->acquire(render::entities::WebEntityRenderer::QML);
2329 cachedWebSurface = true;
2330 auto rootItemLoadedFunctor = [url, webSurface] {
2331 webSurface->getRootItem()->setProperty(render::entities::WebEntityRenderer::URL_PROPERTY, url);
2332 };
2333 if (webSurface->getRootItem()) {
2334 rootItemLoadedFunctor();
2335 } else {
2336 QObject::connect(webSurface.data(), &hifi::qml::OffscreenSurface::rootContextCreated, rootItemLoadedFunctor);
2337 }
2338 } else {
2339 // FIXME: the tablet should use the OffscreenQmlSurfaceCache
2340 webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface(), [](OffscreenQmlSurface* webSurface) {
2341 AbstractViewStateInterface::instance()->sendLambdaEvent([webSurface] {
2342 // WebEngineView may run other threads (wasapi), so they must be deleted for a clean shutdown
2343 // if the application has already stopped its event loop, delete must be explicit
2344 delete webSurface;
2345 });
2346 });
2347 auto rootItemLoadedFunctor = [webSurface, url, isTablet] {
2348 Application::setupQmlSurface(webSurface->getSurfaceContext(), isTablet || url == OVERLAY_LOGIN_DIALOG.toString());
2349 };
2350 if (webSurface->getRootItem()) {
2351 rootItemLoadedFunctor();
2352 } else {
2353 QObject::connect(webSurface.data(), &hifi::qml::OffscreenSurface::rootContextCreated, rootItemLoadedFunctor);
2354 }
2355 webSurface->load(url);
2356 cachedWebSurface = false;
2357 }
2358 const uint8_t DEFAULT_MAX_FPS = 10;
2359 const uint8_t TABLET_FPS = 90;
2360 webSurface->setMaxFps(isTablet ? TABLET_FPS : DEFAULT_MAX_FPS);
2361 });
2362 render::entities::WebEntityRenderer::setReleaseWebSurfaceOperator([this](QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface, std::vector<QMetaObject::Connection>& connections) {
2363 QQuickItem* rootItem = webSurface->getRootItem();
2364
2365 // Fix for crash in QtWebEngineCore when rapidly switching domains
2366 // Call stop on the QWebEngineView before destroying OffscreenQMLSurface.
2367 if (rootItem) {
2368 // stop loading
2369 QMetaObject::invokeMethod(rootItem, "stop");
2370 }
2371
2372 webSurface->pause();
2373
2374 for (auto& connection : connections) {
2375 QObject::disconnect(connection);
2376 }
2377 connections.clear();
2378
2379 // If the web surface was fetched out of the cache, release it back into the cache
2380 if (cachedWebSurface) {
2381 // If it's going back into the cache make sure to explicitly set the URL to a blank page
2382 // in order to stop any resource consumption or audio related to the page.
2383 if (rootItem) {
2384 rootItem->setProperty("url", "about:blank");
2385 }
2386 auto offscreenCache = DependencyManager::get<OffscreenQmlSurfaceCache>();
2387 if (offscreenCache) {
2388 offscreenCache->release(render::entities::WebEntityRenderer::QML, webSurface);
2389 }
2390 cachedWebSurface = false;
2391 }
2392 webSurface.reset();
2393 });
2394
2324 // Preload Tablet sounds2395 // Preload Tablet sounds
2325 DependencyManager::get<TabletScriptingInterface>()->preloadSounds();2396 DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
2326 DependencyManager::get<Keyboard>()->createKeyboard();2397 DependencyManager::get<Keyboard>()->createKeyboard();
@@ -2347,7 +2418,6 @@ void Application::updateVerboseLogging() { · 20 unmodified lines
2347 bool enable = menu->isOptionChecked(MenuOption::VerboseLogging);2418 bool enable = menu->isOptionChecked(MenuOption::VerboseLogging);
2348 2419
2349 QString rules =2420 QString rules =
2350 "hifi.*.debug=%1\n"
2351 "hifi.*.info=%1\n"2421 "hifi.*.info=%1\n"
2352 "hifi.audio-stream.debug=false\n"2422 "hifi.audio-stream.debug=false\n"
2353 "hifi.audio-stream.info=false";2423 "hifi.audio-stream.info=false";
@@ -2674,6 +2744,7 @@ Application::~Application() { · 320 unmodified lines
2674 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {2744 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
2675 steamClient->shutdown();2745 steamClient->shutdown();
2676 }2746 }
2747
2677 DependencyManager::destroy<PluginManager>();2748 DependencyManager::destroy<PluginManager>();
2678 2749
2679 DependencyManager::destroy<CompositorHelper>(); // must be destroyed before the FramebufferCache2750 DependencyManager::destroy<CompositorHelper>(); // must be destroyed before the FramebufferCache
@@ -3029,7 +3100,7 @@ void Application::initializeUi() { · 349 unmodified lines
3029 });3100 });
3030 3101
3031 offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1);3102 offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1);
3032 offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2);3103 offscreenSurfaceCache->reserve(render::entities::WebEntityRenderer::QML, 2);
3033#endif3104#endif
3034 3105
3035 flushMenuUpdates();3106 flushMenuUpdates();
@@ -3169,6 +3240,61 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) { · 133 unmodified lines
3169#endif3240#endif
3170}3241}
3171 3242
3243void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditionalContextProperties) {
3244 surfaceContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
3245 surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
3246 surfaceContext->setContextProperty("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
3247 surfaceContext->setContextProperty("Preferences", DependencyManager::get<Preferences>().data());
3248 surfaceContext->setContextProperty("Vec3", new Vec3());
3249 surfaceContext->setContextProperty("Quat", new Quat());
3250 surfaceContext->setContextProperty("MyAvatar", DependencyManager::get<AvatarManager>()->getMyAvatar().get());
3251 surfaceContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
3252 surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
3253
3254 if (setAdditionalContextProperties) {
3255 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
3256 auto flags = tabletScriptingInterface->getFlags();
3257
3258 surfaceContext->setContextProperty("offscreenFlags", flags);
3259 surfaceContext->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
3260
3261 surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
3262 surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
3263 surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
3264
3265 surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
3266 surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
3267 surfaceContext->setContextProperty("AccountServices", AccountServicesScriptingInterface::getInstance());
3268
3269 // in Qt 5.10.0 there is already an "Audio" object in the QML context
3270 // though I failed to find it (from QtMultimedia??). So.. let it be "AudioScriptingInterface"
3271 surfaceContext->setContextProperty("AudioScriptingInterface", DependencyManager::get<AudioScriptingInterface>().data());
3272
3273 surfaceContext->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
3274 surfaceContext->setContextProperty("fileDialogHelper", new FileDialogHelper());
3275 surfaceContext->setContextProperty("ScriptDiscoveryService", DependencyManager::get<ScriptEngines>().data());
3276 surfaceContext->setContextProperty("Assets", DependencyManager::get<AssetMappingsScriptingInterface>().data());
3277 surfaceContext->setContextProperty("LODManager", DependencyManager::get<LODManager>().data());
3278 surfaceContext->setContextProperty("OctreeStats", DependencyManager::get<OctreeStatsProvider>().data());
3279 surfaceContext->setContextProperty("DCModel", DependencyManager::get<DomainConnectionModel>().data());
3280 surfaceContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance());
3281 surfaceContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
3282 surfaceContext->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance());
3283 surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
3284 surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
3285 surfaceContext->setContextProperty("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
3286 surfaceContext->setContextProperty("Render", AbstractViewStateInterface::instance()->getRenderEngine()->getConfiguration().get());
3287 surfaceContext->setContextProperty("Workload", qApp->getGameWorkload()._engine->getConfiguration().get());
3288 surfaceContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
3289 surfaceContext->setContextProperty("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
3290 surfaceContext->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data());
3291 surfaceContext->setContextProperty("Reticle", qApp->getApplicationCompositor().getReticleInterface());
3292 surfaceContext->setContextProperty("HiFiAbout", AboutUtil::getInstance());
3293 surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get<WalletScriptingInterface>().data());
3294 surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get<ResourceRequestObserver>().data());
3295 }
3296}
3297
3172void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {3298void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
3173 PROFILE_RANGE(render, __FUNCTION__);3299 PROFILE_RANGE(render, __FUNCTION__);
3174 PerformanceTimer perfTimer("updateCamera");3300 PerformanceTimer perfTimer("updateCamera");
@@ -4755,6 +4881,10 @@ void Application::idle() { · 1580 unmodified lines
4755 steamClient->runCallbacks();4881 steamClient->runCallbacks();
4756 }4882 }
4757 4883
4884 if (auto oculusPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
4885 oculusPlugin->handleOVREvents();
4886 }
4887
4758 float secondsSinceLastUpdate = (float)_lastTimeUpdated.nsecsElapsed() / NSECS_PER_MSEC / MSECS_PER_SECOND;4888 float secondsSinceLastUpdate = (float)_lastTimeUpdated.nsecsElapsed() / NSECS_PER_MSEC / MSECS_PER_SECOND;
4759 _lastTimeUpdated.start();4889 _lastTimeUpdated.start();
4760 4890
@@ -5939,6 +6069,13 @@ void Application::update(float deltaTime) { · 1178 unmodified lines
5939 6069
5940 auto userInputMapper = DependencyManager::get<UserInputMapper>();6070 auto userInputMapper = DependencyManager::get<UserInputMapper>();
5941 6071
6072 controller::HmdAvatarAlignmentType hmdAvatarAlignmentType;
6073 if (myAvatar->getHmdAvatarAlignmentType() == "eyes") {
6074 hmdAvatarAlignmentType = controller::HmdAvatarAlignmentType::Eyes;
6075 } else {
6076 hmdAvatarAlignmentType = controller::HmdAvatarAlignmentType::Head;
6077 }
6078
5942 controller::InputCalibrationData calibrationData = {6079 controller::InputCalibrationData calibrationData = {
5943 myAvatar->getSensorToWorldMatrix(),6080 myAvatar->getSensorToWorldMatrix(),
5944 createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition()),6081 createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition()),
@@ -5952,7 +6089,8 @@ void Application::update(float deltaTime) { · 7 unmodified lines
5952 myAvatar->getRightArmCalibrationMat(),6089 myAvatar->getRightArmCalibrationMat(),
5953 myAvatar->getLeftArmCalibrationMat(),6090 myAvatar->getLeftArmCalibrationMat(),
5954 myAvatar->getRightHandCalibrationMat(),6091 myAvatar->getRightHandCalibrationMat(),
5955 myAvatar->getLeftHandCalibrationMat()6092 myAvatar->getLeftHandCalibrationMat(),
6093 hmdAvatarAlignmentType
5956 };6094 };
5957 6095
5958 InputPluginPointer keyboardMousePlugin;6096 InputPluginPointer keyboardMousePlugin;
@@ -8117,7 +8255,18 @@ void Application::toggleLogDialog() { · 2158 unmodified lines
8117 return;8255 return;
8118 }8256 }
8119 if (! _logDialog) {8257 if (! _logDialog) {
8258
8259 bool keepOnTop =_keepLogWindowOnTop.get();
8260#ifdef Q_OS_WIN
8261 _logDialog = new LogDialog(keepOnTop ? qApp->getWindow() : nullptr, getLogger());
8262#else
8120 _logDialog = new LogDialog(nullptr, getLogger());8263 _logDialog = new LogDialog(nullptr, getLogger());
8264
8265 if (keepOnTop) {
8266 Qt::WindowFlags flags = _logDialog->windowFlags() | Qt::Tool;
8267 _logDialog->setWindowFlags(flags);
8268 }
8269#endif
8121 }8270 }
8122 8271
8123 if (_logDialog->isVisible()) {8272 if (_logDialog->isVisible()) {
@@ -8127,6 +8276,19 @@ void Application::toggleLogDialog() { · 3 unmodified lines
8127 }8276 }
8128}8277}
8129 8278
8279 void Application::recreateLogWindow(int keepOnTop) {
8280 _keepLogWindowOnTop.set(keepOnTop != 0);
8281 if (_logDialog) {
8282 bool toggle = _logDialog->isVisible();
8283 _logDialog->close();
8284 _logDialog = nullptr;
8285
8286 if (toggle) {
8287 toggleLogDialog();
8288 }
8289 }
8290 }
8291
8130void Application::toggleEntityScriptServerLogDialog() {8292void Application::toggleEntityScriptServerLogDialog() {
8131 if (! _entityScriptServerLogDialog) {8293 if (! _entityScriptServerLogDialog) {
8132 _entityScriptServerLogDialog = new EntityScriptServerLogDialog(nullptr);8294 _entityScriptServerLogDialog = new EntityScriptServerLogDialog(nullptr);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t