EGLFS: Add support for multiple displays

Change-Id: Id039e0ed2d99562eb2a5cfe1e7b34013c75ff3ac
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
Louai Al-Khanji 2014-09-18 14:36:16 +03:00
parent 7069ebd1f6
commit 97f119af14
9 changed files with 574 additions and 350 deletions

View File

@ -84,8 +84,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,7 +94,6 @@ QEGLPlatformIntegration::QEGLPlatformIntegration()
QEGLPlatformIntegration::~QEGLPlatformIntegration()
{
}
void QEGLPlatformIntegration::initialize()
@ -108,9 +106,6 @@ 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);
@ -121,8 +116,6 @@ void QEGLPlatformIntegration::destroy()
foreach (QWindow *w, qGuiApp->topLevelWindows())
w->destroy();
delete m_screen;
if (m_display != EGL_NO_DISPLAY)
eglTerminate(m_display);
}
@ -228,7 +221,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());
@ -266,7 +259,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())

View File

@ -52,7 +52,6 @@
QT_BEGIN_NAMESPACE
class QEGLPlatformScreen;
class QEGLPlatformWindow;
class QEGLPlatformContext;
class QFbVtHandler;
@ -67,7 +66,6 @@ public:
void initialize() Q_DECL_OVERRIDE;
void destroy() Q_DECL_OVERRIDE;
QEGLPlatformScreen *screen() const { return m_screen; }
EGLDisplay display() const { return m_display; }
QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
@ -93,7 +91,6 @@ public:
QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
protected:
virtual QEGLPlatformScreen *createScreen() const = 0;
virtual QEGLPlatformWindow *createWindow(QWindow *window) const = 0;
virtual QEGLPlatformContext *createContext(const QSurfaceFormat &format,
QPlatformOpenGLContext *shareContext,
@ -110,7 +107,6 @@ protected:
private:
static void loadKeymapStatic(const QString &filename);
QEGLPlatformScreen *m_screen;
EGLDisplay m_display;
QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformFontDatabase> m_fontDb;

View File

@ -94,9 +94,9 @@ void QEglFSContext::swapBuffers(QPlatformSurface *surface)
cursor->paintOnScreen();
}
QEglFSHooks::hooks()->waitForVSync();
QEglFSHooks::hooks()->waitForVSync(surface);
QEGLPlatformContext::swapBuffers(surface);
QEglFSHooks::hooks()->presentBuffer();
QEglFSHooks::hooks()->presentBuffer(surface);
}
QT_END_NAMESPACE

View File

