From da2b3c4479e1d23ea6ead555cadc96a56967887a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 1 Sep 2014 10:43:42 +0200 Subject: Prevent current context from becoming inconsistent upon create() Platform plugins have a tendency to make the newly created native context current with a temporary surface. This is usually needed to query some information related to the new context. Afterwards most of them just reset to having nothing current. This has two issues: It unexpectedly changes the current context/surface. A call into QOpenGLContext::create() does not imply that the current context will get changed. This is the minor issue and we could probably live with it (at least if it had been documented). However, the real issue is that QOpenGLContext::currentContext() will become inconsistent: it will still report whatever was current before the create() even though on the EGL/WGL/GLX level that's not the case anymore. To prevent all this confusion the platform plugins can easily be changed to restore whatever context/surface was current before they altered it. Change-Id: I6a5b4597c86571327524ddb13e0d02538593cc7b Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 148c5d9b2f..dce8bd888c 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -249,6 +249,15 @@ void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLCon void QEGLPlatformContext::updateFormatFromGL() { #ifndef QT_NO_OPENGL + // Have to save & restore to prevent QOpenGLContext::currentContext() from becoming + // inconsistent after QOpenGLContext::create(). + EGLDisplay prevDisplay = eglGetCurrentDisplay(); + if (prevDisplay == EGL_NO_DISPLAY) // when no context is current + prevDisplay = m_eglDisplay; + EGLContext prevContext = eglGetCurrentContext(); + EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW); + EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ); + // Make the context current to ensure the GL version query works. This needs a surface too. const EGLint pbufferAttributes[] = { EGL_WIDTH, 1, @@ -300,7 +309,7 @@ void QEGLPlatformContext::updateFormatFromGL() } } } - eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext); } eglDestroySurface(m_eglDisplay, pbuffer); #endif // QT_NO_OPENGL -- cgit v1.2.3 From b366d0d0166bbb114ccf9a8e8be7d3c6c45e313e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 27 Aug 2014 10:11:22 +0200 Subject: Make the EGL platform cursor reset the array buffer Otherwise bad things happen if the application leaves a buffer bound. [ChangeLog] The eglfs mouse cursor properly resets the array buffer to prevent rendering issues. This, just like with vertex attributes and textures, requires applications to be aware of such state changes in swapBuffers(). Change-Id: I8b383cc867d8d0d0572773eacfa650e7b33b9680 Reviewed-by: Gunnar Sletta --- src/platformsupport/eglconvenience/qeglplatformcursor.cpp | 3 +++ src/platformsupport/eglconvenience/qeglplatformcursor_p.h | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp index b6293e60ec..7198d7c6fb 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp @@ -343,6 +343,8 @@ void QEGLPlatformCursor::draw(const QRectF &r) { if (!m_program) { // one time initialization + initializeOpenGLFunctions(); + createShaderPrograms(); if (!m_cursorAtlas.texture) { @@ -387,6 +389,7 @@ void QEGLPlatformCursor::draw(const QRectF &r) }; glBindTexture(GL_TEXTURE_2D, m_cursor.texture); + glBindBuffer(GL_ARRAY_BUFFER, 0); m_program->enableAttributeArray(m_vertexCoordEntry); m_program->enableAttributeArray(m_textureCoordEntry); diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h index 6f4216874a..440bcc40eb 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -86,7 +87,7 @@ private: bool m_active; }; -class QEGLPlatformCursor : public QPlatformCursor +class QEGLPlatformCursor : public QPlatformCursor, protected QOpenGLFunctions { public: QEGLPlatformCursor(QPlatformScreen *screen); @@ -113,7 +114,7 @@ private: void draw(const QRectF &rect); void update(const QRegion ®ion); void createShaderPrograms(); - static void createCursorTexture(uint *texture, const QImage &image); + void createCursorTexture(uint *texture, const QImage &image); void initCursorAtlas(); // current cursor information -- cgit v1.2.3 From 5cb21215c972e6ea406bd3e9c0461a0683edfa71 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 2 Sep 2014 15:10:29 +0200 Subject: Change a qFatal to a qWarning There are valid uses cases how to use Qt without installing any fonts (e.g. by using an application font), so let's make the warning non fatal. Task-number: QTBUG-29192 Change-Id: I5684331b687bef4b8a54be1f68303c80aa8d4372 Reviewed-by: Paul Olav Tvete Reviewed-by: Frederik Gladhorn --- src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index 26ae0eb724..75359fbaa3 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -96,8 +96,9 @@ void QBasicFontDatabase::populateFontDatabase() QString fontpath = fontDir(); if(!QFile::exists(fontpath)) { - qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?", + qWarning("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?", qPrintable(fontpath)); + return; } QDir dir(fontpath); -- cgit v1.2.3