src/opengl/qgl_x11.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
--- a/src/opengl/qgl_x11.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/opengl/qgl_x11.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -53,6 +53,7 @@
 #include <private/qfontengine_ft_p.h>
 #include <private/qt_x11_p.h>
 #include <private/qpixmap_x11_p.h>
+#include <private/qimagepixmapcleanuphooks_p.h>
 #ifdef Q_OS_HPUX
 // for GLXPBuffer
 #include <private/qglpixelbuffer_p.h>
@@ -342,8 +343,8 @@
     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"))) {
+        QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS));
+        if (extensions.match("GLX_ARB_get_proc_address")) {
 #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
             void *handle = dlopen(NULL, RTLD_LAZY);
             if (handle) {
@@ -522,8 +523,8 @@
         if (!d->gpm)
             return false;
     }
-    QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS));
-    if (glxExt.contains(QLatin1String("GLX_SGI_video_sync"))) {
+    QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
+    if (extensions.match("GLX_SGI_video_sync")) {
         if (d->glFormat.swapInterval() == -1)
             d->glFormat.setSwapInterval(0);
     } else {
@@ -629,8 +630,8 @@
     static bool useTranspExt = false;
     static bool useTranspExtChecked = false;
     if (f.plane() && !useTranspExtChecked && d->paintDevice) {
-        QByteArray estr(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
-        useTranspExt = estr.contains("GLX_EXT_visual_info");
+        QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
+        useTranspExt = extensions.match("GLX_EXT_visual_info");
         //# (A bit simplistic; that could theoretically be a substring)
         if (useTranspExt) {
             QByteArray cstr(glXGetClientString(xinfo->display(), GLX_VENDOR));
@@ -873,8 +874,9 @@
             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);
+                QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
+                if (extensions.match("GLX_SGI_video_sync")) {
                     glXGetVideoSyncSGI =  (qt_glXGetVideoSyncSGI)qglx_getProcAddress("glXGetVideoSyncSGI");
                     glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI)qglx_getProcAddress("glXWaitVideoSyncSGI");
                 }
@@ -1105,8 +1107,8 @@
     if (resolved && !glXGetProcAddressARB)
         return 0;
     if (!glXGetProcAddressARB) {
-        QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS));
-        if (glxExt.contains(QLatin1String("GLX_ARB_get_proc_address"))) {
+        QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS));
+        if (extensions.match("GLX_ARB_get_proc_address")) {
 #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
             void *handle = dlopen(NULL, RTLD_LAZY);
             if (handle) {
@@ -1593,7 +1595,7 @@
 static qt_glXBindTexImageEXT glXBindTexImageEXT = 0;
 static qt_glXReleaseTexImageEXT glXReleaseTexImageEXT = 0;
 
-bool qt_resolveTextureFromPixmap()
+static bool qt_resolveTextureFromPixmap(QPaintDevice *paintDevice)
 {
     static bool resolvedTextureFromPixmap = false;
 
@@ -1606,9 +1608,9 @@
         {
             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);
+        QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
+        if (extensions.match("GLX_EXT_texture_from_pixmap")) {
             glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT");
             glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT");
         }
@@ -1629,7 +1631,7 @@
 
     Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
 
-    if (!qt_resolveTextureFromPixmap())
+    if (!qt_resolveTextureFromPixmap(paintDevice))
         return 0;
 
     QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
@@ -1704,7 +1706,7 @@
         pixmapData->gl_surface = (Qt::HANDLE)glxPixmap;
 
         // Make sure the cleanup hook gets called so we can delete the glx pixmap
-        pixmapData->is_cached = true;
+        QImagePixmapCleanupHooks::enableCleanupHooks(pixmapData);
     }
 
     GLuint textureId;