summaryrefslogtreecommitdiffstats
path: root/src/opengl/qglfunctions.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-08-16 09:29:44 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-08-29 10:24:55 +0200
commitaaa4a26f82f99fa8724841eba91bad029306e0ce (patch)
tree3d24e874bff00efc0e73af610bc80e645d14f789 /src/opengl/qglfunctions.cpp
parent00fd783a39d55d2365ddead4fab2cc06091c119f (diff)
Move GL resource handling enablers to QtGui.
Made resource handling more robust by attempting to free GL resources in the correct thread, and not forcing a context to become current to free resources. Change-Id: Ie81d4005b608972375755571d9b50ce82080709b Reviewed-on: http://codereview.qt.nokia.com/3258 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/opengl/qglfunctions.cpp')
-rw-r--r--src/opengl/qglfunctions.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp
index 48549fb8d2..534c6c8bbf 100644
--- a/src/opengl/qglfunctions.cpp
+++ b/src/opengl/qglfunctions.cpp
@@ -41,6 +41,7 @@
#include "qglfunctions.h"
#include "qgl_p.h"
+#include "QtGui/private/qguiglcontext_qpa_p.h"
QT_BEGIN_NAMESPACE
@@ -139,16 +140,27 @@ QT_BEGIN_NAMESPACE
*/
// Hidden private fields for additional extension data.
-struct QGLFunctionsPrivateEx : public QGLFunctionsPrivate
+struct QGLFunctionsPrivateEx : public QGLFunctionsPrivate, public QGLSharedResource
{
- QGLFunctionsPrivateEx(const QGLContext *context = 0)
- : QGLFunctionsPrivate(context)
+ QGLFunctionsPrivateEx(QGuiGLContext *context)
+ : QGLFunctionsPrivate(QGLContext::fromGuiGLContext(context))
+ , QGLSharedResource(context->shareGroup())
, m_features(-1) {}
+ void invalidateResource()
+ {
+ m_features = -1;
+ }
+
+ void freeResource(QGuiGLContext *)
+ {
+ // no gl resources to free
+ }
+
int m_features;
};
-Q_GLOBAL_STATIC(QGLContextGroupResource<QGLFunctionsPrivateEx>, qt_gl_functions_resource)
+Q_GLOBAL_STATIC(QGLMultiGroupSharedResource, qt_gl_functions_resource)
static QGLFunctionsPrivateEx *qt_gl_functions(const QGLContext *context = 0)
{
@@ -157,13 +169,7 @@ static QGLFunctionsPrivateEx *qt_gl_functions(const QGLContext *context = 0)
Q_ASSERT(context);
QGLFunctionsPrivateEx *funcs =
reinterpret_cast<QGLFunctionsPrivateEx *>
- (qt_gl_functions_resource()->value(context));
-#if QT_VERSION < 0x040800
- if (!funcs) {
- funcs = new QGLFunctionsPrivateEx();
- qt_gl_functions_resource()->insert(context, funcs);
- }
-#endif
+ (qt_gl_functions_resource()->value<QGLFunctionsPrivateEx>(context->contextHandle()));
return funcs;
}