summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp1
-rw-r--r--src/opengl/qgl_egl.cpp52
-rw-r--r--src/opengl/qgl_p.h1
-rw-r--r--src/opengl/qgl_qws.cpp51
-rw-r--r--src/opengl/qgl_wince.cpp61
-rw-r--r--src/opengl/qgl_x11egl.cpp59
-rw-r--r--src/opengl/qglpixelbuffer.cpp1
7 files changed, 63 insertions, 163 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index fe676ea..89bd7d4 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1430,6 +1430,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
#endif
#if defined(QT_OPENGL_ES)
eglContext = 0;
+ eglSurface = EGL_NO_SURFACE;
#endif
fbo = 0;
crWin = false;
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 60155b6..deb7092 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <QtOpenGL/qgl.h>
+#include "qgl_p.h"
#include "qgl_egl_p.h"
QT_BEGIN_NAMESPACE
@@ -128,4 +129,55 @@ void qt_egl_update_format(const QEglContext& context, QGLFormat& format)
context.clearError();
}
+void QGLContext::reset()
+{
+ Q_D(QGLContext);
+ if (!d->valid)
+ return;
+ d->cleanup();
+ doneCurrent();
+ if (d->eglContext) {
+ delete d->eglContext;
+ d->eglContext = 0;
+ }
+ d->eglSurface = EGL_NO_SURFACE; // XXX - probably need to destroy surface
+ d->crWin = false;
+ d->sharing = false;
+ d->valid = false;
+ d->transpColor = QColor();
+ d->initDone = false;
+ qgl_share_reg()->removeShare(this);
+}
+
+void QGLContext::makeCurrent()
+{
+ Q_D(QGLContext);
+ if (!d->valid || !d->eglContext || d->eglSurface == EGL_NO_SURFACE) {
+ qWarning("QGLContext::makeCurrent(): Cannot make invalid context current");
+ return;
+ }
+
+ if (d->eglContext->makeCurrent(d->eglSurface))
+ QGLContextPrivate::setCurrentContext(this);
+}
+
+void QGLContext::doneCurrent()
+{
+ Q_D(QGLContext);
+ if (d->eglContext)
+ d->eglContext->doneCurrent();
+
+ QGLContextPrivate::setCurrentContext(0);
+}
+
+
+void QGLContext::swapBuffers() const
+{
+ Q_D(const QGLContext);
+ if (!d->valid || !d->eglContext)
+ return;
+
+ d->eglContext->swapBuffers(d->eglSurface);
+}
+
QT_END_NAMESPACE
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 7269195..2e8ac88 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -295,6 +295,7 @@ public:
#endif
#if defined(QT_OPENGL_ES)
QEglContext *eglContext;
+ EGLSurface eglSurface;
#elif defined(Q_WS_X11) || defined(Q_WS_MAC)
void* cx;
#endif
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index 7197776..b8a8777 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -228,61 +228,12 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
d->eglContext = 0;
return false;
}
+ d->eglSurface = d->eglContext->surface();
return true;
}
-void QGLContext::reset()
-{
- Q_D(QGLContext);
- if (!d->valid)
- return;
- d->cleanup();
- doneCurrent();
- if (d->eglContext) {
- delete d->eglContext;
- d->eglContext = 0;
- }
- d->crWin = false;
- d->sharing = false;
- d->valid = false;
- d->transpColor = QColor();
- d->initDone = false;
- qgl_share_reg()->removeShare(this);
-}
-
-void QGLContext::makeCurrent()
-{
- Q_D(QGLContext);
- if(!d->valid || !d->eglContext) {
- qWarning("QGLContext::makeCurrent(): Cannot make invalid context current");
- return;
- }
-
- if (d->eglContext->makeCurrent())
- QGLContextPrivate::setCurrentContext(this);
-}
-
-void QGLContext::doneCurrent()
-{
- Q_D(QGLContext);
- if (d->eglContext)
- d->eglContext->doneCurrent();
-
- QGLContextPrivate::setCurrentContext(0);
-}
-
-
-void QGLContext::swapBuffers() const
-{
- Q_D(const QGLContext);
- if(!d->valid || !d->eglContext)
- return;
-
- d->eglContext->swapBuffers();
-}
-
QColor QGLContext::overlayTransparentColor() const
{
return QColor(0, 0, 0); // Invalid color
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index 4e655f1..f951ea0 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -183,6 +183,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
d->eglContext = 0;
return false;
}
+ d->eglSurface = d->eglContext->surface();
return true;
@@ -415,66 +416,6 @@ const QRgb* QGLCmap::colors() const
}
-void QGLContext::reset()
-{
- Q_D(QGLContext);
- if (!d->valid)
- return;
- d->cleanup();
- doneCurrent();
- if (d->eglContext) {
- delete d->eglContext;
- d->eglContext = 0;
- }
- d->crWin = false;
- d->sharing = false;
- d->valid = false;
- d->transpColor = QColor();
- d->initDone = false;
- qgl_share_reg()->removeShare(this);
-}
-
-
-//
-// NOTE: In a multi-threaded environment, each thread has a current
-// context. If we want to make this code thread-safe, we probably
-// have to use TLS (thread local storage) for keeping current contexts.
-//
-
-void QGLContext::makeCurrent()
-{
-
- Q_D(QGLContext);
- if(!d->valid || !d->eglContext) {
- qWarning("QGLContext::makeCurrent(): Cannot make invalid context current");
- return;
- }
-
- if (d->eglContext->makeCurrent())
- QGLContextPrivate::setCurrentContext(this);
-}
-
-
-void QGLContext::doneCurrent()
-{
-
- Q_D(QGLContext);
- if (d->eglContext)
- d->eglContext->doneCurrent();
-
- QGLContextPrivate::setCurrentContext(0);
-}
-
-void QGLContext::swapBuffers() const
-{
- Q_D(const QGLContext);
- if(!d->valid || !d->eglContext)
- return;
-
- d->eglContext->swapBuffers();
-}
-
-
QColor QGLContext::overlayTransparentColor() const
{
return d_func()->transpColor;
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index 32d8cc2..c054860 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -119,56 +119,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
}
-void QGLContext::reset()
-{
- Q_D(QGLContext);
- if (!d->valid)
- return;
- d->cleanup();
- doneCurrent();
- if (d->eglContext) {
- delete d->eglContext;
- d->eglContext = 0;
- }
- d->crWin = false;
- d->sharing = false;
- d->valid = false;
- d->transpColor = QColor();
- d->initDone = false;
- qgl_share_reg()->removeShare(this);
-}
-
-void QGLContext::makeCurrent()
-{
- Q_D(QGLContext);
- if(!d->valid || !d->eglContext) {
- qWarning("QGLContext::makeCurrent(): Cannot make invalid context current");
- return;
- }
-
- if (d->eglContext->makeCurrent())
- QGLContextPrivate::setCurrentContext(this);
-}
-
-void QGLContext::doneCurrent()
-{
- Q_D(QGLContext);
- if (d->eglContext)
- d->eglContext->doneCurrent();
-
- QGLContextPrivate::setCurrentContext(0);
-}
-
-
-void QGLContext::swapBuffers() const
-{
- Q_D(const QGLContext);
- if(!d->valid || !d->eglContext)
- return;
-
- d->eglContext->swapBuffers();
-}
-
QColor QGLContext::overlayTransparentColor() const
{
return QColor(0, 0, 0); // Invalid color
@@ -412,11 +362,13 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext,
// Create the EGL surface to draw into.
- if (!d->glcx->d_func()->eglContext->createSurface(this)) {
- delete d->glcx->d_func()->eglContext;
- d->glcx->d_func()->eglContext = 0;
+ QGLContextPrivate *ctxpriv = d->glcx->d_func();
+ if (!ctxpriv->eglContext->createSurface(this)) {
+ delete ctxpriv->eglContext;
+ ctxpriv->eglContext = 0;
return;
}
+ ctxpriv->eglSurface = ctxpriv->eglContext->surface();
d->eglSurfaceWindowId = w; // Remember the window id we created the surface for
@@ -485,6 +437,7 @@ void QGLWidgetPrivate::recreateEglSurface(bool force)
// The window id has changed so we need to re-create the EGL surface
if (!glcx->d_func()->eglContext->recreateSurface(q))
qWarning("Error creating EGL window surface: 0x%x", eglGetError());
+ glcx->d_func()->eglSurface = glcx->d_func()->eglContext->surface();
eglSurfaceWindowId = currentId;
}
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index 07bc711..7c97ebb 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -146,6 +146,7 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form
qctx->d_func()->vi = 0;
#elif defined(QT_OPENGL_ES)
qctx->d_func()->eglContext = ctx;
+ qctx->d_func()->eglSurface = pbuf;
#endif
}
}