@ -43,6 +43,8 @@
QT_BEGIN_NAMESPACE
class QEglFSScreen;
class QEglFSIntegration;
class QPlatformSurface;
class QEglFSHooks
{
@ -51,6 +53,8 @@ public:
virtual void platformInit();
virtual void platformDestroy();
virtual EGLNativeDisplayType platformDisplay() const;
virtual void screenInit();
virtual void screenDestroy();
virtual QSizeF physicalScreenSize() const;
virtual QSize screenSize() const;
virtual QDpi logicalDpi() const;
@ -67,8 +71,8 @@ public:
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
virtual QPlatformCursor *createCursor(QPlatformScreen *screen) const;
virtual bool filterConfig(EGLDisplay display, EGLConfig config) const;
virtual void waitForVSync() const;
virtual void presentBuffer();
virtual void waitForVSync(QPlatformSurface *surface) const;
virtual void presentBuffer(QPlatformSurface *surface);
virtual QByteArray fbDeviceName() const;
virtual int framebufferIndex() const;

File diff suppressed because it is too large Load Diff

View File

@ -32,9 +32,13 @@
****************************************************************************/
#include "qeglfshooks.h"
#include "qeglfsintegration.h"
#include "qeglfsscreen.h"
#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtCore/QRegularExpression>
#include <QtGui/private/qguiapplication_p.h>
#if defined(Q_OS_LINUX)
#include <fcntl.h>
@ -94,6 +98,18 @@ EGLNativeDisplayType QEglFSHooks::platformDisplay() const
return EGL_DEFAULT_DISPLAY;
}
void QEglFSHooks::screenInit()
{
QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
integration->addScreen(new QEglFSScreen(integration->display()));
}
void QEglFSHooks::screenDestroy()
{
while (!qApp->screens().isEmpty())
delete qApp->screens().last()->handle();
}
QSizeF QEglFSHooks::physicalScreenSize() const
{
return q_physicalScreenSizeFromFb(framebuffer, screenSize());
@ -184,8 +200,10 @@ QPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const
return new QEGLPlatformCursor(screen);
}
void QEglFSHooks::waitForVSync() const
void QEglFSHooks::waitForVSync(QPlatformSurface *surface) const
{
Q_UNUSED(surface);
#if defined(FBIO_WAITFORVSYNC)
static const bool forceSync = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCEVSYNC");
if (forceSync && framebuffer != -1) {
@ -196,8 +214,9 @@ void QEglFSHooks::waitForVSync() const
#endif
}
void QEglFSHooks::presentBuffer()
void QEglFSHooks::presentBuffer(QPlatformSurface *surface)
{
Q_UNUSED(surface);
}
bool QEglFSHooks::supportsPBuffers() const

View File

@ -77,6 +77,11 @@ bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) cons
return QEGLPlatformIntegration::hasCapability(cap);
}
void QEglFSIntegration::addScreen(QPlatformScreen *screen)
{
screenAdded(screen);
}
void QEglFSIntegration::initialize()
{
QEglFSHooks::hooks()->platformInit();
@ -85,10 +90,13 @@ void QEglFSIntegration::initialize()
if (!mDisableInputHandlers)
createInputHandlers();
QEglFSHooks::hooks()->screenInit();
}
void QEglFSIntegration::destroy()
{
QEglFSHooks::hooks()->screenDestroy();
QEGLPlatformIntegration::destroy();
QEglFSHooks::hooks()->platformDestroy();
}
@ -98,11 +106,6 @@ EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const
return QEglFSHooks::hooks()->platformDisplay();
}
QEGLPlatformScreen *QEglFSIntegration::createScreen() const
{
return new QEglFSScreen(display());
}
QEGLPlatformWindow *QEglFSIntegration::createWindow(QWindow *window) const
{
return new QEglFSWindow(window);
@ -138,17 +141,6 @@ QPlatformOffscreenSurface *QEglFSIntegration::createOffscreenSurface(EGLDisplay
// Never return null. Multiple QWindows are not supported by this plugin.
}
QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
{
switch (hint)
{
case QPlatformIntegration::ShowIsFullScreen:
return screen()->compositingWindow() == 0;
default:
return QPlatformIntegration::styleHint(hint);
}
}
EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
{
class Chooser : public QEglConfigChooser {

View File

@ -45,16 +45,16 @@ class QEglFSIntegration : public QEGLPlatformIntegration
public:
QEglFSIntegration();
void addScreen(QPlatformScreen *screen);
void initialize() Q_DECL_OVERRIDE;
void destroy() Q_DECL_OVERRIDE;
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
QVariant styleHint(QPlatformIntegration::StyleHint hint) const Q_DECL_OVERRIDE;
static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
protected:
QEGLPlatformScreen *createScreen() const Q_DECL_OVERRIDE;
QEGLPlatformWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
QEGLPlatformContext *createContext(const QSurfaceFormat &format,
QPlatformOpenGLContext *shareContext,

View File

@ -147,8 +147,9 @@ void QEglFSWindow::invalidateSurface()
void QEglFSWindow::resetSurface()
{
EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display();
m_window = QEglFSHooks::hooks()->createNativeWindow(this, QEglFSHooks::hooks()->screenSize(), m_format);
QEglFSScreen *nativeScreen = static_cast<QEglFSScreen *>(screen());
EGLDisplay display = nativeScreen->display();
m_window = QEglFSHooks::hooks()->createNativeWindow(this, nativeScreen->geometry().size(), m_format);
m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL);
if (m_surface == EGL_NO_SURFACE) {
EGLint error = eglGetError();