summaryrefslogtreecommitdiff
path: root/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-03-07 17:29:24 +0100
committerJørgen Lind <jorgen.lind@nokia.com>2011-03-07 17:33:28 +0100
commitd9afcf0e84e438f89c1a8c5e26da51b06d8f61d0 (patch)
treec5f1bb28b0195b67a47ccf6ed8d007bc7af06435 /src/plugins/platforms/xcb/qxcbnativeinterface.cpp
parentcf264556fdea0d434e329e36c07a0ae6fa974f8b (diff)
downloadqt4-tools-d9afcf0e84e438f89c1a8c5e26da51b06d8f61d0.tar.gz
Lighthouse: Adding Native interface to getting the native eglcontext
in xcbplugin. I also reoredered how eglInitialize was executed, (its not so lazy anymore)
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbnativeinterface.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index f379580b03..8b6678b452 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -5,6 +5,14 @@
#include <QtGui/private/qapplication_p.h>
#include <QtCore/QMap>
+#include <QtCore/QDebug>
+
+#if defined(XCB_USE_EGL)
+#include "../eglconvenience/qeglplatformcontext.h"
+#elif defined (XCB_USE_DRI2)
+#include "qdri2context.h"
+#endif
+
class QXcbResourceMap : public QMap<QByteArray, QXcbNativeInterface::ResourceType>
{
public:
@@ -16,6 +24,7 @@ public:
insert("connection",QXcbNativeInterface::Connection);
insert("screen",QXcbNativeInterface::Screen);
insert("graphicsdevice",QXcbNativeInterface::GraphicsDevice);
+ insert("eglcontext",QXcbNativeInterface::EglContext);
}
};
@@ -42,6 +51,9 @@ void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceStr
case GraphicsDevice:
result = graphicsDeviceForWidget(widget);
break;
+ case EglContext:
+ result = eglContextForWidget(widget);
+ break;
default:
result = 0;
}
@@ -72,7 +84,7 @@ void *QXcbNativeInterface::displayForWidget(QWidget *widget)
void *QXcbNativeInterface::eglDisplayForWidget(QWidget *widget)
{
-#if defined(XCB_USE_DRI2)
+#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
QXcbScreen *screen = qPlatformScreenForWidget(widget);
return screen->connection()->egl_display();
#else
@@ -100,7 +112,33 @@ void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget)
QByteArray deviceName = screen->connection()->dri2DeviceName();
return deviceName.data();
#else
+ Q_UNUSED(widget);
return 0;
#endif
}
+
+void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
+{
+ Q_ASSERT(widget);
+ if (!widget->platformWindow()) {
+ qDebug() << "QPlatformWindow does not exist for widget" << widget
+ << "cannot return EGLContext";
+ return 0;
+ }
+ QPlatformGLContext *platformContext = widget->platformWindow()->glContext();
+ if (!platformContext) {
+ qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext"
+ << "cannot return EGLContext";
+ return 0;
+ }
+#if defined(XCB_USE_EGL)
+ QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(platformContext);
+ return eglPlatformContext->eglContext();
+#elif defined (XCB_USE_DRI2)
+ QDri2Context *dri2Context = static_cast<QDri2Context *>(platformContext);
+ return dri2Context->eglContext();
+#else
+ return 0;
+#endif
+}