Showing the changes to interface/src/Application.cpp (1 of 17 files). Show all
Unified · Split
| @@ -144,6 +144,7 @@ · 143 unmodified lines | |||
| 144 | #include <trackers/EyeTracker.h> | 144 | #include <trackers/EyeTracker.h> |
| 145 | #include <avatars-renderer/ScriptAvatar.h> | 145 | #include <avatars-renderer/ScriptAvatar.h> |
| 146 | #include <RenderableEntityItem.h> | 146 | #include <RenderableEntityItem.h> |
| 147 | #include <procedural/ProceduralSkybox.h> | ||
| 147 | 148 | ||
| 148 | #include "AudioClient.h" | 149 | #include "AudioClient.h" |
| 149 | #include "audio/AudioScope.h" | 150 | #include "audio/AudioScope.h" |
| @@ -375,7 +376,7 @@ Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTRE · 225 unmodified lines | |||
| 375 | static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com"; | 376 | static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com"; |
| 376 | static const int INTERVAL_TO_CHECK_HMD_WORN_STATUS = 500; // milliseconds | 377 | static const int INTERVAL_TO_CHECK_HMD_WORN_STATUS = 500; // milliseconds |
| 377 | static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop"; | 378 | static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop"; |
| 378 | 379 | static const QString ACTIVE_DISPLAY_PLUGIN_SETTING_NAME = "activeDisplayPlugin"; | |
| 379 | static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system"; | 380 | static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system"; |
| 380 | 381 | ||
| 381 | const std::vector<std::pair<QString, Application::AcceptURLMethod>> Application::_acceptedExtensions { | 382 | const std::vector<std::pair<QString, Application::AcceptURLMethod>> Application::_acceptedExtensions { |
| @@ -1352,10 +1353,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 970 unmodified lines | |||
| 1352 | QCoreApplication::processEvents(); | 1353 | QCoreApplication::processEvents(); |
| 1353 | _glWidget->createContext(); | 1354 | _glWidget->createContext(); |
| 1354 | 1355 | ||
| 1355 | // Create the main thread context, the GPU backend, and the display plugins | 1356 | // Create the main thread context, the GPU backend |
| 1356 | initializeGL(); | 1357 | initializeGL(); |
| 1357 | DependencyManager::get<TextureCache>()->setGPUContext(_gpuContext); | 1358 | qCDebug(interfaceapp, "Initialized GL"); |
| 1358 | qCDebug(interfaceapp, "Initialized Display."); | 1359 | |
| 1360 | // Initialize the display plugin architecture | ||
| 1361 | initializeDisplayPlugins(); | ||
| 1362 | qCDebug(interfaceapp, "Initialized Display"); | ||
| 1363 | |||
| 1359 | // Create the rendering engine. This can be slow on some machines due to lots of | 1364 | // Create the rendering engine. This can be slow on some machines due to lots of |
| 1360 | // GPU pipeline creation. | 1365 | // GPU pipeline creation. |
| 1361 | initializeRenderEngine(); | 1366 | initializeRenderEngine(); |
| @@ -2256,8 +2261,11 @@ void Application::updateVerboseLogging() { · 894 unmodified lines | |||
| 2256 | } | 2261 | } |
| 2257 | bool enable = menu->isOptionChecked(MenuOption::VerboseLogging); | 2262 | bool enable = menu->isOptionChecked(MenuOption::VerboseLogging); |
| 2258 | 2263 | ||
| 2259 | QString rules = "*.debug=%1\n" | 2264 | QString rules = |
| 2260 | "*.info=%1"; | 2265 | "hifi.*.debug=%1\n" |
| 2266 | "hifi.*.info=%1\n" | ||
| 2267 | "hifi.audio-stream.debug=false\n" | ||
| 2268 | "hifi.audio-stream.info=false"; | ||
| 2261 | rules = rules.arg(enable ? "true" : "false"); | 2269 | rules = rules.arg(enable ? "true" : "false"); |
| 2262 | QLoggingCategory::setFilterRules(rules); | 2270 | QLoggingCategory::setFilterRules(rules); |
| 2263 | } | 2271 | } |
| @@ -2372,6 +2380,10 @@ void Application::onAboutToQuit() { · 108 unmodified lines | |||
| 2372 | } | 2380 | } |
| 2373 | } | 2381 | } |
| 2374 | 2382 | ||
| 2383 | // The active display plugin needs to be loaded before the menu system is active, | ||
| 2384 | // so its persisted explicitly here | ||
| 2385 | Setting::Handle<QString>{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME }.set(getActiveDisplayPlugin()->getName()); | ||
| 2386 | |||
| 2375 | getActiveDisplayPlugin()->deactivate(); | 2387 | getActiveDisplayPlugin()->deactivate(); |
| 2376 | if (_autoSwitchDisplayModeSupportedHMDPlugin | 2388 | if (_autoSwitchDisplayModeSupportedHMDPlugin |
| 2377 | && _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) { | 2389 | && _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) { |
| @@ -2611,10 +2623,84 @@ void Application::initializeGL() { · 233 unmodified lines | |||
| 2611 | _glWidget->makeCurrent(); | 2623 | _glWidget->makeCurrent(); |
| 2612 | _gpuContext = std::make_shared<gpu::Context>(); | 2624 | _gpuContext = std::make_shared<gpu::Context>(); |
| 2613 | 2625 | ||
| 2626 | DependencyManager::get<TextureCache>()->setGPUContext(_gpuContext); | ||
| 2627 | |||
| 2614 | // Restore the default main thread context | 2628 | // Restore the default main thread context |
| 2615 | _offscreenContext->makeCurrent(); | 2629 | _offscreenContext->makeCurrent(); |
| 2630 | } | ||
| 2631 | |||
| 2632 | static const QString SPLASH_SKYBOX{ "{\"ProceduralEntity\":{ \"version\":2, \"shaderUrl\":\"qrc:///shaders/splashSkybox.frag\" } }" }; | ||
| 2633 | |||
| 2634 | void Application::initializeDisplayPlugins() { | ||
| 2635 | auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); | ||
| 2636 | Setting::Handle<QString> activeDisplayPluginSetting{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME, displayPlugins.at(0)->getName() }; | ||
| 2637 | auto lastActiveDisplayPluginName = activeDisplayPluginSetting.get(); | ||
| 2638 | |||
| 2639 | auto defaultDisplayPlugin = displayPlugins.at(0); | ||
| 2640 | // Once time initialization code | ||
| 2641 | DisplayPluginPointer targetDisplayPlugin; | ||
| 2642 | foreach(auto displayPlugin, displayPlugins) { | ||
| 2643 | displayPlugin->setContext(_gpuContext); | ||
| 2644 | if (displayPlugin->getName() == lastActiveDisplayPluginName) { | ||
| 2645 | targetDisplayPlugin = displayPlugin; | ||
| 2646 | } | ||
| 2647 | QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, | ||
| 2648 | [this](const QSize& size) { resizeGL(); }); | ||
| 2649 | QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset); | ||
| 2650 | } | ||
| 2651 | |||
| 2652 | // The default display plugin needs to be activated first, otherwise the display plugin thread | ||
| 2653 | // may be launched by an external plugin, which is bad | ||
| 2654 | setDisplayPlugin(defaultDisplayPlugin); | ||
| 2655 | |||
| 2656 | // Now set the desired plugin if it's not the same as the default plugin | ||
| 2657 | if (targetDisplayPlugin != defaultDisplayPlugin) { | ||
| 2658 | setDisplayPlugin(targetDisplayPlugin); | ||
| 2659 | } | ||
| 2660 | |||
| 2661 | // Submit a default frame to render until the engine starts up | ||
| 2662 | updateRenderArgs(0.0f); | ||
| 2663 | |||
| 2664 | _offscreenContext->makeCurrent(); | ||
| 2616 | 2665 | ||
| 2617 | updateDisplayMode(); | 2666 | #define ENABLE_SPLASH_FRAME 0 |
| 2667 | #if ENABLE_SPLASH_FRAME | ||
| 2668 | { | ||
| 2669 | QMutexLocker viewLocker(&_renderArgsMutex); | ||
| 2670 | |||
| 2671 | if (_appRenderArgs._isStereo) { | ||
| 2672 | _gpuContext->enableStereo(true); | ||
| 2673 | _gpuContext->setStereoProjections(_appRenderArgs._eyeProjections); | ||
| 2674 | _gpuContext->setStereoViews(_appRenderArgs._eyeOffsets); | ||
| 2675 | } | ||
| 2676 | |||
| 2677 | // Frame resources | ||
| 2678 | auto framebufferCache = DependencyManager::get<FramebufferCache>(); | ||
| 2679 | gpu::FramebufferPointer finalFramebuffer = framebufferCache->getFramebuffer(); | ||
| 2680 | std::shared_ptr<ProceduralSkybox> procedural = std::make_shared<ProceduralSkybox>(); | ||
| 2681 | procedural->parse(SPLASH_SKYBOX); | ||
| 2682 | |||
| 2683 | _gpuContext->beginFrame(_appRenderArgs._view, _appRenderArgs._headPose); | ||
| 2684 | gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) { | ||
| 2685 | batch.resetStages(); | ||
| 2686 | batch.enableStereo(false); | ||
| 2687 | batch.setFramebuffer(finalFramebuffer); | ||
| 2688 | batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, { 0, 0, 0, 1 }); | ||
| 2689 | batch.enableSkybox(true); | ||
| 2690 | batch.enableStereo(_appRenderArgs._isStereo); | ||
| 2691 | batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); | ||
| 2692 | procedural->render(batch, _appRenderArgs._renderArgs.getViewFrustum()); | ||
| 2693 | }); | ||
| 2694 | auto frame = _gpuContext->endFrame(); | ||
| 2695 | frame->frameIndex = 0; | ||
| 2696 | frame->framebuffer = finalFramebuffer; | ||
| 2697 | frame->pose = _appRenderArgs._headPose; | ||
| 2698 | frame->framebufferRecycler = [framebufferCache, procedural](const gpu::FramebufferPointer& framebuffer) { | ||
| 2699 | framebufferCache->releaseFramebuffer(framebuffer); | ||
| 2700 | }; | ||
| 2701 | _displayPlugin->submitFrame(frame); | ||
| 2702 | } | ||
| 2703 | #endif | ||
| 2618 | } | 2704 | } |
| 2619 | 2705 | ||
| 2620 | void Application::initializeRenderEngine() { | 2706 | void Application::initializeRenderEngine() { |
| @@ -2638,6 +2724,7 @@ void Application::initializeRenderEngine() { · 17 unmodified lines | |||
| 2638 | } | 2724 | } |
| 2639 | 2725 | ||
| 2640 | extern void setupPreferences(); | 2726 | extern void setupPreferences(); |
| 2727 | static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, bool active); | ||
| 2641 | 2728 | ||
| 2642 | void Application::initializeUi() { | 2729 | void Application::initializeUi() { |
| 2643 | // Build a shared canvas / context for the Chromium processes | 2730 | // Build a shared canvas / context for the Chromium processes |
| @@ -2779,10 +2866,25 @@ void Application::initializeUi() { · 135 unmodified lines | |||
| 2779 | offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1); | 2866 | offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1); |
| 2780 | offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2); | 2867 | offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2); |
| 2781 | 2868 | ||
| 2782 | // Now that the menu is instantiated, ensure the display plugin menu is properly updated | ||
| 2783 | updateDisplayMode(); | ||
| 2784 | flushMenuUpdates(); | 2869 | flushMenuUpdates(); |
| 2785 | 2870 | ||
| 2871 | // Now that the menu is instantiated, ensure the display plugin menu is properly updated | ||
| 2872 | { | ||
| 2873 | auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); | ||
| 2874 | // first sort the plugins into groupings: standard, advanced, developer | ||
| 2875 | std::stable_sort(displayPlugins.begin(), displayPlugins.end(), | ||
| 2876 | [](const DisplayPluginPointer& a, const DisplayPluginPointer& b)->bool { return a->getGrouping() < b->getGrouping(); }); | ||
| 2877 | |||
| 2878 | // concatenate the groupings into a single list in the order: standard, advanced, developer | ||
| 2879 | for(const auto& displayPlugin : displayPlugins) { | ||
| 2880 | addDisplayPluginToMenu(displayPlugin, _displayPlugin == displayPlugin); | ||
| 2881 | } | ||
| 2882 | |||
| 2883 | // after all plugins have been added to the menu, add a separator to the menu | ||
| 2884 | auto parent = getPrimaryMenu()->getMenu(MenuOption::OutputMenu); | ||
| 2885 | parent->addSeparator(); | ||
| 2886 | } | ||
| 2887 | |||
| 2786 | // The display plugins are created before the menu now, so we need to do this here to hide the menu bar | 2888 | // The display plugins are created before the menu now, so we need to do this here to hide the menu bar |
| 2787 | // now that it exists | 2889 | // now that it exists |
| 2788 | if (_window && _window->isFullScreen()) { | 2890 | if (_window && _window->isFullScreen()) { |
| @@ -2933,7 +3035,7 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) { · 144 unmodified lines | |||
| 2933 | _thirdPersonHMDCameraBoomValid = false; | 3035 | _thirdPersonHMDCameraBoomValid = false; |
| 2934 | 3036 | ||
| 2935 | _myCamera.setOrientation(myAvatar->getHead()->getOrientation()); | 3037 | _myCamera.setOrientation(myAvatar->getHead()->getOrientation()); |
| 2936 | if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | 3038 | if (isOptionChecked(MenuOption::CenterPlayerInView)) { |
| 2937 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() | 3039 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() |
| 2938 | + _myCamera.getOrientation() * boomOffset); | 3040 | + _myCamera.getOrientation() * boomOffset); |
| 2939 | } | 3041 | } |
| @@ -5735,6 +5837,32 @@ void Application::update(float deltaTime) { · 2795 unmodified lines | |||
| 5735 | } | 5837 | } |
| 5736 | 5838 | ||
| 5737 | 5839 | ||
| 5840 | updateRenderArgs(deltaTime); | ||
| 5841 | |||
| 5842 | // HACK | ||
| 5843 | // load the view frustum | ||
| 5844 | // FIXME: This preDisplayRender call is temporary until we create a separate render::scene for the mirror rendering. | ||
| 5845 | // Then we can move this logic into the Avatar::simulate call. | ||
| 5846 | myAvatar->preDisplaySide(&_appRenderArgs._renderArgs); | ||
| 5847 | |||
| 5848 | |||
| 5849 | { | ||
| 5850 | PerformanceTimer perfTimer("limitless"); | ||
| 5851 | AnimDebugDraw::getInstance().update(); | ||
| 5852 | } | ||
| 5853 | |||
| 5854 | { | ||
| 5855 | PerformanceTimer perfTimer("limitless"); | ||
| 5856 | DependencyManager::get<LimitlessVoiceRecognitionScriptingInterface>()->update(); | ||
| 5857 | } | ||
| 5858 | |||
| 5859 | { // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over | ||
| 5860 | PerformanceTimer perfTimer("enqueueFrame"); | ||
| 5861 | getMain3DScene()->enqueueFrame(); | ||
| 5862 | } | ||
| 5863 | } | ||
| 5864 | |||
| 5865 | void Application::updateRenderArgs(float deltaTime) { | ||
| 5738 | editRenderArgs([this, deltaTime](AppRenderArgs& appRenderArgs) { | 5866 | editRenderArgs([this, deltaTime](AppRenderArgs& appRenderArgs) { |
| 5739 | PerformanceTimer perfTimer("editRenderArgs"); | 5867 | PerformanceTimer perfTimer("editRenderArgs"); |
| 5740 | appRenderArgs._headPose = getHMDSensorPose(); | 5868 | appRenderArgs._headPose = getHMDSensorPose(); |
| @@ -5758,9 +5886,9 @@ void Application::update(float deltaTime) { · 17 unmodified lines | |||
| 5758 | QMutexLocker viewLocker(&_viewMutex); | 5886 | QMutexLocker viewLocker(&_viewMutex); |
| 5759 | // adjust near clip plane to account for sensor scaling. | 5887 | // adjust near clip plane to account for sensor scaling. |
| 5760 | auto adjustedProjection = glm::perspective(glm::radians(_fieldOfView.get()), | 5888 | auto adjustedProjection = glm::perspective(glm::radians(_fieldOfView.get()), |
| 5761 | getActiveDisplayPlugin()->getRecommendedAspectRatio(), | 5889 | getActiveDisplayPlugin()->getRecommendedAspectRatio(), |
| 5762 | DEFAULT_NEAR_CLIP * sensorToWorldScale, | 5890 | DEFAULT_NEAR_CLIP * sensorToWorldScale, |
| 5763 | DEFAULT_FAR_CLIP); | 5891 | DEFAULT_FAR_CLIP); |
| 5764 | _viewFrustum.setProjection(adjustedProjection); | 5892 | _viewFrustum.setProjection(adjustedProjection); |
| 5765 | _viewFrustum.calculate(); | 5893 | _viewFrustum.calculate(); |
| 5766 | } | 5894 | } |
| @@ -5776,8 +5904,14 @@ void Application::update(float deltaTime) { · 9 unmodified lines | |||
| 5776 | } | 5904 | } |
| 5777 | { | 5905 | { |
| 5778 | PROFILE_RANGE(render, "/resizeGL"); | 5906 | PROFILE_RANGE(render, "/resizeGL"); |
| 5779 | PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); | 5907 | bool showWarnings = false; |
| 5780 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 5908 | bool suppressShortTimings = false; |
| 5909 | auto menu = Menu::getInstance(); | ||
| 5910 | if (menu) { | ||
| 5911 | suppressShortTimings = menu->isOptionChecked(MenuOption::SuppressShortTimings); | ||
| 5912 | showWarnings = menu->isOptionChecked(MenuOption::PipelineWarnings); | ||
| 5913 | } | ||
| 5914 | PerformanceWarning::setSuppressShortTimings(suppressShortTimings); | ||
| 5781 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); | 5915 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| 5782 | resizeGL(); | 5916 | resizeGL(); |
| 5783 | } | 5917 | } |
| @@ -5833,12 +5967,6 @@ void Application::update(float deltaTime) { · 49 unmodified lines | |||
| 5833 | } | 5967 | } |
| 5834 | } | 5968 | } |
| 5835 | 5969 | ||
| 5836 | // HACK | ||
| 5837 | // load the view frustum | ||
| 5838 | // FIXME: This preDisplayRender call is temporary until we create a separate render::scene for the mirror rendering. | ||
| 5839 | // Then we can move this logic into the Avatar::simulate call. | ||
| 5840 | myAvatar->preDisplaySide(&appRenderArgs._renderArgs); | ||
| 5841 | |||
| 5842 | { | 5970 | { |
| 5843 | QMutexLocker viewLocker(&_viewMutex); | 5971 | QMutexLocker viewLocker(&_viewMutex); |
| 5844 | _myCamera.loadViewFrustum(_displayViewFrustum); | 5972 | _myCamera.loadViewFrustum(_displayViewFrustum); |
| @@ -5850,21 +5978,6 @@ void Application::update(float deltaTime) { · 5 unmodified lines | |||
| 5850 | appRenderArgs._renderArgs.setViewFrustum(_displayViewFrustum); | 5978 | appRenderArgs._renderArgs.setViewFrustum(_displayViewFrustum); |
| 5851 | } | 5979 | } |
| 5852 | }); | 5980 | }); |
| 5853 | |||
| 5854 | { | ||
| 5855 | PerformanceTimer perfTimer("limitless"); | ||
| 5856 | AnimDebugDraw::getInstance().update(); | ||
| 5857 | } | ||
| 5858 | |||
| 5859 | { | ||
| 5860 | PerformanceTimer perfTimer("limitless"); | ||
| 5861 | DependencyManager::get<LimitlessVoiceRecognitionScriptingInterface>()->update(); | ||
| 5862 | } | ||
| 5863 | |||
| 5864 | { // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over | ||
| 5865 | PerformanceTimer perfTimer("enqueueFrame"); | ||
| 5866 | getMain3DScene()->enqueueFrame(); | ||
| 5867 | } | ||
| 5868 | } | 5981 | } |
| 5869 | 5982 | ||
| 5870 | void Application::queryAvatars() { | 5983 | void Application::queryAvatars() { |
| @@ -7509,15 +7622,19 @@ void Application::shareSnapshot(const QString& path, const QUrl& href) { · 1638 unmodified lines | |||
| 7509 | } | 7622 | } |
| 7510 | 7623 | ||
| 7511 | float Application::getRenderResolutionScale() const { | 7624 | float Application::getRenderResolutionScale() const { |
| 7512 | if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) { | 7625 | auto menu = Menu::getInstance(); |
| 7626 | if (!menu) { | ||
| 7627 | return 1.0f; | ||
| 7628 | } | ||
| 7629 | if (menu->isOptionChecked(MenuOption::RenderResolutionOne)) { | ||
| 7513 | return 1.0f; | 7630 | return 1.0f; |
| 7514 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) { | 7631 | } else if (menu->isOptionChecked(MenuOption::RenderResolutionTwoThird)) { |
| 7515 | return 0.666f; | 7632 | return 0.666f; |
| 7516 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) { | 7633 | } else if (menu->isOptionChecked(MenuOption::RenderResolutionHalf)) { |
| 7517 | return 0.5f; | 7634 | return 0.5f; |
| 7518 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionThird)) { | 7635 | } else if (menu->isOptionChecked(MenuOption::RenderResolutionThird)) { |
| 7519 | return 0.333f; | 7636 | return 0.333f; |
| 7520 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) { | 7637 | } else if (menu->isOptionChecked(MenuOption::RenderResolutionQuarter)) { |
| 7521 | return 0.25f; | 7638 | return 0.25f; |
| 7522 | } else { | 7639 | } else { |
| 7523 | return 1.0f; | 7640 | return 1.0f; |
| @@ -7741,7 +7858,7 @@ DisplayPluginPointer Application::getActiveDisplayPlugin() const { · 217 unmodified lines | |||
| 7741 | 7858 | ||
| 7742 | static const char* EXCLUSION_GROUP_KEY = "exclusionGroup"; | 7859 | static const char* EXCLUSION_GROUP_KEY = "exclusionGroup"; |
| 7743 | 7860 | ||
| 7744 | static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { | 7861 | static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, bool active) { |
| 7745 | auto menu = Menu::getInstance(); | 7862 | auto menu = Menu::getInstance(); |
| 7746 | QString name = displayPlugin->getName(); | 7863 | QString name = displayPlugin->getName(); |
| 7747 | auto grouping = displayPlugin->getGrouping(); | 7864 | auto grouping = displayPlugin->getGrouping(); |
| @@ -7786,65 +7903,12 @@ void Application::updateDisplayMode() { · 38 unmodified lines | |||
| 7786 | qFatal("Attempted to switch display plugins from a non-main thread"); | 7903 | qFatal("Attempted to switch display plugins from a non-main thread"); |
| 7787 | } | 7904 | } |
| 7788 | 7905 | ||
| 7789 | auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); | ||
| 7790 | |||
| 7791 | // Once time initialization code | ||
| 7792 | static std::once_flag once; | ||
| 7793 | std::call_once(once, [&] { | ||
| 7794 | foreach(auto displayPlugin, displayPlugins) { | ||
| 7795 | displayPlugin->setContext(_gpuContext); | ||
| 7796 | QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, | ||
| 7797 | [this](const QSize& size) { resizeGL(); }); | ||
| 7798 | QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset); | ||
| 7799 | } | ||
| 7800 | }); | ||
| 7801 | |||
| 7802 | // Once time initialization code that depends on the UI being available | 7906 | // Once time initialization code that depends on the UI being available |
| 7803 | auto menu = Menu::getInstance(); | 7907 | auto displayPlugins = getDisplayPlugins(); |
| 7804 | if (menu) { | ||
| 7805 | static std::once_flag onceUi; | ||
| 7806 | std::call_once(onceUi, [&] { | ||
| 7807 | bool first = true; | ||
| 7808 | |||
| 7809 | // first sort the plugins into groupings: standard, advanced, developer | ||
| 7810 | DisplayPluginList standard; | ||
| 7811 | DisplayPluginList advanced; | ||
| 7812 | DisplayPluginList developer; | ||
| 7813 | foreach(auto displayPlugin, displayPlugins) { | ||
| 7814 | displayPlugin->setContext(_gpuContext); | ||
| 7815 | auto grouping = displayPlugin->getGrouping(); | ||
| 7816 | switch (grouping) { | ||
| 7817 | case Plugin::ADVANCED: | ||
| 7818 | advanced.push_back(displayPlugin); | ||
| 7819 | break; | ||
| 7820 | case Plugin::DEVELOPER: | ||
| 7821 | developer.push_back(displayPlugin); | ||
| 7822 | break; | ||
| 7823 | default: | ||
| 7824 | standard.push_back(displayPlugin); | ||
| 7825 | break; | ||
| 7826 | } | ||
| 7827 | } | ||
| 7828 | |||
| 7829 | // concatenate the groupings into a single list in the order: standard, advanced, developer | ||
| 7830 | standard.insert(std::end(standard), std::begin(advanced), std::end(advanced)); | ||
| 7831 | standard.insert(std::end(standard), std::begin(developer), std::end(developer)); | ||
| 7832 | |||
| 7833 | foreach(auto displayPlugin, standard) { | ||
| 7834 | addDisplayPluginToMenu(displayPlugin, first); | ||
| 7835 | first = false; | ||
| 7836 | } | ||
| 7837 | |||
| 7838 | // after all plugins have been added to the menu, add a separator to the menu | ||
| 7839 | auto parent = menu->getMenu(MenuOption::OutputMenu); | ||
| 7840 | parent->addSeparator(); | ||
| 7841 | }); | ||
| 7842 | |||
| 7843 | } | ||
| 7844 | |||
| 7845 | 7908 | ||
| 7846 | // Default to the first item on the list, in case none of the menu items match | 7909 | // Default to the first item on the list, in case none of the menu items match |
| 7847 | DisplayPluginPointer newDisplayPlugin = displayPlugins.at(0); | 7910 | DisplayPluginPointer newDisplayPlugin = displayPlugins.at(0); |
| 7911 | auto menu = getPrimaryMenu(); | ||
| 7848 | if (menu) { | 7912 | if (menu) { |
| 7849 | foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) { | 7913 | foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) { |
| 7850 | QString name = displayPlugin->getName(); | 7914 | QString name = displayPlugin->getName(); |
| @@ -7868,6 +7932,14 @@ void Application::updateDisplayMode() { · 17 unmodified lines | |||
| 7868 | } | 7932 | } |
| 7869 | 7933 | ||
| 7870 | void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) { | 7934 | void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) { |
| 7935 | if (newDisplayPlugin == _displayPlugin) { | ||
| 7936 | return; | ||
| 7937 | } | ||
| 7938 | |||
| 7939 | // FIXME don't have the application directly set the state of the UI, | ||
| 7940 | // instead emit a signal that the display plugin is changing and let | ||
| 7941 | // the desktop lock itself. Reduces coupling between the UI and display | ||
| 7942 | // plugins | ||
| 7871 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 7943 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 7872 | auto desktop = offscreenUi->getDesktop(); | 7944 | auto desktop = offscreenUi->getDesktop(); |
| 7873 | auto menu = Menu::getInstance(); | 7945 | auto menu = Menu::getInstance(); |
| @@ -7878,8 +7950,8 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) { · 4 unmodified lines | |||
| 7878 | bool wasRepositionLocked = false; | 7950 | bool wasRepositionLocked = false; |
| 7879 | if (desktop) { | 7951 | if (desktop) { |
| 7880 | // Tell the desktop to no reposition (which requires plugin info), until we have set the new plugin, below. | 7952 | // Tell the desktop to no reposition (which requires plugin info), until we have set the new plugin, below. |
| 7881 | wasRepositionLocked = offscreenUi->getDesktop()->property("repositionLocked").toBool(); | 7953 | wasRepositionLocked = desktop->property("repositionLocked").toBool(); |
| 7882 | offscreenUi->getDesktop()->setProperty("repositionLocked", true); | 7954 | desktop->setProperty("repositionLocked", true); |
| 7883 | } | 7955 | } |
| 7884 | 7956 | ||
| 7885 | if (_displayPlugin) { | 7957 | if (_displayPlugin) { |