summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-09-25 00:21:23 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-09-25 00:21:23 (GMT)
commitf3d15516572394b6bcd44a89dd66516fa4eba56e (patch)
treeb97aa3bc1826d21e6fd8b39f657b1e1e63369270 /src/opengl
parent7421f79f57f475b9e96e53e5cbd9861c428d4ae3 (diff)
downloadQt-f3d15516572394b6bcd44a89dd66516fa4eba56e.zip
Qt-f3d15516572394b6bcd44a89dd66516fa4eba56e.tar.gz
Qt-f3d15516572394b6bcd44a89dd66516fa4eba56e.tar.bz2
Remove the storage of the EGLSurface from QEglContext
Reviewed-by: Sarah Smith
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl_qws.cpp19
-rw-r--r--src/opengl/qgl_wince.cpp4
-rw-r--r--src/opengl/qgl_x11egl.cpp13
-rw-r--r--src/opengl/qglpixelbuffer_egl.cpp5
4 files changed, 21 insertions, 20 deletions
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index b8a8777..d158e44 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -117,17 +117,17 @@ void qt_egl_add_platform_config(QEglProperties& props, QPaintDevice *device)
props.setPixelFormat(glScreen->pixelFormat());
}
-static bool qt_egl_create_surface
+static EGLSurface qt_egl_create_surface
(QEglContext *context, QPaintDevice *device,
const QEglProperties *properties = 0)
{
// Get the screen surface functions, which are used to create native ids.
QGLScreen *glScreen = glScreenForDevice(device);
if (!glScreen)
- return false;
+ return EGL_NO_SURFACE;
QGLScreenSurfaceFunctions *funcs = glScreen->surfaceFunctions();
if (!funcs)
- return false;
+ return EGL_NO_SURFACE;
// Create the native drawable for the paint device.
int devType = device->devType();
@@ -143,7 +143,7 @@ static bool qt_egl_create_surface
}
if (!ok) {
qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable");
- return false;
+ return EGL_NO_SURFACE;
}
// Create the EGL surface to draw into, based on the native drawable.
@@ -160,12 +160,9 @@ static bool qt_egl_create_surface
surf = eglCreatePixmapSurface
(context->display(), context->config(), pixmapDrawable, props);
}
- if (surf == EGL_NO_SURFACE) {
+ if (surf == EGL_NO_SURFACE)
qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
- return false;
- }
- context->setSurface(surf);
- return true;
+ return surf;
}
bool QGLContext::chooseContext(const QGLContext* shareContext)
@@ -223,12 +220,12 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Create the EGL surface to draw into. We cannot use
// QEglContext::createSurface() because it does not have
// access to the QGLScreen.
- if (!qt_egl_create_surface(d->eglContext, device())) {
+ d->eglSurface = qt_egl_create_surface(d->eglContext, device());
+ if (d->eglSurface == EGL_NO_SURFACE) {
delete d->eglContext;
d->eglContext = 0;
return false;
}
- d->eglSurface = d->eglContext->surface();
return true;
}
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index f951ea0..dbb5c98 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -178,12 +178,12 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
#endif
// Create the EGL surface to draw into.
- if (!d->eglContext->createSurface(device())) {
+ d->eglSurface = d->eglContext->createSurface(device());
+ if (d->eglSurface == EGL_NO_SURFACE) {
delete d->eglContext;
d->eglContext = 0;
return false;
}
- d->eglSurface = d->eglContext->surface();
return true;
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index c054860..2214775 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -363,12 +363,12 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext,
// Create the EGL surface to draw into.
QGLContextPrivate *ctxpriv = d->glcx->d_func();
- if (!ctxpriv->eglContext->createSurface(this)) {
+ ctxpriv->eglSurface = ctxpriv->eglContext->createSurface(this);
+ if (ctxpriv->eglSurface == EGL_NO_SURFACE) {
delete ctxpriv->eglContext;
ctxpriv->eglContext = 0;
return;
}
- ctxpriv->eglSurface = ctxpriv->eglContext->surface();
d->eglSurfaceWindowId = w; // Remember the window id we created the surface for
@@ -435,9 +435,14 @@ void QGLWidgetPrivate::recreateEglSurface(bool force)
if ( force || (currentId != eglSurfaceWindowId) ) {
// The window id has changed so we need to re-create the EGL surface
- if (!glcx->d_func()->eglContext->recreateSurface(q))
+ QEglContext *ctx = glcx->d_func()->eglContext;
+ EGLSurface surface = glcx->d_func()->eglSurface;
+ if (surface != EGL_NO_SURFACE)
+ ctx->destroySurface(surface); // Will force doneCurrent() if nec.
+ surface = ctx->createSurface(q);
+ if (surface == EGL_NO_SURFACE)
qWarning("Error creating EGL window surface: 0x%x", eglGetError());
- glcx->d_func()->eglSurface = glcx->d_func()->eglContext->surface();
+ glcx->d_func()->eglSurface = surface;
eglSurfaceWindowId = currentId;
}
diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp
index e331de5..4cba1bb 100644
--- a/src/opengl/qglpixelbuffer_egl.cpp
+++ b/src/opengl/qglpixelbuffer_egl.cpp
@@ -135,7 +135,6 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
qWarning() << "QGLPixelBufferPrivate::init(): Unable to create EGL pbuffer surface:" << QEglContext::errorString(eglGetError());
return false;
}
- ctx->setSurface(pbuf);
// Create a new context for the configuration.
QEglContext *shareContext = 0;
@@ -163,7 +162,7 @@ bool QGLPixelBuffer::bindToDynamicTexture(GLuint texture_id)
if (d->invalid || d->textureFormat == EGL_NONE || !d->ctx)
return false;
glBindTexture(GL_TEXTURE_2D, texture_id);
- return eglBindTexImage(d->ctx->display(), d->ctx->surface(), EGL_BACK_BUFFER);
+ return eglBindTexImage(d->ctx->display(), d->pbuf, EGL_BACK_BUFFER);
#else
Q_UNUSED(texture_id);
return false;
@@ -176,7 +175,7 @@ void QGLPixelBuffer::releaseFromDynamicTexture()
Q_D(QGLPixelBuffer);
if (d->invalid || d->textureFormat == EGL_NONE || !d->ctx)
return;
- eglReleaseTexImage(d->ctx->display(), d->ctx->surface(), EGL_BACK_BUFFER);
+ eglReleaseTexImage(d->ctx->display(), d->pbuf, EGL_BACK_BUFFER);
#endif
}