diff options
Diffstat (limited to 'src/platformsupport/eglconvenience/qeglplatformintegration.cpp')
-rw-r--r-- | src/platformsupport/eglconvenience/qeglplatformintegration.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp index 7d05b54c15..09011e6e58 100644 --- a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp @@ -43,6 +43,7 @@ #include <QtPlatformSupport/private/qgenericunixservices_p.h> #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> #include <QtPlatformSupport/private/qfbvthandler_p.h> +#include <QtPlatformSupport/private/qopenglcompositorbackingstore_p.h> #if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) #include <QtPlatformSupport/private/qevdevmousemanager_p.h> @@ -50,12 +51,15 @@ #include <QtPlatformSupport/private/qevdevtouch_p.h> #endif +#if !defined(QT_NO_TSLIB) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) +#include <QtPlatformSupport/private/qtslib_p.h> +#endif + #include <QtPlatformHeaders/qeglfsfunctions.h> #include "qeglplatformintegration_p.h" #include "qeglplatformcontext_p.h" #include "qeglplatformwindow_p.h" -#include "qeglplatformbackingstore_p.h" #include "qeglplatformscreen_p.h" #include "qeglplatformcursor_p.h" @@ -84,8 +88,7 @@ QT_BEGIN_NAMESPACE */ QEGLPlatformIntegration::QEGLPlatformIntegration() - : m_screen(0), - m_display(EGL_NO_DISPLAY), + : m_display(EGL_NO_DISPLAY), m_inputContext(0), m_fontDb(new QGenericUnixFontDatabase), m_services(new QGenericUnixServices), @@ -95,9 +98,6 @@ QEGLPlatformIntegration::QEGLPlatformIntegration() QEGLPlatformIntegration::~QEGLPlatformIntegration() { - delete m_screen; - if (m_display != EGL_NO_DISPLAY) - eglTerminate(m_display); } void QEGLPlatformIntegration::initialize() @@ -110,14 +110,20 @@ void QEGLPlatformIntegration::initialize() if (!eglInitialize(m_display, &major, &minor)) qFatal("Could not initialize egl display"); - m_screen = createScreen(); - screenAdded(m_screen); - m_inputContext = QPlatformInputContextFactory::create(); m_vtHandler.reset(new QFbVtHandler); } +void QEGLPlatformIntegration::destroy() +{ + foreach (QWindow *w, qGuiApp->topLevelWindows()) + w->destroy(); + + if (m_display != EGL_NO_DISPLAY) + eglTerminate(m_display); +} + QAbstractEventDispatcher *QEGLPlatformIntegration::createEventDispatcher() const { return createUnixEventDispatcher(); @@ -135,7 +141,9 @@ QPlatformFontDatabase *QEGLPlatformIntegration::fontDatabase() const QPlatformBackingStore *QEGLPlatformIntegration::createPlatformBackingStore(QWindow *window) const { - return new QEGLPlatformBackingStore(window); + QOpenGLCompositorBackingStore *bs = new QOpenGLCompositorBackingStore(window); + static_cast<QEGLPlatformWindow *>(window->handle())->setBackingStore(bs); + return bs; } QPlatformWindow *QEGLPlatformIntegration::createPlatformWindow(QWindow *window) const @@ -150,10 +158,9 @@ QPlatformWindow *QEGLPlatformIntegration::createPlatformWindow(QWindow *window) QPlatformOpenGLContext *QEGLPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { - QEGLPlatformScreen *screen = static_cast<QEGLPlatformScreen *>(context->screen()->handle()); // If there is a "root" window into which raster and QOpenGLWidget content is // composited, all other contexts must share with its context. - QOpenGLContext *compositingContext = screen ? screen->compositingContext() : 0; + QOpenGLContext *compositingContext = QOpenGLCompositor::instance()->context(); QPlatformOpenGLContext *share = compositingContext ? compositingContext->handle() : context->shareHandle(); QVariant nativeHandle = context->nativeHandle(); QPlatformOpenGLContext *platformContext = createContext(context->format(), @@ -219,7 +226,7 @@ void *QEGLPlatformIntegration::nativeResourceForIntegration(const QByteArray &re switch (resourceType(resource)) { case EglDisplay: - result = m_screen->display(); + result = display(); break; case NativeDisplay: result = reinterpret_cast<void*>(nativeDisplay()); @@ -257,7 +264,7 @@ void *QEGLPlatformIntegration::nativeResourceForWindow(const QByteArray &resourc if (window && window->handle()) result = static_cast<QEGLPlatformScreen *>(window->handle()->screen())->display(); else - result = m_screen->display(); + result = display(); break; case EglWindow: if (window && window->handle()) @@ -345,11 +352,17 @@ void QEGLPlatformIntegration::createInputHandlers() m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this); QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this); Q_FOREACH (QScreen *screen, QGuiApplication::screens()) { - QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->handle()->cursor()); + QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(screen->handle()->cursor()); if (cursor) cursor->setMouseDeviceDiscovery(mouseMgr->deviceDiscovery()); } - new QEvdevTouchScreenHandlerThread(QString() /* spec */, this); +#ifndef QT_NO_TSLIB + const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB"); + if (useTslib) + new QTsLibMouseHandler(QLatin1String("TsLib"), QString() /* spec */); + else +#endif // QT_NO_TSLIB + new QEvdevTouchScreenHandlerThread(QString() /* spec */, this); #endif } |