From 93eb7c1378d97978fbe415f532e341de0138f4fe Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 15 Oct 2009 10:44:27 +1000 Subject: Back-port several OpenGL/ES fixes from 4.6 to 4.5 8ee6d090d45198fb2530849236c97f014666b7e4: fix EGL_SAMPLES b125af1b298d694c332f56deebe4755d0c985d5d: memory leak of EGLSurface's ef8d9fa7091b0d45fe15aae43b8f1c47547cb16d: double-destroy of pbuffer 73d9dced8298dfad7bc72607146e81e96fffb6d4: suppress pbuffer warnings Reviewed-by: Donald Carr --- src/opengl/qgl_egl.cpp | 2 +- src/opengl/qgl_qws.cpp | 2 ++ src/opengl/qglpixelbuffer_egl.cpp | 15 +++++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 7e91c35..348a677 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -74,7 +74,7 @@ void qt_egl_set_format(QEglProperties& props, int deviceType, const QGLFormat& f props.setValue(EGL_STENCIL_SIZE, f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize()); if (f.sampleBuffers()) { props.setValue(EGL_SAMPLE_BUFFERS, 1); - props.setValue(EGL_SAMPLES, f.samples()); + props.setValue(EGL_SAMPLES, f.samples() == -1 ? 1 : f.samples()); } else { props.setValue(EGL_SAMPLE_BUFFERS, 0); } diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index b842426..4058b66 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -187,6 +187,8 @@ void QGLContext::reset() d->cleanup(); doneCurrent(); if (d->eglContext) { + if (d->eglContext->surface() != EGL_NO_SURFACE) + eglDestroySurface(d->eglContext->display(), d->eglContext->surface()); delete d->eglContext; d->eglContext = 0; } diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp index b2f16c1..fbe6c36 100644 --- a/src/opengl/qglpixelbuffer_egl.cpp +++ b/src/opengl/qglpixelbuffer_egl.cpp @@ -152,7 +152,7 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge bool QGLPixelBufferPrivate::cleanup() { - eglDestroySurface(QEglContext::defaultDisplay(0), pbuf); + // No need to destroy "pbuf" here - it is done in QGLContext::reset(). return true; } @@ -203,13 +203,20 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const bool QGLPixelBuffer::hasOpenGLPbuffers() { // See if we have at least 1 configuration that matches the default format. - QEglContext ctx; - if (!ctx.openDisplay(0)) + EGLDisplay dpy = QEglContext::defaultDisplay(0); + if (dpy == EGL_NO_DISPLAY) return false; QEglProperties configProps; qt_egl_set_format(configProps, QInternal::Pbuffer, QGLFormat::defaultFormat()); configProps.setRenderableType(QEglContext::OpenGL); - return ctx.chooseConfig(configProps, QEglContext::BestPixelFormat); + do { + EGLConfig cfg = 0; + EGLint matching = 0; + if (eglChooseConfig(dpy, configProps.properties(), + &cfg, 1, &matching) && matching > 0) + return true; + } while (configProps.reduceConfiguration()); + return false; } QT_END_NAMESPACE -- cgit v0.12