summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-08-26 11:37:18 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-08-26 11:37:18 (GMT)
commit55123a9b94eb38a372a2d285b25c58085921f233 (patch)
treea50e58817060bd31116e4cee684300eaf721ce4f /src/opengl/qgl.cpp
parentc0c2e556e98ffe550cbedb4e3a0def5dd272ce25 (diff)
parenta4515ec14fdc772eb6b5c4801cddaddc26b94d84 (diff)
downloadQt-55123a9b94eb38a372a2d285b25c58085921f233.zip
Qt-55123a9b94eb38a372a2d285b25c58085921f233.tar.gz
Qt-55123a9b94eb38a372a2d285b25c58085921f233.tar.bz2
Merge remote branch 'qt/master' into lighthouse-master
Conflicts: src/opengl/opengl.pro src/opengl/qgl.cpp src/opengl/qgl_p.h
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp65
1 files changed, 58 insertions, 7 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 9d20090..2145001 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -98,7 +98,7 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA)
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs;
#endif
@@ -107,6 +107,11 @@ extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
#endif
struct QGLThreadContext {
+#ifdef QT_OPENGL_ES
+ ~QGLThreadContext() {
+ eglReleaseThread();
+ }
+#endif
QGLContext *context;
};
@@ -2271,7 +2276,7 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu
}
}
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA)
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *)
{
return qt_extensionFuncs;
@@ -2294,11 +2299,19 @@ QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_prem
QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format,
QGLContext::BindOptions options)
{
+ Q_Q(QGLContext);
+
const qint64 key = image.cacheKey();
QGLTexture *texture = textureCacheLookup(key, target);
if (texture) {
- glBindTexture(target, texture->id);
- return texture;
+ if (image.paintingActive()) {
+ // A QPainter is active on the image - take the safe route and replace the texture.
+ q->deleteTexture(texture->id);
+ texture = 0;
+ } else {
+ glBindTexture(target, texture->id);
+ return texture;
+ }
}
if (!texture)
@@ -2564,14 +2577,19 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
}
#else
Q_UNUSED(pd);
- Q_UNUSED(q);
#endif
const qint64 key = pixmap.cacheKey();
QGLTexture *texture = textureCacheLookup(key, target);
if (texture) {
- glBindTexture(target, texture->id);
- return texture;
+ if (pixmap.paintingActive()) {
+ // A QPainter is active on the pixmap - take the safe route and replace the texture.
+ q->deleteTexture(texture->id);
+ texture = 0;
+ } else {
+ glBindTexture(target, texture->id);
+ return texture;
+ }
}
#if defined(Q_WS_X11)
@@ -4183,6 +4201,34 @@ bool QGLWidget::event(QEvent *e)
d->glcx->d_ptr->clearDrawable();
# endif
}
+#elif defined(Q_OS_SYMBIAN)
+ // prevents errors on some systems, where we get a flush to a
+ // hidden widget
+ if (e->type() == QEvent::Hide) {
+ makeCurrent();
+ glFinish();
+ doneCurrent();
+ } else if (e->type() == QEvent::ParentChange) {
+ // if we've reparented a window that has the current context
+ // bound, we need to rebind that context to the new window id
+ if (d->glcx == QGLContext::currentContext())
+ makeCurrent();
+
+ if (testAttribute(Qt::WA_TranslucentBackground))
+ setContext(new QGLContext(d->glcx->requestedFormat(), this));
+ }
+
+ // A re-parent is likely to destroy the Symbian window and re-create it. It is important
+ // that we free the EGL surface _before_ the winID changes - otherwise we can leak.
+ if (e->type() == QEvent::ParentAboutToChange)
+ d->glcx->d_func()->destroyEglSurfaceForDevice();
+
+ if ((e->type() == QEvent::ParentChange) || (e->type() == QEvent::WindowStateChange)) {
+ // The window may have been re-created during re-parent or state change - if so, the EGL
+ // surface will need to be re-created.
+ d->recreateEglSurface();
+ }
+
#endif
return QWidget::event(e);
@@ -4390,6 +4436,11 @@ void QGLWidget::glDraw()
Q_D(QGLWidget);
if (!isValid())
return;
+#ifdef Q_OS_SYMBIAN
+ // Crashes on Symbian if trying to render to invisible surfaces
+ if (!isVisible() && d->glcx->device()->devType() == QInternal::Widget)
+ return;
+#endif
makeCurrent();
#ifndef QT_OPENGL_ES
if (d->glcx->deviceIsPixmap())