diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-31 00:52:12 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-31 00:52:12 (GMT) |
commit | 46403d21e1cfd5b4b89244067a4111d5c2c0ff1a (patch) | |
tree | c520ad63b6614ed7c31aae83bdc1899762c95b2d | |
parent | f270536c4e57bef2cbf203035f89feeb1a86c4df (diff) | |
download | Qt-46403d21e1cfd5b4b89244067a4111d5c2c0ff1a.zip Qt-46403d21e1cfd5b4b89244067a4111d5c2c0ff1a.tar.gz Qt-46403d21e1cfd5b4b89244067a4111d5c2c0ff1a.tar.bz2 |
Move QGLShareContextScope to qgl_p.h so other things can use it.
Reviewed-by: trustme
-rw-r--r-- | src/opengl/qgl_p.h | 40 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_gl.cpp | 37 |
2 files changed, 40 insertions, 37 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 6905199..5496819 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -533,6 +533,46 @@ private: FreeFunc free; }; +// Temporarily make a context current if not already current or +// shared with the current contex. The previous context is made +// current when the object goes out of scope. +class Q_OPENGL_EXPORT QGLShareContextScope +{ +public: + QGLShareContextScope(const QGLContext *ctx) + : m_oldContext(0) + { + QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext()); + if (currentContext != ctx && !qgl_share_reg()->checkSharing(ctx, currentContext)) { + m_oldContext = currentContext; + m_ctx = const_cast<QGLContext *>(ctx); + m_ctx->makeCurrent(); + } else { + m_ctx = currentContext; + } + } + + operator QGLContext *() + { + return m_ctx; + } + + QGLContext *operator->() + { + return m_ctx; + } + + ~QGLShareContextScope() + { + if (m_oldContext) + m_oldContext->makeCurrent(); + } + +private: + QGLContext *m_oldContext; + QGLContext *m_ctx; +}; + QT_END_NAMESPACE #endif // QGL_P_H diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index c193f12..e18f98b 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -132,43 +132,6 @@ void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo) m_fbos << fbo; } -class QGLShareContextScope -{ -public: - QGLShareContextScope(const QGLContext *ctx) - : m_oldContext(0) - { - QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext()); - if (currentContext != ctx && !qgl_share_reg()->checkSharing(ctx, currentContext)) { - m_oldContext = currentContext; - m_ctx = const_cast<QGLContext *>(ctx); - m_ctx->makeCurrent(); - } else { - m_ctx = currentContext; - } - } - - operator QGLContext *() - { - return m_ctx; - } - - QGLContext *operator->() - { - return m_ctx; - } - - ~QGLShareContextScope() - { - if (m_oldContext) - m_oldContext->makeCurrent(); - } - -private: - QGLContext *m_oldContext; - QGLContext *m_ctx; -}; - static int qt_gl_pixmap_serial = 0; QGLPixmapData::QGLPixmapData(PixelType type) |