diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-20 08:04:29 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-20 08:04:29 (GMT) |
commit | 30b45ba2b11342a9e7cc06b68237b68a68955213 (patch) | |
tree | 1018c188375b3217b31abe9b7a0883ee1184a447 /src/opengl/qgl.cpp | |
parent | ce27cf24539e0c7971937e55d8539496ad51ee52 (diff) | |
parent | 8f10ca802dee1ed110f301191c4a56a85575033c (diff) | |
download | Qt-30b45ba2b11342a9e7cc06b68237b68a68955213.zip Qt-30b45ba2b11342a9e7cc06b68237b68a68955213.tar.gz Qt-30b45ba2b11342a9e7cc06b68237b68a68955213.tar.bz2 |
Merge remote branch 'origin/master' into qt-master-from-4.6
Conflicts:
configure.exe
src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
src/opengl/qgl.cpp
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5f5941b..2ed185f 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1708,6 +1708,7 @@ QGLTextureCache::~QGLTextureCache() void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost) { + QWriteLocker locker(&m_lock); if (m_cache.totalCost() + cost > m_cache.maxCost()) { // the cache is full - make an attempt to remove something const QList<qint64> keys = m_cache.keys(); @@ -1725,6 +1726,7 @@ void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, i bool QGLTextureCache::remove(QGLContext* ctx, GLuint textureId) { + QWriteLocker locker(&m_lock); QList<qint64> keys = m_cache.keys(); for (int i = 0; i < keys.size(); ++i) { QGLTexture *tex = m_cache.object(keys.at(i)); @@ -1739,6 +1741,7 @@ bool QGLTextureCache::remove(QGLContext* ctx, GLuint textureId) void QGLTextureCache::removeContextTextures(QGLContext* ctx) { + QWriteLocker locker(&m_lock); QList<qint64> keys = m_cache.keys(); for (int i = 0; i < keys.size(); ++i) { const qint64 &key = keys.at(i); @@ -1761,11 +1764,8 @@ QGLTextureCache* QGLTextureCache::instance() */ void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey) { - // ### remove when the GL texture cache becomes thread-safe - if (qApp->thread() == QThread::currentThread()) { - instance()->remove(cacheKey); - Q_ASSERT(instance()->getTexture(cacheKey) == 0); - } + instance()->remove(cacheKey); + Q_ASSERT(instance()->getTexture(cacheKey) == 0); } @@ -2388,7 +2388,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G #ifndef QT_NO_DEBUG GLenum error = glGetError(); if (error != GL_NO_ERROR) { - qWarning(" - texture upload failed, error code 0x%x\n", error); + qWarning(" - texture upload failed, error code 0x%x, enum: %d (%x)\n", error, target, target); } #endif @@ -3290,6 +3290,7 @@ void QGLContextPrivate::setCurrentContext(QGLContext *context) */ + /***************************************************************************** QGLWidget implementation *****************************************************************************/ @@ -3410,6 +3411,15 @@ void QGLContextPrivate::setCurrentContext(QGLContext *context) One approach to doing this is shown in the \l{Overpainting Example}{Overpainting} example. + \section1 Threading + + It is possible to render into a QGLWidget from another thread, but it + requires that all access to the GL context is safe guarded. The Qt GUI + thread will try to use the context in resizeEvent and paintEvent, so in + order for threaded rendering using a GL widget to work, these functions + need to be intercepted in the GUI thread and handled accordingly in the + application. + \e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.} |