Add glxContextForContext function to QXcbNativeInterface.
authorZeno Albisser <zeno@webkit.org>
Wed, 24 Oct 2012 14:04:15 +0000 (16:04 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 26 Oct 2012 10:09:28 +0000 (12:09 +0200)
This change enables receiving the native GLXContext object that is used
by a QOpenGLContext in case of GLX.
This clearly is non-public api that is only meant to be used as a
last resort for cases where it is really necessary to get hold of
a native context object.

Change-Id: I7f1f974f18063ed334b8034a0c0192c875c10cec
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
src/plugins/platforms/xcb/qxcbnativeinterface.cpp
src/plugins/platforms/xcb/qxcbnativeinterface.h

index 2a36fb7..fa5f5f4 100644 (file)
@@ -53,6 +53,8 @@
 
 #if defined(XCB_USE_EGL)
 #include "QtPlatformSupport/private/qeglplatformcontext_p.h"
+#elif defined (XCB_USE_GLX)
+#include "qglxintegration.h"
 #endif
 
 QT_BEGIN_NAMESPACE
@@ -68,6 +70,7 @@ public:
         insert("connection",QXcbNativeInterface::Connection);
         insert("screen",QXcbNativeInterface::Screen);
         insert("eglcontext",QXcbNativeInterface::EglContext);
+        insert("glxcontext",QXcbNativeInterface::GLXContext);
     }
 };
 
@@ -91,6 +94,9 @@ void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceSt
     case EglContext:
         result = eglContextForContext(context);
         break;
+    case GLXContext:
+        result = glxContextForContext(context);
+        break;
     default:
         break;
     }
@@ -191,4 +197,17 @@ void * QXcbNativeInterface::eglContextForContext(QOpenGLContext *context)
 #endif
 }
 
+void *QXcbNativeInterface::glxContextForContext(QOpenGLContext *context)
+{
+    Q_ASSERT(context);
+#if defined(XCB_USE_GLX)
+    QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
+    return glxPlatformContext->glxContext();
+#else
+    Q_UNUSED(context);
+    return 0;
+#endif
+
+}
+
 QT_END_NAMESPACE
index 1223fdc..c15d002 100644 (file)
@@ -58,7 +58,8 @@ public:
         Connection,
         Screen,
         GraphicsDevice,
-        EglContext
+        EglContext,
+        GLXContext
     };
 
     QXcbNativeInterface();
@@ -76,6 +77,7 @@ public:
     void *screenForWindow(QWindow *window);
     void *graphicsDeviceForWindow(QWindow *window);
     static void *eglContextForContext(QOpenGLContext *context);
+    static void *glxContextForContext(QOpenGLContext *context);
 
 private:
     const QByteArray m_genericEventFilterType;