diff options
Diffstat (limited to 'src/gui/kernel/qopenglcontext.cpp')
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 4efa5a40f3..c5d5490ea0 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -945,7 +945,7 @@ GLuint QOpenGLContext::defaultFramebufferObject() const Avoid calling this function from a different thread than the one the QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a - different thread you should first call make sure it's not current in the + different thread you should first make sure it's not current in the current thread, by calling doneCurrent() if necessary. Then call moveToThread(otherThread) before using it in the other thread. @@ -977,67 +977,66 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) if (!surface->surfaceHandle()) return false; if (!surface->supportsOpenGL()) { +#ifndef Q_OS_WASM // ### work around the WASM platform plugin using QOpenGLContext with raster surfaces. + // see QTBUG-70076 qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface; return false; +#endif } - QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this); - - if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) { - static bool needsWorkaroundSet = false; - static bool needsWorkaround = false; + if (!d->platformGLContext->makeCurrent(surface->surfaceHandle())) + return false; - if (!needsWorkaroundSet) { - QByteArray env; -#ifdef Q_OS_ANDROID - env = qgetenv(QByteArrayLiteral("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND")); - needsWorkaround = env.isEmpty() || env == QByteArrayLiteral("0") || env == QByteArrayLiteral("false"); + QOpenGLContextPrivate::setCurrentContext(this); +#ifndef QT_NO_DEBUG + QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true); #endif - env = qgetenv(QByteArrayLiteral("QT_ENABLE_GLYPH_CACHE_WORKAROUND")); - if (env == QByteArrayLiteral("1") || env == QByteArrayLiteral("true")) - needsWorkaround = true; - - if (!needsWorkaround) { - const char *rendererString = reinterpret_cast<const char *>(functions()->glGetString(GL_RENDERER)); - if (rendererString) - needsWorkaround = - qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450 - || qstrcmp(rendererString, "Mali-T880") == 0 - || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205 - || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)' - || qstrncmp(rendererString, "Adreno (TM) 3xx", 13) == 0 // Adreno 302, 305, 320, 330 - || qstrncmp(rendererString, "Adreno 3xx", 8) == 0 // Same as above but without the '(TM)' - || qstrncmp(rendererString, "Adreno (TM) 4xx", 13) == 0 // Adreno 405, 418, 420, 430 - || qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)' - || qstrncmp(rendererString, "Adreno (TM) 5xx", 13) == 0 // Adreno 505, 506, 510, 530, 540 - || qstrncmp(rendererString, "Adreno 5xx", 8) == 0 // Same as above but without the '(TM)' - || qstrncmp(rendererString, "Adreno (TM) 6xx", 13) == 0 // Adreno 610, 620, 630 - || qstrncmp(rendererString, "Adreno 6xx", 8) == 0 // Same as above but without the '(TM)' - || qstrcmp(rendererString, "GC800 core") == 0 - || qstrcmp(rendererString, "GC1000 core") == 0 - || strstr(rendererString, "GC2000") != 0 - || qstrcmp(rendererString, "Immersion.16") == 0; - } - needsWorkaroundSet = true; - } - - if (needsWorkaround) - d->workaround_brokenFBOReadBack = true; - d->surface = surface; + d->surface = surface; - d->shareGroup->d_func()->deletePendingResources(this); + static bool needsWorkaroundSet = false; + static bool needsWorkaround = false; -#ifndef QT_NO_DEBUG - QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true); + if (!needsWorkaroundSet) { + QByteArray env; +#ifdef Q_OS_ANDROID + env = qgetenv(QByteArrayLiteral("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND")); + needsWorkaround = env.isEmpty() || env == QByteArrayLiteral("0") || env == QByteArrayLiteral("false"); #endif - - return true; + env = qgetenv(QByteArrayLiteral("QT_ENABLE_GLYPH_CACHE_WORKAROUND")); + if (env == QByteArrayLiteral("1") || env == QByteArrayLiteral("true")) + needsWorkaround = true; + + if (!needsWorkaround) { + const char *rendererString = reinterpret_cast<const char *>(functions()->glGetString(GL_RENDERER)); + if (rendererString) + needsWorkaround = + qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450 + || qstrcmp(rendererString, "Mali-T880") == 0 + || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205 + || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)' + || qstrncmp(rendererString, "Adreno (TM) 3xx", 13) == 0 // Adreno 302, 305, 320, 330 + || qstrncmp(rendererString, "Adreno 3xx", 8) == 0 // Same as above but without the '(TM)' + || qstrncmp(rendererString, "Adreno (TM) 4xx", 13) == 0 // Adreno 405, 418, 420, 430 + || qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)' + || qstrncmp(rendererString, "Adreno (TM) 5xx", 13) == 0 // Adreno 505, 506, 510, 530, 540 + || qstrncmp(rendererString, "Adreno 5xx", 8) == 0 // Same as above but without the '(TM)' + || qstrncmp(rendererString, "Adreno (TM) 6xx", 13) == 0 // Adreno 610, 620, 630 + || qstrncmp(rendererString, "Adreno 6xx", 8) == 0 // Same as above but without the '(TM)' + || qstrcmp(rendererString, "GC800 core") == 0 + || qstrcmp(rendererString, "GC1000 core") == 0 + || strstr(rendererString, "GC2000") != 0 + || qstrcmp(rendererString, "Immersion.16") == 0; + } + needsWorkaroundSet = true; } - QOpenGLContextPrivate::setCurrentContext(previous); + if (needsWorkaround) + d->workaround_brokenFBOReadBack = true; + + d->shareGroup->d_func()->deletePendingResources(this); - return false; + return true; } /*! @@ -1078,7 +1077,8 @@ QSurface *QOpenGLContext::surface() const Swap the back and front buffers of \a surface. Call this to finish a frame of OpenGL rendering, and make sure to - call makeCurrent() again before you begin a new frame. + call makeCurrent() again before issuing any further OpenGL commands, + for example as part of a new frame. */ void QOpenGLContext::swapBuffers(QSurface *surface) { |