summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opengl/qgl_p.h40
-rw-r--r--src/opengl/qpixmapdata_gl.cpp37
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)