diff options
author | Samuel Rødal <samuel.rodal@digia.com> | 2013-02-20 08:17:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-06 11:00:23 +0200 |
commit | 785edaa09d6e57aa8ab02a87ab00d9347818c615 (patch) | |
tree | d1f5dc7a6765c1d164da23dcc1b06fcffb5c150a /src/plugins/platforms/eglfs/qeglfswindow.cpp | |
parent | 888bfb09da4367a2eebe41a1a086a802449d2af6 (diff) |
Made EGLFS handle multiple surfaces with more grace.
Prevents crashing when some menu or similar is shown, although the
visual result might not be ideal.
Task-number: QTBUG-29729
Change-Id: Ia840b3ec17f5ef30ee58150bd2f807ca5e72cc12
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfswindow.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfswindow.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 98c54e0ee0..1cc252d285 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -42,6 +42,8 @@ #include "qeglfswindow.h" #include "qeglfshooks.h" #include <qpa/qwindowsysteminterface.h> +#include <qpa/qplatformintegration.h> +#include <private/qguiapplication_p.h> #include <QtPlatformSupport/private/qeglconvenience_p.h> @@ -66,6 +68,11 @@ QEglFSWindow::~QEglFSWindow() destroy(); } +static inline bool supportsMultipleWindows() +{ + return QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MultipleWindows); +} + void QEglFSWindow::create() { if (m_window) @@ -80,6 +87,9 @@ void QEglFSWindow::create() return; } + if (!supportsMultipleWindows() && screen()->primarySurface()) + return; + EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display(); QSurfaceFormat platformFormat = QEglFSHooks::hooks()->surfaceFormatFor(window()->requestedFormat()); m_config = QEglFSIntegration::chooseConfig(display, platformFormat); @@ -104,11 +114,14 @@ void QEglFSWindow::resetSurface() m_window = QEglFSHooks::hooks()->createNativeWindow(QEglFSHooks::hooks()->screenSize(), m_format); m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL); + if (m_surface == EGL_NO_SURFACE) { EGLint error = eglGetError(); eglTerminate(display); qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error); } + + screen()->setPrimarySurface(m_surface); } void QEglFSWindow::destroy() @@ -116,6 +129,12 @@ void QEglFSWindow::destroy() if (m_surface) { EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display(); eglDestroySurface(display, m_surface); + + if (!supportsMultipleWindows()) { + // ours must be the primary surface + screen()->setPrimarySurface(0); + } + m_surface = 0; } @@ -144,9 +163,21 @@ WId QEglFSWindow::winId() const return m_winid; } +EGLSurface QEglFSWindow::surface() const +{ + if (!supportsMultipleWindows()) + return screen()->primarySurface(); + return m_surface; +} + QSurfaceFormat QEglFSWindow::format() const { return m_format; } +QEglFSScreen *QEglFSWindow::screen() const +{ + return static_cast<QEglFSScreen *>(QPlatformWindow::screen()); +} + QT_END_NAMESPACE |