summaryrefslogtreecommitdiffstats
path: root/src/opengl/qwindowsurface_gl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qwindowsurface_gl.cpp')
-rw-r--r--src/opengl/qwindowsurface_gl.cpp67
1 files changed, 51 insertions, 16 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 0bffbda..21b2f09 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
{
@@ -316,7 +334,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
QGLWindowSurface::QGLWindowSurface(QWidget *window)
: QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
{
- Q_ASSERT(window->isTopLevel());
+// Q_ASSERT(window->isTopLevel());
d_ptr->pb = 0;
d_ptr->fbo = 0;
d_ptr->ctx = 0;
@@ -339,11 +357,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;
delete d_ptr;
@@ -359,17 +378,19 @@ 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 **ctxPtr; void **voidPtr; };
- voidPtr = &widgetPrivate->extraData()->glContext;
- int index = d_ptr->contexts.indexOf(ctxPtr);
+ union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
+ voidPtrPtr = &widgetPrivate->extraData()->glContext;
+ int index = d_ptr->contexts.indexOf(ctxPtrPtr);
if (index != -1) {
- delete *ctxPtr;
- *ctxPtr = 0;
+ delete *ctxPtrPtr;
+ *ctxPtrPtr = 0;
d_ptr->contexts.removeAt(index);
}
}
+#endif
}
}
@@ -392,7 +413,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
} else
ctx = new QGLContext(surfaceFormat, widget);
- ctx->create(qt_gl_share_widget()->context());
+ ctx->create(qt_gl_share_context());
#ifndef QT_NO_EGL
static bool checkedForNOKSwapRegion = false;
@@ -411,16 +432,18 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
setPartialUpdateSupport(false); // Force full-screen updates
else
setPartialUpdateSupport(true);
+#else
+ setPartialUpdateSupport(false);
#endif
widgetPrivate->extraData()->glContext = ctx;
- union { QGLContext **ctxPtr; void **voidPtr; };
+ union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(deleted(QObject*)));
- voidPtr = &widgetPrivate->extraData()->glContext;
- d_ptr->contexts << ctxPtr;
+ voidPtrPtr = &widgetPrivate->extraData()->glContext;
+ d_ptr->contexts << ctxPtrPtr;
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
}
@@ -450,6 +473,8 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize,
void QGLWindowSurface::beginPaint(const QRegion &)
{
+ d_ptr->did_paint = true;
+
if (!context())
return;
@@ -464,8 +489,6 @@ void QGLWindowSurface::beginPaint(const QRegion &)
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(clearFlags);
}
-
- d_ptr->did_paint = true;
}
void QGLWindowSurface::endPaint(const QRegion &rgn)
@@ -529,8 +552,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
Q_ASSERT(parent);
+#if !defined(Q_WS_QPA)
if (!geometry().isValid())
return;
+#else
+ if (!size().isValid())
+ return;
+#endif
// Needed to support native child-widgets...
hijackWindow(parent);
@@ -764,12 +792,19 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
}
+#if !defined(Q_WS_QPA)
void QGLWindowSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
d_ptr->geometry_updated = true;
}
-
+#else
+void QGLWindowSurface::resize(const QSize &size)
+{
+ QWindowSurface::resize(size);
+ d_ptr->geometry_updated = true;
+}
+#endif
void QGLWindowSurface::updateGeometry() {
if (!d_ptr->geometry_updated)
@@ -861,7 +896,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;
@@ -900,7 +935,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();