diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-04 22:50:12 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-04 22:50:12 (GMT) |
commit | 5f34e11676002953fe5e9f94fbcd08739d46aba8 (patch) | |
tree | 2f130a6521f97a49c2c50a888d5981960f930175 /src/opengl/qgl_p.h | |
parent | 1ec1d9bc56572a92108a4b1bf48587717e7c630b (diff) | |
download | Qt-5f34e11676002953fe5e9f94fbcd08739d46aba8.zip Qt-5f34e11676002953fe5e9f94fbcd08739d46aba8.tar.gz Qt-5f34e11676002953fe5e9f94fbcd08739d46aba8.tar.bz2 |
Move QGLContextResource management into QGLContextGroup
Context resources are per-group, so they should be managed
by the group. This should also improve performance of context
shutdown slightly by removing QGLSignalProxy::aboutToDestroyContext()
signal dispatches to the resources.
Reviewed-by: trustme
Diffstat (limited to 'src/opengl/qgl_p.h')
-rw-r--r-- | src/opengl/qgl_p.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 2bf3374..fd7f544 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -219,6 +219,8 @@ public: #endif }; +class QGLContextResource; + // QGLContextPrivate has the responsibility of creating context groups. // QGLContextPrivate and QGLShareRegister will both maintain the reference counter and destroy // context groups when needed. @@ -234,10 +236,15 @@ private: QGLExtensionFuncs m_extensionFuncs; const QGLContext *m_context; // context group's representative QList<const QGLContext *> m_shares; + QHash<QGLContextResource *, void *> m_resources; QAtomicInt m_refs; + void cleanupResources(const QGLContext *ctx); + friend class QGLShareRegister; + friend class QGLContext; friend class QGLContextPrivate; + friend class QGLContextResource; }; // Reference to a QGLContext which automatically switches to another @@ -506,26 +513,21 @@ inline GLenum qt_gl_preferredTextureTarget() } // One resource per group of shared contexts. -class Q_AUTOTEST_EXPORT QGLContextResource : public QObject +class Q_AUTOTEST_EXPORT QGLContextResource { - Q_OBJECT public: typedef void (*FreeFunc)(void *); - QGLContextResource(FreeFunc f, QObject *parent = 0); + QGLContextResource(FreeFunc f); ~QGLContextResource(); // Set resource 'value' for 'key' and all its shared contexts. void insert(const QGLContext *key, void *value); // Return resource for 'key' or a shared context. void *value(const QGLContext *key); - // Free resource for 'key' and all its shared contexts. - void removeGroup(const QGLContext *key); -private slots: - // Remove entry 'key' from cache and delete resource if there are no shared contexts. - void removeOne(const QGLContext *key); + // Cleanup 'value' in response to a context group being destroyed. + void cleanup(const QGLContext *ctx, void *value); private: - typedef QHash<const QGLContext *, void *> ResourceHash; - ResourceHash m_resources; FreeFunc free; + QAtomicInt active; }; // Temporarily make a context current if not already current or |