summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2013-02-20 08:17:35 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-06 11:00:23 +0200
commit785edaa09d6e57aa8ab02a87ab00d9347818c615 (patch)
treed1f5dc7a6765c1d164da23dcc1b06fcffb5c150a /src
parent888bfb09da4367a2eebe41a1a086a802449d2af6 (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')
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.cpp6
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h7
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp31
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h4
4 files changed, 47 insertions, 1 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
index 6cb1f88c66..1fe8bcc11b 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
@@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE
QEglFSScreen::QEglFSScreen(EGLDisplay dpy)
: m_dpy(dpy)
+ , m_surface(0)
, m_cursor(0)
{
#ifdef QEGL_EXTRA_DEBUG
@@ -95,4 +96,9 @@ QPlatformCursor *QEglFSScreen::cursor() const
return m_cursor;
}
+void QEglFSScreen::setPrimarySurface(EGLSurface surface)
+{
+ m_surface = surface;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h
index 298a67cd3a..b04c85797f 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.h
@@ -69,9 +69,16 @@ public:
QPlatformCursor *cursor() const;
EGLDisplay display() const { return m_dpy; }
+ EGLSurface primarySurface() const { return m_surface; }
+
+protected:
+ void setPrimarySurface(EGLSurface surface);
private:
+ friend class QEglFSWindow;
+
EGLDisplay m_dpy;
+ EGLSurface m_surface;
QEglFSCursor *m_cursor;
};
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
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
index 67a64973ce..ff360962ed 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -59,9 +59,11 @@ public:
void setWindowState(Qt::WindowState state);
WId winId() const;
- EGLSurface surface() const { return m_surface; }
+ EGLSurface surface() const;
QSurfaceFormat format() const;
+ QEglFSScreen *screen() const;
+
void create();
void destroy();