From 8f3ba6ac205e5faed7260abb60463375ab4a2f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 16 Nov 2009 17:04:37 +0100 Subject: Fixed querying of GLX extensions under X11. We always queried the client for its GLX extensions and used them blindly, even though they might not be available in the server. Also fixed the extension string check itself. We used simple sub-string search, which could potentially break if one extension name is a sub-string of another. Task-number: QTBUG-5732 Reviewed-by: Kim --- src/opengl/qgl_x11.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 899047a..a037282 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -343,8 +343,8 @@ void* qglx_getProcAddress(const char* procName) static bool triedResolvingGlxGetProcAddress = false; if (!triedResolvingGlxGetProcAddress) { triedResolvingGlxGetProcAddress = true; - QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); - if (glxExt.contains(QLatin1String("GLX_ARB_get_proc_address"))) { + QList glxExt = QByteArray(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)).split(' '); + if (glxExt.contains("GLX_ARB_get_proc_address")) { #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { @@ -523,8 +523,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (!d->gpm) return false; } - QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); - if (glxExt.contains(QLatin1String("GLX_SGI_video_sync"))) { + QList glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); + if (glxExt.contains("GLX_SGI_video_sync")) { if (d->glFormat.swapInterval() == -1) d->glFormat.setSwapInterval(0); } else { @@ -874,8 +874,9 @@ void QGLContext::swapBuffers() const static qt_glXWaitVideoSyncSGI glXWaitVideoSyncSGI = 0; static bool resolved = false; if (!resolved) { - QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); - if (glxExt.contains(QLatin1String("GLX_SGI_video_sync"))) { + const QX11Info *xinfo = qt_x11Info(d->paintDevice); + QList glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); + if (glxExt.contains("GLX_SGI_video_sync")) { glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI)qglx_getProcAddress("glXGetVideoSyncSGI"); glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI)qglx_getProcAddress("glXWaitVideoSyncSGI"); } @@ -1106,8 +1107,8 @@ void *QGLContext::getProcAddress(const QString &proc) const if (resolved && !glXGetProcAddressARB) return 0; if (!glXGetProcAddressARB) { - QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); - if (glxExt.contains(QLatin1String("GLX_ARB_get_proc_address"))) { + QList glxExt = QByteArray(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)).split(' '); + if (glxExt.contains("GLX_ARB_get_proc_address")) { #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { @@ -1594,7 +1595,7 @@ typedef void (*qt_glXReleaseTexImageEXT)(Display*, GLXDrawable, int); static qt_glXBindTexImageEXT glXBindTexImageEXT = 0; static qt_glXReleaseTexImageEXT glXReleaseTexImageEXT = 0; -bool qt_resolveTextureFromPixmap() +static bool qt_resolveTextureFromPixmap(QPaintDevice *paintDevice) { static bool resolvedTextureFromPixmap = false; @@ -1607,9 +1608,9 @@ bool qt_resolveTextureFromPixmap() { return false; // Can't use TFP without NPOT } - - QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); - if (glxExt.contains(QLatin1String("GLX_EXT_texture_from_pixmap"))) { + const QX11Info *xinfo = qt_x11Info(paintDevice); + QList glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); + if (glxExt.contains("GLX_EXT_texture_from_pixmap")) { glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT"); glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT"); } @@ -1630,7 +1631,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, con Q_ASSERT(pmd->classId() == QPixmapData::X11Class); - if (!qt_resolveTextureFromPixmap()) + if (!qt_resolveTextureFromPixmap(paintDevice)) return 0; QX11PixmapData *pixmapData = static_cast(pmd); -- cgit v0.12