diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-05 01:55:53 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-05 01:55:53 (GMT) |
commit | 7b19bfec4c496f2112b363cbdc8a0c302a48cfce (patch) | |
tree | 0de2b3f93d6b58aa54c31a39ca44d1cb8fea0337 /src/opengl/gl2paintengineex | |
parent | a3add3d6ab1b7a3e4dbb2df81fd51625b834fe45 (diff) | |
download | Qt-7b19bfec4c496f2112b363cbdc8a0c302a48cfce.zip Qt-7b19bfec4c496f2112b363cbdc8a0c302a48cfce.tar.gz Qt-7b19bfec4c496f2112b363cbdc8a0c302a48cfce.tar.bz2 |
Consistently use QGLShareContextScope for context switching
QGLShareContextScope is safer and more reliable than trying to manually
detect how and when to temporarily switch contexts. Replace the few
remaining instances of context-switching with it.
Reviewed-by: trustme
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 6 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qglgradientcache.cpp | 6 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 6 |
3 files changed, 3 insertions, 15 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 59c50aa..e22303d 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -60,12 +60,8 @@ QGLEngineSharedShaders *QGLEngineSharedShaders::shadersForContext(const QGLConte { QGLEngineSharedShaders *p = reinterpret_cast<QGLEngineSharedShaders *>(qt_shared_shaders()->value(context)); if (!p) { - QGLContext *oldContext = const_cast<QGLContext *>(QGLContext::currentContext()); - if (oldContext != context) - const_cast<QGLContext *>(context)->makeCurrent(); + QGLShareContextScope scope(context); qt_shared_shaders()->insert(context, p = new QGLEngineSharedShaders(context)); - if (oldContext && oldContext != context) - oldContext->makeCurrent(); } return p; } diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp index 4b2b2a0..e06f15d 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache.cpp +++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp @@ -57,13 +57,9 @@ QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context) { QGL2GradientCache *p = reinterpret_cast<QGL2GradientCache *>(qt_gradient_caches()->value(context)); if (!p) { - QGLContext *oldContext = const_cast<QGLContext *>(QGLContext::currentContext()); - if (oldContext != context) - const_cast<QGLContext *>(context)->makeCurrent(); + QGLShareContextScope scope(context); p = new QGL2GradientCache; qt_gradient_caches()->insert(context, p); - if (oldContext && oldContext != context) - oldContext->makeCurrent(); } return p; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 992d47d..073f7db 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -162,15 +162,11 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyph QGLTextureGlyphCache::~QGLTextureGlyphCache() { if (ctx) { - QGLContext *oldContext = const_cast<QGLContext *>(QGLContext::currentContext()); - if (oldContext != ctx) - ctx->makeCurrent(); + QGLShareContextScope scope(ctx); glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) glDeleteTextures(1, &m_texture); - if (oldContext && oldContext != ctx) - oldContext->makeCurrent(); } } |