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.cpp55
1 files changed, 37 insertions, 18 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 17b2044..b48fe2c 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -184,7 +184,7 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
class QGLGlobalShareWidget
{
public:
- QGLGlobalShareWidget() : refCount(0), widget(0), initializing(false) {}
+ QGLGlobalShareWidget() : widget(0), initializing(false) {}
QGLWidget *shareWidget() {
if (!initializing && !widget && !cleanedUp) {
@@ -223,7 +223,6 @@ public:
}
static bool cleanedUp;
- int refCount;
private:
QGLWidget *widget;
@@ -354,14 +353,10 @@ QGLWindowSurface::~QGLWindowSurface()
if (QGLGlobalShareWidget::cleanedUp)
return;
- --(_qt_gl_share_widget()->refCount);
-
#ifdef Q_OS_SYMBIAN
- if (_qt_gl_share_widget()->refCount <= 0) {
// Destroy the context if necessary.
if (!qt_gl_share_widget()->context()->isSharing())
qt_destroy_gl_share_widget();
- }
#endif
}
@@ -410,9 +405,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
ctx->create(qt_gl_share_widget()->context());
- if (widget != qt_gl_share_widget())
- ++(_qt_gl_share_widget()->refCount);
-
#ifndef QT_NO_EGL
static bool checkedForNOKSwapRegion = false;
static bool haveNOKSwapRegion = false;
@@ -719,6 +711,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0);
} else {
+#ifndef Q_OS_SYMBIAN // We don't have FBO pool on Symbian
// can't do sub-region blits with multisample FBOs
QGLFramebufferObject *temp = qgl_fbo_pool()->acquire(d_ptr->fbo->size(), QGLFramebufferObjectFormat());
@@ -741,6 +734,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0);
qgl_fbo_pool()->release(temp);
+#endif // Q_OS_SYMBIAN
}
ctx->d_ptr->current_fbo = 0;
@@ -823,18 +817,43 @@ void QGLWindowSurface::updateGeometry() {
if (wd->extraData() && wd->extraData()->glContext) {
#ifdef Q_OS_SYMBIAN // Symbian needs to recreate the context when native window size changes
if (d_ptr->size != geometry().size()) {
- if (window() != qt_gl_share_widget())
- --(_qt_gl_share_widget()->refCount);
+ QGLContext *ctx = reinterpret_cast<QGLContext *>(wd->extraData()->glContext);
+
+ if (ctx == QGLContext::currentContext())
+ ctx->doneCurrent();
- delete wd->extraData()->glContext;
- wd->extraData()->glContext = 0;
- d_ptr->ctx = 0;
+ ctx->d_func()->destroyEglSurfaceForDevice();
+
+ // Delete other contexts (shouldn't happen too often, if at all)
+ while (d_ptr->contexts.size()) {
+ QGLContext **ctxPtrPtr = d_ptr->contexts.takeFirst();
+ if ((*ctxPtrPtr) != ctx)
+ delete *ctxPtrPtr;
+ }
+ union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
+ voidPtrPtr = &wd->extraData()->glContext;
+ d_ptr->contexts << ctxPtrPtr;
+
+ ctx->d_func()->eglSurface = ctx->d_func()->eglContext->createSurface(window());
+
+ // Partial update supported has been decided already in previous hijackWindow call.
+ // Reset swap behaviour based on that flag.
+ if (hasPartialUpdateSupport()) {
+ eglSurfaceAttrib(QEgl::display(), ctx->d_func()->eglSurfaceForDevice(),
+ EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
+
+ if (eglGetError() != EGL_SUCCESS)
+ qWarning("QGLWindowSurface::updateGeometry() - could not re-enable preserved swap behaviour");
+ } else {
+ eglSurfaceAttrib(QEgl::display(), ctx->d_func()->eglSurfaceForDevice(),
+ EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
+
+ if (eglGetError() != EGL_SUCCESS)
+ qWarning("QGLWindowSurface::updateGeometry() - could not re-enable destroyed swap behaviour");
+ }
}
- else
#endif
- {
- hijack = false; // we already have gl context for widget
- }
+ hijack = false; // we already have gl context for widget
}
if (hijack)