summaryrefslogtreecommitdiffstats
path: root/src/opengl/qwindowsurface_gl.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2010-11-26 14:59:30 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2010-11-26 15:06:05 (GMT)
commit71abe300263d9f6bcd6e061e889a58111c48f92a (patch)
tree1d56f5244b8336de0b64e6e3131b8cedb514be6a /src/opengl/qwindowsurface_gl.cpp
parent896c51e4d41a7fee06a1601f1b25746f9f98be88 (diff)
downloadQt-71abe300263d9f6bcd6e061e889a58111c48f92a.zip
Qt-71abe300263d9f6bcd6e061e889a58111c48f92a.tar.gz
Qt-71abe300263d9f6bcd6e061e889a58111c48f92a.tar.bz2
Make QtOpenGL use shared contextexts on Lighthouse
Diffstat (limited to 'src/opengl/qwindowsurface_gl.cpp')
-rw-r--r--src/opengl/qwindowsurface_gl.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 47f36dd..cd7558c 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -182,6 +182,7 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
// QGLWindowSurface
//
+#ifndef Q_WS_QPA
class QGLGlobalShareWidget
{
public:
@@ -255,6 +256,23 @@ void qt_destroy_gl_share_widget()
{
_qt_gl_share_widget()->destroy();
}
+#endif//Q_WS_QPA
+
+const QGLContext *qt_gl_share_context()
+{
+#ifdef Q_WS_QPA
+ //make it possible to have an assesor to defaultSharedGLContext.
+ const QPlatformGLContext *platformContext = QPlatformGLContext::defaultSharedContext();
+ if (!platformContext)
+ qDebug() << "Please implement a defaultSharedContext for your platformplugin";
+ return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(platformContext));
+#else
+ QGLWidget *widget = qt_gl_share_widget();
+ if (widget)
+ return widget->context();
+ return 0;
+#endif
+}
struct QGLWindowSurfacePrivate
{
@@ -336,10 +354,12 @@ QGLWindowSurface::~QGLWindowSurface()
{
if (d_ptr->ctx)
glDeleteTextures(1, &d_ptr->tex_id);
+#ifndef Q_WS_QPA // Dont delete the contexts. Destroying the window does that for us
foreach(QGLContext **ctx, d_ptr->contexts) {
delete *ctx;
*ctx = 0;
}
+#endif
delete d_ptr->pb;
delete d_ptr->fbo;
@@ -356,6 +376,7 @@ void QGLWindowSurface::deleted(QObject *object)
d_ptr->fbo = 0;
}
+#ifndef Q_WS_QPA //no need to specifically delete the QGLContext as it will be deleted by QWidget
QWidgetPrivate *widgetPrivate = widget->d_func();
if (widgetPrivate->extraData()) {
union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
@@ -367,6 +388,7 @@ void QGLWindowSurface::deleted(QObject *object)
d_ptr->contexts.removeAt(index);
}
}
+#endif
}
}
@@ -377,8 +399,14 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
if (widgetPrivate->extraData()->glContext)
return;
+#ifdef Q_WS_QPA
+ QGLContext *ctx = QGLContext::fromPlatformGLContext(widget->platformWindow()->glContext());
+ if (!d_ptr->fbo && d_ptr->tried_fbo)
+ d_ptr->ctx = ctx;
+#else
QGLContext *ctx = new QGLContext(surfaceFormat, widget);
ctx->create(qt_gl_share_widget()->context());
+#endif
#ifndef QT_NO_EGL
static bool checkedForNOKSwapRegion = false;
@@ -816,7 +844,7 @@ void QGLWindowSurface::updateGeometry() {
}
}
-#if !defined(QT_OPENGL_ES_2)
+#if !defined(QT_OPENGL_ES_2) && !defined(Q_WS_QPA) //QPA doesn't support pixelbuffers
if (d_ptr->destructive_swap_buffers && (d_ptr->pb || !d_ptr->tried_pb)) {
d_ptr->tried_pb = true;
@@ -855,7 +883,7 @@ void QGLWindowSurface::updateGeometry() {
d_ptr->pb = 0;
}
}
-#endif // !defined(QT_OPENGL_ES_2)
+#endif // !defined(QT_OPENGL_ES_2) !defined(Q_WS_QPA)
ctx->makeCurrent();