mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
rework plugins to not depend on PluginContainer unless they want to
This commit is contained in:
parent
ec87e2fe90
commit
c322317878
39 changed files with 159 additions and 192 deletions
|
@ -139,7 +139,7 @@ link_hifi_libraries(shared octree gpu gl gpu-gl procedural model render
|
|||
recording fbx networking model-networking entities avatars
|
||||
audio audio-client animation script-engine physics
|
||||
render-utils entities-renderer ui auto-updater
|
||||
controllers plugins display-plugins input-plugins steamworks-wrapper)
|
||||
controllers plugins ui-plugins display-plugins input-plugins steamworks-wrapper)
|
||||
|
||||
# include the binary directory of render-utils for shader includes
|
||||
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_BINARY_DIR}/libraries/render-utils")
|
||||
|
|
|
@ -83,7 +83,6 @@
|
|||
#include <PerfStat.h>
|
||||
#include <PhysicsEngine.h>
|
||||
#include <PhysicsHelpers.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <plugins/PluginManager.h>
|
||||
#include <RenderableWebEntityItem.h>
|
||||
#include <RenderShadowTask.h>
|
||||
|
@ -119,7 +118,6 @@
|
|||
#include "InterfaceLogging.h"
|
||||
#include "LODManager.h"
|
||||
#include "ModelPackager.h"
|
||||
#include "PluginContainerProxy.h"
|
||||
#include "scripting/AccountScriptingInterface.h"
|
||||
#include "scripting/AssetMappingsScriptingInterface.h"
|
||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||
|
@ -464,7 +462,6 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
// continuing to overburden Application.cpp
|
||||
Cube3DOverlay* _keyboardFocusHighlight{ nullptr };
|
||||
int _keyboardFocusHighlightID{ -1 };
|
||||
PluginContainer* _pluginContainer;
|
||||
|
||||
|
||||
// FIXME hack access to the internal share context for the Chromium helper
|
||||
|
@ -504,6 +501,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
|||
_maxOctreePPS(maxOctreePacketsPerSecond.get()),
|
||||
_lastFaceTrackerUpdate(0)
|
||||
{
|
||||
|
||||
|
||||
PluginContainer* pluginContainer = dynamic_cast<PluginContainer*>(this); // set the container for any plugins that care
|
||||
PluginManager::getInstance()->setContainer(pluginContainer);
|
||||
|
||||
// FIXME this may be excessively conservative. On the other hand
|
||||
// maybe I'm used to having an 8-core machine
|
||||
// Perhaps find the ideal thread count and subtract 2 or 3
|
||||
|
@ -521,7 +523,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
|||
|
||||
_entityClipboard->createRootElement();
|
||||
|
||||
_pluginContainer = new PluginContainerProxy();
|
||||
#ifdef Q_OS_WIN
|
||||
installNativeEventFilter(&MyNativeEventFilter::getInstance());
|
||||
#endif
|
||||
|
@ -2035,9 +2036,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_Return:
|
||||
if (isOption) {
|
||||
if (_window->isFullScreen()) {
|
||||
_pluginContainer->unsetFullscreen();
|
||||
unsetFullscreen();
|
||||
} else {
|
||||
_pluginContainer->setFullscreen(nullptr);
|
||||
setFullscreen(nullptr);
|
||||
}
|
||||
} else {
|
||||
Menu::getInstance()->triggerOption(MenuOption::AddressBar);
|
||||
|
@ -2951,9 +2952,10 @@ void Application::loadSettings() {
|
|||
//DependencyManager::get<LODManager>()->setAutomaticLODAdjust(false);
|
||||
|
||||
Menu::getInstance()->loadSettings();
|
||||
|
||||
// If there is a preferred plugin, we probably messed it up with the menu settings, so fix it.
|
||||
auto pluginManager = PluginManager::getInstance();
|
||||
|
||||
|
||||
auto plugins = pluginManager->getPreferredDisplayPlugins();
|
||||
for (auto plugin : plugins) {
|
||||
auto menu = Menu::getInstance();
|
||||
|
@ -5190,6 +5192,7 @@ void Application::updateDisplayMode() {
|
|||
// FIXME probably excessive and useless context switching
|
||||
_offscreenContext->makeCurrent();
|
||||
|
||||
qDebug() << "Application::updateDisplayMode()... line:" << __LINE__ << "about to call newDisplayPlugin->activate()";
|
||||
bool active = newDisplayPlugin->activate();
|
||||
|
||||
if (!active) {
|
||||
|
@ -5308,3 +5311,49 @@ void Application::showDesktop() {
|
|||
CompositorHelper& Application::getApplicationCompositor() const {
|
||||
return *DependencyManager::get<CompositorHelper>();
|
||||
}
|
||||
|
||||
|
||||
// virtual functions required for PluginContainer
|
||||
ui::Menu* Application::getPrimaryMenu() {
|
||||
auto appMenu = _window->menuBar();
|
||||
auto uiMenu = dynamic_cast<ui::Menu*>(appMenu);
|
||||
return uiMenu;
|
||||
}
|
||||
|
||||
void Application::showDisplayPluginsTools(bool show) {
|
||||
DependencyManager::get<DialogsManager>()->hmdTools(show);
|
||||
}
|
||||
|
||||
GLWidget* Application::getPrimaryWidget() {
|
||||
return _glWidget;
|
||||
}
|
||||
|
||||
MainWindow* Application::getPrimaryWindow() {
|
||||
return getWindow();
|
||||
}
|
||||
|
||||
QOpenGLContext* Application::getPrimaryContext() {
|
||||
return _glWidget->context()->contextHandle();
|
||||
}
|
||||
|
||||
bool Application::makeRenderingContextCurrent() {
|
||||
return _offscreenContext->makeCurrent();
|
||||
}
|
||||
|
||||
void Application::releaseSceneTexture(const gpu::TexturePointer& texture) {
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
auto& framebufferMap = _lockedFramebufferMap;
|
||||
Q_ASSERT(framebufferMap.contains(texture));
|
||||
auto framebufferPointer = framebufferMap[texture];
|
||||
framebufferMap.remove(texture);
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
framebufferCache->releaseFramebuffer(framebufferPointer);
|
||||
}
|
||||
|
||||
void Application::releaseOverlayTexture(const gpu::TexturePointer& texture) {
|
||||
_applicationOverlay.releaseOverlay(texture);
|
||||
}
|
||||
|
||||
bool Application::isForeground() const {
|
||||
return _isForeground && !_window->isMinimized();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <PhysicsEngine.h>
|
||||
#include <plugins/Forward.h>
|
||||
#include <plugins/DisplayPlugin.h>
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
#include <ScriptEngine.h>
|
||||
#include <ShapeManager.h>
|
||||
#include <SimpleMovingAverage.h>
|
||||
|
@ -86,14 +87,32 @@ class Application;
|
|||
#endif
|
||||
#define qApp (static_cast<Application*>(QCoreApplication::instance()))
|
||||
|
||||
class Application : public QApplication, public AbstractViewStateInterface, public AbstractScriptingServicesInterface, public AbstractUriHandler {
|
||||
class Application : public QApplication,
|
||||
public AbstractViewStateInterface,
|
||||
public AbstractScriptingServicesInterface,
|
||||
public AbstractUriHandler,
|
||||
public PluginContainer {
|
||||
Q_OBJECT
|
||||
|
||||
// TODO? Get rid of those
|
||||
friend class OctreePacketProcessor;
|
||||
friend class PluginContainerProxy;
|
||||
|
||||
public:
|
||||
|
||||
// virtual functions required for PluginContainer
|
||||
virtual ui::Menu* getPrimaryMenu() override;
|
||||
virtual void requestReset() override { resetSensors(true); }
|
||||
virtual void showDisplayPluginsTools(bool show) override;
|
||||
virtual GLWidget* getPrimaryWidget() override;
|
||||
virtual MainWindow* getPrimaryWindow() override;
|
||||
virtual QOpenGLContext* getPrimaryContext() override;
|
||||
virtual bool makeRenderingContextCurrent() override;
|
||||
virtual void releaseSceneTexture(const gpu::TexturePointer& texture) override;
|
||||
virtual void releaseOverlayTexture(const gpu::TexturePointer& texture) override;
|
||||
virtual bool isForeground() const override;
|
||||
|
||||
virtual DisplayPluginPointer getActiveDisplayPlugin() const override;
|
||||
|
||||
enum Event {
|
||||
Present = DisplayPlugin::Present,
|
||||
Paint = Present + 1,
|
||||
|
@ -163,7 +182,6 @@ public:
|
|||
|
||||
Overlays& getOverlays() { return _overlays; }
|
||||
|
||||
bool isForeground() const { return _isForeground; }
|
||||
|
||||
size_t getFrameCount() const { return _frameCount; }
|
||||
float getFps() const { return _frameCounter.rate(); }
|
||||
|
@ -185,8 +203,6 @@ public:
|
|||
|
||||
void setActiveDisplayPlugin(const QString& pluginName);
|
||||
|
||||
DisplayPluginPointer getActiveDisplayPlugin() const;
|
||||
|
||||
FileLogger* getLogger() const { return _logger; }
|
||||
|
||||
glm::vec2 getViewportDimensions() const;
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
#include "PluginContainerProxy.h"
|
||||
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
#include <plugins/Plugin.h>
|
||||
#include <plugins/PluginManager.h>
|
||||
#include <display-plugins/DisplayPlugin.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <FramebufferCache.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "MainWindow.h"
|
||||
#include "GLCanvas.h"
|
||||
#include "ui/DialogsManager.h"
|
||||
|
||||
#include <gl/OffscreenGLCanvas.h>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
|
||||
PluginContainerProxy::PluginContainerProxy() {
|
||||
}
|
||||
|
||||
PluginContainerProxy::~PluginContainerProxy() {
|
||||
}
|
||||
|
||||
ui::Menu* PluginContainerProxy::getPrimaryMenu() {
|
||||
auto appMenu = qApp->_window->menuBar();
|
||||
auto uiMenu = dynamic_cast<ui::Menu*>(appMenu);
|
||||
return uiMenu;
|
||||
}
|
||||
|
||||
bool PluginContainerProxy::isForeground() {
|
||||
return qApp->isForeground() && !qApp->getWindow()->isMinimized();
|
||||
}
|
||||
|
||||
void PluginContainerProxy::requestReset() {
|
||||
// We could signal qApp to sequence this, but it turns out that requestReset is only used from within the main thread anyway.
|
||||
qApp->resetSensors(true);
|
||||
}
|
||||
|
||||
void PluginContainerProxy::showDisplayPluginsTools(bool show) {
|
||||
DependencyManager::get<DialogsManager>()->hmdTools(show);
|
||||
}
|
||||
|
||||
GLWidget* PluginContainerProxy::getPrimaryWidget() {
|
||||
return qApp->_glWidget;
|
||||
}
|
||||
|
||||
MainWindow* PluginContainerProxy::getPrimaryWindow() {
|
||||
return qApp->getWindow();
|
||||
}
|
||||
|
||||
QOpenGLContext* PluginContainerProxy::getPrimaryContext() {
|
||||
return qApp->_glWidget->context()->contextHandle();
|
||||
}
|
||||
|
||||
const DisplayPluginPointer PluginContainerProxy::getActiveDisplayPlugin() const {
|
||||
return qApp->getActiveDisplayPlugin();
|
||||
}
|
||||
|
||||
bool PluginContainerProxy::makeRenderingContextCurrent() {
|
||||
return qApp->_offscreenContext->makeCurrent();
|
||||
}
|
||||
|
||||
void PluginContainerProxy::releaseSceneTexture(const gpu::TexturePointer& texture) {
|
||||
Q_ASSERT(QThread::currentThread() == qApp->thread());
|
||||
auto& framebufferMap = qApp->_lockedFramebufferMap;
|
||||
Q_ASSERT(framebufferMap.contains(texture));
|
||||
auto framebufferPointer = framebufferMap[texture];
|
||||
framebufferMap.remove(texture);
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
framebufferCache->releaseFramebuffer(framebufferPointer);
|
||||
}
|
||||
|
||||
void PluginContainerProxy::releaseOverlayTexture(const gpu::TexturePointer& texture) {
|
||||
qApp->_applicationOverlay.releaseOverlay(texture);
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#pragma once
|
||||
#ifndef hifi_PluginContainerProxy_h
|
||||
#define hifi_PluginContainerProxy_h
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QRect>
|
||||
|
||||
#include <plugins/Forward.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
|
||||
class QActionGroup;
|
||||
|
||||
class PluginContainerProxy : public QObject, PluginContainer {
|
||||
Q_OBJECT
|
||||
PluginContainerProxy();
|
||||
virtual ~PluginContainerProxy();
|
||||
virtual void showDisplayPluginsTools(bool show = true) override;
|
||||
virtual void requestReset() override;
|
||||
virtual bool makeRenderingContextCurrent() override;
|
||||
virtual void releaseSceneTexture(const gpu::TexturePointer& texture) override;
|
||||
virtual void releaseOverlayTexture(const gpu::TexturePointer& texture) override;
|
||||
virtual GLWidget* getPrimaryWidget() override;
|
||||
virtual MainWindow* getPrimaryWindow() override;
|
||||
virtual ui::Menu* getPrimaryMenu() override;
|
||||
virtual QOpenGLContext* getPrimaryContext() override;
|
||||
virtual bool isForeground() override;
|
||||
virtual const DisplayPluginPointer getActiveDisplayPlugin() const override;
|
||||
|
||||
friend class Application;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
set(TARGET_NAME display-plugins)
|
||||
setup_hifi_library(OpenGL)
|
||||
link_hifi_libraries(shared plugins gl gpu-gl ui)
|
||||
link_hifi_libraries(shared plugins ui-plugins gl gpu-gl ui)
|
||||
|
||||
target_opengl()
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <SettingHandle.h>
|
||||
|
||||
#include "DisplayPlugin.h"
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
|
||||
static Setting::Handle<float> IPD_SCALE_HANDLE("hmd.ipdScale", 1.0f);
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include <QtGui/QGuiApplication>
|
||||
#include <QtWidgets/QAction>
|
||||
|
||||
#include <plugins/PluginContainer.h>
|
||||
|
||||
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("Desktop");
|
||||
|
||||
static const QString FULLSCREEN = "Fullscreen";
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "NullDisplayPlugin.h"
|
||||
|
||||
#include <QtGui/QImage>
|
||||
#include <plugins/PluginContainer.h>
|
||||
|
||||
const QString NullDisplayPlugin::NAME("NullDisplayPlugin");
|
||||
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
//
|
||||
#pragma once
|
||||
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
#include "DisplayPlugin.h"
|
||||
|
||||
class NullDisplayPlugin : public DisplayPlugin {
|
||||
ACCESS_PLUGIN_CONTAINER_MIXIN
|
||||
public:
|
||||
|
||||
virtual ~NullDisplayPlugin() final {}
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
#include <NumericalConstants.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <shared/NsightHelpers.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <gl/Config.h>
|
||||
#include <gl/GLEscrow.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <CursorManager.h>
|
||||
#include "CompositorHelper.h"
|
||||
#include <ui/Menu.h>
|
||||
|
||||
|
||||
#if THREADED_PRESENT
|
||||
|
@ -202,6 +202,7 @@ private:
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
OpenGLDisplayPlugin::OpenGLDisplayPlugin() {
|
||||
_sceneTextureEscrow.setRecycler([this](const gpu::TexturePointer& texture){
|
||||
cleanupForSceneTexture(texture);
|
||||
|
@ -233,10 +234,11 @@ bool OpenGLDisplayPlugin::activate() {
|
|||
cursorData.hotSpot = vec2(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_container) {
|
||||
return false;
|
||||
}
|
||||
_vsyncSupported = _container->getPrimaryWidget()->isVsyncSupported();
|
||||
|
||||
|
||||
#if THREADED_PRESENT
|
||||
// Start the present thread if necessary
|
||||
QSharedPointer<PresentThread> presentThread;
|
||||
|
@ -272,7 +274,11 @@ bool OpenGLDisplayPlugin::activate() {
|
|||
_container->makeRenderingContextCurrent();
|
||||
#endif
|
||||
|
||||
return DisplayPlugin::activate();
|
||||
if (isHmd() && (getHmdScreen() >= 0)) {
|
||||
_container->showDisplayPluginsTools();
|
||||
}
|
||||
|
||||
return Parent::activate();
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::deactivate() {
|
||||
|
@ -288,7 +294,16 @@ void OpenGLDisplayPlugin::deactivate() {
|
|||
_container->makeRenderingContextCurrent();
|
||||
#endif
|
||||
internalDeactivate();
|
||||
DisplayPlugin::deactivate();
|
||||
|
||||
_container->showDisplayPluginsTools(false);
|
||||
if (!_container->currentDisplayActions().isEmpty()) {
|
||||
auto menu = _container->getPrimaryMenu();
|
||||
foreach(auto itemInfo, _container->currentDisplayActions()) {
|
||||
menu->removeMenuItem(itemInfo.first, itemInfo.second);
|
||||
}
|
||||
_container->currentDisplayActions().clear();
|
||||
}
|
||||
Parent::deactivate();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,9 +21,14 @@
|
|||
#include <gl/GLEscrow.h>
|
||||
#include <shared/RateCounter.h>
|
||||
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
|
||||
#define THREADED_PRESENT 1
|
||||
|
||||
class OpenGLDisplayPlugin : public DisplayPlugin {
|
||||
|
||||
ACCESS_PLUGIN_CONTAINER_MIXIN
|
||||
|
||||
protected:
|
||||
using Mutex = std::mutex;
|
||||
using Lock = std::unique_lock<Mutex>;
|
||||
|
@ -135,7 +140,9 @@ protected:
|
|||
BasicFramebufferWrapperPtr _compositeFramebuffer;
|
||||
bool _lockCurrentTexture { false };
|
||||
|
||||
|
||||
private:
|
||||
using Parent = DisplayPlugin;
|
||||
ProgramPtr _activeProgram;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <QtWidgets/QWidget>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <CursorManager.h>
|
||||
#include <gl/GLWidget.h>
|
||||
#include <shared/NsightHelpers.h>
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "../OpenGLDisplayPlugin.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
class HmdDisplayPlugin : public OpenGLDisplayPlugin {
|
||||
using Parent = OpenGLDisplayPlugin;
|
||||
public:
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "SideBySideStereoDisplayPlugin.h"
|
||||
#include <GLMHelpers.h>
|
||||
#include <CursorManager.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <gl/GLWidget.h>
|
||||
#include "../CompositorHelper.h"
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include <ViewFrustum.h>
|
||||
#include <MatrixStack.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <gl/GLWidget.h>
|
||||
#include <CursorManager.h>
|
||||
#include "../CompositorHelper.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set(TARGET_NAME input-plugins)
|
||||
setup_hifi_library()
|
||||
link_hifi_libraries(shared plugins controllers)
|
||||
link_hifi_libraries(shared plugins ui-plugins controllers)
|
||||
|
||||
GroupSources("src/input-plugins")
|
||||
|
|
|
@ -1,28 +1,6 @@
|
|||
#include "DisplayPlugin.h"
|
||||
|
||||
#include <NumericalConstants.h>
|
||||
#include <ui/Menu.h>
|
||||
|
||||
#include "PluginContainer.h"
|
||||
|
||||
bool DisplayPlugin::activate() {
|
||||
if (isHmd() && (getHmdScreen() >= 0)) {
|
||||
_container->showDisplayPluginsTools();
|
||||
}
|
||||
return Parent::activate();
|
||||
}
|
||||
|
||||
void DisplayPlugin::deactivate() {
|
||||
_container->showDisplayPluginsTools(false);
|
||||
if (!_container->currentDisplayActions().isEmpty()) {
|
||||
auto menu = _container->getPrimaryMenu();
|
||||
foreach(auto itemInfo, _container->currentDisplayActions()) {
|
||||
menu->removeMenuItem(itemInfo.first, itemInfo.second);
|
||||
}
|
||||
_container->currentDisplayActions().clear();
|
||||
}
|
||||
Parent::deactivate();
|
||||
}
|
||||
|
||||
int64_t DisplayPlugin::getPaintDelayUsecs() const {
|
||||
std::lock_guard<std::mutex> lock(_paintDelayMutex);
|
||||
|
|
|
@ -64,8 +64,6 @@ public:
|
|||
Present = QEvent::User + 1
|
||||
};
|
||||
|
||||
bool activate() override;
|
||||
void deactivate() override;
|
||||
virtual bool isHmd() const { return false; }
|
||||
virtual int getHmdScreen() const { return -1; }
|
||||
/// By default, all HMDs are stereo
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
|
||||
QString Plugin::UNKNOWN_PLUGIN_ID("unknown");
|
||||
|
||||
void Plugin::setContainer(PluginContainer* container) {
|
||||
_container = container;
|
||||
}
|
||||
|
||||
bool Plugin::isSupported() const { return true; }
|
||||
|
||||
void Plugin::init() {}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "Forward.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
class Plugin : public QObject {
|
||||
public:
|
||||
/// \return human-readable name
|
||||
|
@ -28,8 +30,11 @@ public:
|
|||
virtual const QString& getID() const { assert(false); return UNKNOWN_PLUGIN_ID; }
|
||||
|
||||
virtual bool isSupported() const;
|
||||
|
||||
void setContainer(PluginContainer* container);
|
||||
|
||||
/// Some plugins may need access to the PluginContainer, if the individual plugin
|
||||
/// needs access to this, they should override these methods and store their own
|
||||
/// type safe version of the pointer to the container.
|
||||
virtual void setContainer(void* container) { }
|
||||
|
||||
/// Called when plugin is initially loaded, typically at application start
|
||||
virtual void init();
|
||||
|
@ -65,7 +70,5 @@ public:
|
|||
|
||||
protected:
|
||||
bool _active { false };
|
||||
PluginContainer* _container { nullptr };
|
||||
static QString UNKNOWN_PLUGIN_ID;
|
||||
|
||||
};
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "RuntimePlugin.h"
|
||||
#include "DisplayPlugin.h"
|
||||
#include "InputPlugin.h"
|
||||
#include "PluginContainer.h"
|
||||
|
||||
|
||||
PluginManager* PluginManager::getInstance() {
|
||||
|
@ -133,10 +132,11 @@ const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
|||
}
|
||||
}
|
||||
}
|
||||
auto& container = PluginContainer::getInstance();
|
||||
for (auto plugin : displayPlugins) {
|
||||
plugin->setContainer(&container);
|
||||
plugin->init();
|
||||
if (_container) {
|
||||
plugin->setContainer(_container);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -171,10 +171,11 @@ const InputPluginList& PluginManager::getInputPlugins() {
|
|||
}
|
||||
}
|
||||
|
||||
auto& container = PluginContainer::getInstance();
|
||||
for (auto plugin : inputPlugins) {
|
||||
plugin->setContainer(&container);
|
||||
plugin->init();
|
||||
if (_container) {
|
||||
plugin->setContainer(_container);
|
||||
}
|
||||
}
|
||||
});
|
||||
return inputPlugins;
|
||||
|
|
|
@ -26,4 +26,7 @@ public:
|
|||
void disableDisplays(const QStringList& displays);
|
||||
void disableInputs(const QStringList& inputs);
|
||||
void saveSettings();
|
||||
void setContainer(void* container) { _container = container; }
|
||||
private:
|
||||
void* _container { nullptr };
|
||||
};
|
||||
|
|
3
libraries/ui-plugins/CMakeLists.txt
Normal file
3
libraries/ui-plugins/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
set(TARGET_NAME ui-plugins)
|
||||
setup_hifi_library(OpenGL)
|
||||
link_hifi_libraries(shared plugins ui)
|
|
@ -7,16 +7,18 @@
|
|||
//
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QRect>
|
||||
|
||||
#include "Forward.h"
|
||||
#include <plugins/Forward.h>
|
||||
|
||||
class QAction;
|
||||
class GLWidget;
|
||||
|
@ -63,8 +65,8 @@ public:
|
|||
virtual GLWidget* getPrimaryWidget() = 0;
|
||||
virtual MainWindow* getPrimaryWindow() = 0;
|
||||
virtual QOpenGLContext* getPrimaryContext() = 0;
|
||||
virtual bool isForeground() = 0;
|
||||
virtual const DisplayPluginPointer getActiveDisplayPlugin() const = 0;
|
||||
virtual bool isForeground() const = 0;
|
||||
virtual DisplayPluginPointer getActiveDisplayPlugin() const = 0;
|
||||
|
||||
/// settings interface
|
||||
bool getBoolSetting(const QString& settingName, bool defaultValue);
|
||||
|
@ -84,3 +86,12 @@ protected:
|
|||
std::map<QString, QActionGroup*> _exclusiveGroups;
|
||||
QRect _savedGeometry { 10, 120, 800, 600 };
|
||||
};
|
||||
|
||||
/// Mixin this class to your class to get easy access to the PluginContainer
|
||||
#define ACCESS_PLUGIN_CONTAINER_MIXIN \
|
||||
public: \
|
||||
virtual void setContainer(void* container) override { \
|
||||
_container = static_cast<PluginContainer*>(container); \
|
||||
} \
|
||||
protected: \
|
||||
PluginContainer* _container { nullptr };
|
|
@ -8,5 +8,5 @@
|
|||
|
||||
set(TARGET_NAME hifiSixense)
|
||||
setup_hifi_plugin(Script Qml Widgets)
|
||||
link_hifi_libraries(shared controllers ui plugins input-plugins)
|
||||
link_hifi_libraries(shared controllers ui plugins ui-plugins input-plugins)
|
||||
target_sixense()
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <NumericalConstants.h>
|
||||
#include <PathUtils.h>
|
||||
#include <PerfStat.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <controllers/InputDevice.h>
|
||||
#include <controllers/StandardControls.h>
|
||||
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
#include <plugins/InputPlugin.h>
|
||||
|
||||
struct _sixenseControllerData;
|
||||
|
@ -24,6 +25,7 @@ using SixenseControllerData = _sixenseControllerData;
|
|||
|
||||
// Handles interaction with the Sixense SDK (e.g., Razer Hydra).
|
||||
class SixenseManager : public InputPlugin {
|
||||
ACCESS_PLUGIN_CONTAINER_MIXIN
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Plugin functions
|
||||
|
|
|
@ -13,7 +13,7 @@ if (WIN32)
|
|||
|
||||
set(TARGET_NAME oculus)
|
||||
setup_hifi_plugin(Multimedia)
|
||||
link_hifi_libraries(shared gl gpu controllers ui plugins display-plugins input-plugins audio-client networking)
|
||||
link_hifi_libraries(shared gl gpu controllers ui plugins ui-plugins display-plugins input-plugins audio-client networking)
|
||||
|
||||
include_hifi_library_headers(octree)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <QtCore/QLoggingCategory>
|
||||
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
#include <controllers/UserInputMapper.h>
|
||||
#include <controllers/StandardControls.h>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ if (APPLE)
|
|||
|
||||
set(TARGET_NAME oculusLegacy)
|
||||
setup_hifi_plugin()
|
||||
link_hifi_libraries(shared gl gpu plugins ui display-plugins input-plugins)
|
||||
link_hifi_libraries(shared gl gpu plugins ui ui-plugins display-plugins input-plugins)
|
||||
|
||||
include_hifi_library_headers(octree)
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <gl/OglplusHelpers.h>
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
#include "plugins/PluginContainer.h"
|
||||
#include "OculusHelpers.h"
|
||||
|
||||
using namespace oglplus;
|
||||
|
|
|
@ -12,7 +12,7 @@ if (WIN32)
|
|||
set(TARGET_NAME openvr)
|
||||
setup_hifi_plugin(OpenGL Script Qml Widgets)
|
||||
link_hifi_libraries(shared gl networking controllers ui
|
||||
plugins display-plugins input-plugins script-engine
|
||||
plugins display-plugins ui-plugins input-plugins script-engine
|
||||
render-utils model gpu render model-networking fbx)
|
||||
|
||||
include_hifi_library_headers(octree)
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <gl/GlWindow.h>
|
||||
|
||||
#include <PerfStat.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <shared/NsightHelpers.h>
|
||||
#include "OpenVrHelpers.h"
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <gpu/Context.h>
|
||||
#include <DeferredLightingEffect.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <UserActivityLogger.h>
|
||||
|
||||
#include <controllers/UserInputMapper.h>
|
||||
|
|
|
@ -23,12 +23,14 @@
|
|||
#include <plugins/InputPlugin.h>
|
||||
#include <RenderArgs.h>
|
||||
#include <render/Scene.h>
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
|
||||
namespace vr {
|
||||
class IVRSystem;
|
||||
}
|
||||
|
||||
class ViveControllerManager : public InputPlugin {
|
||||
class ViveControllerManager : public InputPlugin {
|
||||
ACCESS_PLUGIN_CONTAINER_MIXIN
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Plugin functions
|
||||
|
|
|
@ -6,7 +6,7 @@ setup_hifi_project(Script Qml)
|
|||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared gl script-engine plugins render-utils input-plugins display-plugins controllers)
|
||||
link_hifi_libraries(shared gl script-engine plugins render-utils ui-plugins input-plugins display-plugins controllers)
|
||||
|
||||
|
||||
if (WIN32)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <QtQml/QQmlContext>
|
||||
|
||||
#include <plugins/Plugin.h>
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <ui-plugins/PluginContainer.h>
|
||||
#include <plugins/PluginManager.h>
|
||||
#include <input-plugins/InputPlugin.h>
|
||||
#include <input-plugins/KeyboardMouseDevice.h>
|
||||
|
@ -90,8 +90,8 @@ public:
|
|||
virtual MainWindow* getPrimaryWindow() override { return nullptr; }
|
||||
virtual QOpenGLContext* getPrimaryContext() override { return nullptr; }
|
||||
virtual ui::Menu* getPrimaryMenu() override { return nullptr; }
|
||||
virtual bool isForeground() override { return true; }
|
||||
virtual const DisplayPluginPointer getActiveDisplayPlugin() const override { return DisplayPluginPointer(); }
|
||||
virtual bool isForeground() const override { return true; }
|
||||
virtual DisplayPluginPointer getActiveDisplayPlugin() const override { return DisplayPluginPointer(); }
|
||||
};
|
||||
|
||||
class MyControllerScriptingInterface : public controller::ScriptingInterface {
|
||||
|
|
Loading…
Reference in a new issue