summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-08-19 09:52:55 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-08-19 09:52:55 (GMT)
commit872ccdcc090cec252cea2109d2fc9f2f2ee4c795 (patch)
tree7b14b977528cb6e833a765afce3c9bf6e55c94af /src/opengl
parent74d519f87e804b624ac76337fe2905d512d363fc (diff)
parentf6cfafde26b4735965be8df0d11e9d7c297c75b9 (diff)
downloadQt-872ccdcc090cec252cea2109d2fc9f2f2ee4c795.zip
Qt-872ccdcc090cec252cea2109d2fc9f2f2ee4c795.tar.gz
Qt-872ccdcc090cec252cea2109d2fc9f2f2ee4c795.tar.bz2
Merge remote branch 'qt/4.7' into lighthouse-4.7
Conflicts: src/opengl/qgl_p.h
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp32
-rw-r--r--src/opengl/qgl_egl.cpp1
-rw-r--r--src/opengl/qgl_mac.mm11
-rw-r--r--src/opengl/qgl_p.h3
-rw-r--r--src/opengl/qglextensions.cpp4
-rw-r--r--src/opengl/qglframebufferobject.cpp4
-rw-r--r--src/opengl/qglshaderprogram.cpp2
-rw-r--r--src/opengl/qwindowsurface_gl.cpp19
-rw-r--r--src/opengl/qwindowsurface_gl_p.h1
9 files changed, 65 insertions, 12 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 0f171e4..3affca4 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1695,6 +1695,10 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
workaround_needsFullClearOnEveryFrame = false;
workaround_brokenFBOReadBack = false;
workaroundsCached = false;
+
+ workaround_brokenTextureFromPixmap = false;
+ workaround_brokenTextureFromPixmap_init = false;
+
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
vertexAttributeArraysEnabledState[i] = false;
}
@@ -1998,7 +2002,7 @@ struct DDSFormat {
option helps preserve this default behavior.
\omitvalue CanFlipNativePixmapBindOption Used by x11 from pixmap to choose
- wether or not it can bind the pixmap upside down or not.
+ whether or not it can bind the pixmap upside down or not.
\omitvalue MemoryManagedBindOption Used by paint engines to
indicate that the pixmap should be memory managed along side with
@@ -2577,11 +2581,27 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
&& xinfo && xinfo->screen() == pixmap.x11Info().screen()
&& target == GL_TEXTURE_2D)
{
- texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options);
- if (texture) {
- texture->options |= QGLContext::MemoryManagedBindOption;
- texture->boundPixmap = pd;
- boundPixmaps.insert(pd, QPixmap(pixmap));
+ if (!workaround_brokenTextureFromPixmap_init) {
+ workaround_brokenTextureFromPixmap_init = true;
+
+ const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
+ const int pos = versionString.indexOf("NVIDIA ");
+
+ if (pos >= 0) {
+ const QByteArray nvidiaVersionString = versionString.mid(pos + strlen("NVIDIA "));
+
+ if (nvidiaVersionString.startsWith("195") || nvidiaVersionString.startsWith("256"))
+ workaround_brokenTextureFromPixmap = true;
+ }
+ }
+
+ if (!workaround_brokenTextureFromPixmap) {
+ texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options);
+ if (texture) {
+ texture->options |= QGLContext::MemoryManagedBindOption;
+ texture->boundPixmap = pd;
+ boundPixmaps.insert(pd, QPixmap(pixmap));
+ }
}
}
#endif
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 3763926..a154325 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -240,6 +240,7 @@ void QGLContextPrivate::destroyEglSurfaceForDevice()
if (QGLWidget *wgl = qobject_cast<QGLWidget *>(w)) {
if (wgl->d_func()->eglSurfaceWindowId != wgl->winId()) {
qWarning("WARNING: Potential EGL surface leak! Not destroying surface.");
+ eglSurface = EGL_NO_SURFACE;
return;
}
}
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm
index 4d7532e..66fe7d3 100644
--- a/src/opengl/qgl_mac.mm
+++ b/src/opengl/qgl_mac.mm
@@ -804,17 +804,22 @@ void QGLContext::generateFontDisplayLists(const QFont & /* fnt */, int /* listBa
static CFBundleRef qt_getOpenGLBundle()
{
CFBundleRef bundle = 0;
+ CFStringRef urlString = QCFString::toCFStringRef(QLatin1String("/System/Library/Frameworks/OpenGL.framework"));
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
- QCFString::toCFStringRef(QLatin1String("/System/Library/Frameworks/OpenGL.framework")), kCFURLPOSIXPathStyle, false);
+ urlString, kCFURLPOSIXPathStyle, false);
if (url)
bundle = CFBundleCreate(kCFAllocatorDefault, url);
+ CFRelease(urlString);
return bundle;
}
void *QGLContext::getProcAddress(const QString &proc) const
{
- return CFBundleGetFunctionPointerForName(QCFType<CFBundleRef>(qt_getOpenGLBundle()),
- QCFString(proc));
+ CFStringRef procName = QCFString(proc).toCFStringRef(proc);
+ void *result = CFBundleGetFunctionPointerForName(QCFType<CFBundleRef>(qt_getOpenGLBundle()),
+ procName);
+ CFRelease(procName);
+ return result;
}
#ifndef QT_MAC_USE_COCOA
/*****************************************************************************
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index e8c859a..0e52f22 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -400,6 +400,9 @@ public:
uint workaround_brokenFBOReadBack : 1;
uint workaroundsCached : 1;
+ uint workaround_brokenTextureFromPixmap : 1;
+ uint workaround_brokenTextureFromPixmap_init : 1;
+
#ifndef QT_NO_EGL
uint ownsEglContext : 1;
#endif
diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp
index 8e2bbd4..6aec8ae 100644
--- a/src/opengl/qglextensions.cpp
+++ b/src/opengl/qglextensions.cpp
@@ -255,6 +255,10 @@ bool qt_resolve_glsl_extensions(QGLContext *ctx)
glFramebufferTextureLayerEXT = (_glFramebufferTextureLayerEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureLayerEXT"));
glFramebufferTextureFaceEXT = (_glFramebufferTextureFaceEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureFaceEXT"));
+ // Must at least have the FragmentShader extension to continue.
+ if (!(QGLExtensions::glExtensions() & QGLExtensions::FragmentShader))
+ return false;
+
glCreateShader = (_glCreateShader) ctx->getProcAddress(QLatin1String("glCreateShader"));
if (glCreateShader) {
glShaderSource = (_glShaderSource) ctx->getProcAddress(QLatin1String("glShaderSource"));
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index deffc20..9b8a3d1 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -445,11 +445,11 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
GLint maxSamples;
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
- samples = qBound(1, int(samples), int(maxSamples));
+ samples = qBound(0, int(samples), int(maxSamples));
glGenRenderbuffers(1, &color_buffer);
glBindRenderbuffer(GL_RENDERBUFFER_EXT, color_buffer);
- if (glRenderbufferStorageMultisampleEXT) {
+ if (glRenderbufferStorageMultisampleEXT && samples > 0) {
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples,
internal_format, size.width(), size.height());
} else {
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index c7689b8..74382b0 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -2121,7 +2121,7 @@ void QGLShaderProgram::setUniformValue(int location, const QSize& size)
Q_D(QGLShaderProgram);
Q_UNUSED(d);
if (location != -1) {
- GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.width())};
+ GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())};
glUniform2fv(location, 1, values);
}
}
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index b3c9df1..25c0501 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -199,6 +199,7 @@ public:
return widget;
}
+ // destroys the share widget and prevents recreation
void cleanup() {
QGLWidget *w = widget;
cleanedUp = true;
@@ -206,6 +207,20 @@ public:
delete w;
}
+ // destroys the share widget, but allows it to be recreated later on
+ void destroy() {
+ if (cleanedUp)
+ return;
+
+ QGLWidget *w = widget;
+
+ // prevent potential recursions
+ cleanedUp = true;
+ widget = 0;
+ delete w;
+ cleanedUp = false;
+ }
+
static bool cleanedUp;
private:
@@ -233,6 +248,10 @@ QGLWidget* qt_gl_share_widget()
return _qt_gl_share_widget()->shareWidget();
}
+void qt_destroy_gl_share_widget()
+{
+ _qt_gl_share_widget()->destroy();
+}
struct QGLWindowSurfacePrivate
{
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index eebc42f..ca73bad 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -67,6 +67,7 @@ class QWidget;
struct QGLWindowSurfacePrivate;
Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget();
+Q_OPENGL_EXPORT void qt_destroy_gl_share_widget();
class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice
{