summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-08-19 10:43:58 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-08-19 10:43:58 (GMT)
commit0e451e855e54f6827e11f7664450aaf0be208203 (patch)
tree26ceb00aa948c1cbd8103a825fc5582d6a1bd719 /src/opengl
parenta226143eeda6771efc4f0df6955351336735cb60 (diff)
parent872ccdcc090cec252cea2109d2fc9f2f2ee4c795 (diff)
downloadQt-0e451e855e54f6827e11f7664450aaf0be208203.zip
Qt-0e451e855e54f6827e11f7664450aaf0be208203.tar.gz
Qt-0e451e855e54f6827e11f7664450aaf0be208203.tar.bz2
Merge remote branch 'lighthouse/4.7' into lighthouse-master
Conflicts: src/plugins/bearer/connman/qconnmanservice_linux.cpp tests/auto/qpainter/tst_qpainter.cpp
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp30
-rw-r--r--src/opengl/qgl_p.h3
-rw-r--r--src/opengl/qgl_qpa.cpp14
3 files changed, 41 insertions, 6 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 63477ae..9d20090 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1698,6 +1698,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;
}
@@ -2578,11 +2582,27 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
&& target == GL_TEXTURE_2D
&& QApplication::instance()->thread() == QThread::currentThread())
{
- 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_p.h b/src/opengl/qgl_p.h
index f02b85f..44e5fd1 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -401,6 +401,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/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 3d5b74f..49c0860 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -105,7 +105,8 @@ static QPlatformWindowFormat qt_glformat_to_platformwindowformat(const QGLFormat
retFormat.setRedBufferSize(format.redBufferSize());
retFormat.setRgba(format.rgba());
retFormat.setSampleBuffers(format.sampleBuffers());
- retFormat.setSamples(format.sampleBuffers());
+ if (format.samples() >= 0)
+ retFormat.setSamples(format.samples());
retFormat.setStencil(format.stencil());
if (format.stencilBufferSize() >= 0)
retFormat.setStencilBufferSize(format.stencilBufferSize());
@@ -243,19 +244,30 @@ class QGLTemporaryContextPrivate
{
public:
QWidget *widget;
+ QGLContext *context;
};
QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
: d(new QGLTemporaryContextPrivate)
{
+ d->context = const_cast<QGLContext *>(QGLContext::currentContext());
+ if (d->context)
+ d->context->doneCurrent();
d->widget = new QWidget;
d->widget->setGeometry(0,0,3,3);
+ QPlatformWindowFormat format = d->widget->platformWindowFormat();
+ format.setWindowApi(QPlatformWindowFormat::OpenGL);
d->widget->winId();
+
+
d->widget->platformWindow()->glContext()->makeCurrent();
}
QGLTemporaryContext::~QGLTemporaryContext()
{
+ d->widget->platformWindow()->glContext()->doneCurrent();
+ if (d->context)
+ d->context->makeCurrent();
delete d->widget;
}