summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopengl_p.h
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-09-12 14:53:20 +0200
committerKim M. Kalland <kim.kalland@nokia.com>2011-09-12 17:44:41 +0200
commitfa42faaee527b9822500cd9a69023be817083d92 (patch)
tree008f09e786673065fb5a66b5e76a2d1a914a6218 /src/gui/opengl/qopengl_p.h
parent2d5fbd05bb93dcc4c5a85f8cf36e6b8ea522e86d (diff)
Implemented texture cache for GL paint engine in QtGui.
This is simpler than the existing texture cache in QtOpenGL, as it only serves the GL paint engine. There's one per context group, to simplify the design and to prevent performance degradations. Change-Id: I61e3c9a444d8e246a8b38da019a56f2c0a533c0c Reviewed-on: http://codereview.qt-project.org/4674 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
Diffstat (limited to 'src/gui/opengl/qopengl_p.h')
-rw-r--r--src/gui/opengl/qopengl_p.h93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h
index 59368f1a7b..b09f9447db 100644
--- a/src/gui/opengl/qopengl_p.h
+++ b/src/gui/opengl/qopengl_p.h
@@ -80,99 +80,6 @@ private:
QVector<int> m_offsets;
};
-class QOpenGLTexture : public QOpenGLSharedResource {
-public:
- QOpenGLTexture(QOpenGLContext *ctx, GLuint id, bool inverted)
- : QOpenGLSharedResource(ctx->shareGroup())
- , m_id(id)
- , m_inverted(inverted)
- {
- }
-
- GLuint id() const { return m_id; }
- bool invertedY() const { return m_inverted; }
-
-protected:
- void invalidateResource()
- {
- m_id = 0;
- }
-
- void freeResource(QOpenGLContext *)
- {
- glDeleteTextures(1, &m_id);
- }
-
-private:
- GLuint m_id;
- bool m_inverted;
-};
-
-struct QOpenGLTextureCacheKey {
- qint64 key;
- QOpenGLContextGroup *group;
-};
-
-inline bool operator==(const QOpenGLTextureCacheKey &a, const QOpenGLTextureCacheKey &b)
-{
- return a.key == b.key && a.group == b.group;
-}
-
-inline uint qHash(const QOpenGLTextureCacheKey &key)
-{
- return qHash(key.key) ^ qHash(key.group);
-}
-
-class QPlatformPixmap;
-
-class QOpenGLTextureCache {
-public:
- QOpenGLTextureCache();
- ~QOpenGLTextureCache();
-
- void insert(QOpenGLContext *ctx, qint64 key, QOpenGLTexture *texture, int cost);
- void remove(qint64 key);
- inline int size();
- inline void setMaxCost(int newMax);
- inline int maxCost();
- inline QOpenGLTexture* getTexture(QOpenGLContext *ctx, qint64 key);
-
- bool remove(QOpenGLContext *ctx, GLuint textureId);
- void removeContextTextures(QOpenGLContext *ctx);
- static QOpenGLTextureCache *instance();
- static void cleanupTexturesForCacheKey(qint64 cacheKey);
- static void cleanupTexturesForPixampData(QPlatformPixmap* pixmap);
- static void cleanupBeforePixmapDestruction(QPlatformPixmap* pixmap);
-
-private:
- QCache<QOpenGLTextureCacheKey, QOpenGLTexture> m_cache;
- QReadWriteLock m_lock;
-};
-
-int QOpenGLTextureCache::size() {
- QReadLocker locker(&m_lock);
- return m_cache.size();
-}
-
-void QOpenGLTextureCache::setMaxCost(int newMax)
-{
- QWriteLocker locker(&m_lock);
- m_cache.setMaxCost(newMax);
-}
-
-int QOpenGLTextureCache::maxCost()
-{
- QReadLocker locker(&m_lock);
- return m_cache.maxCost();
-}
-
-QOpenGLTexture* QOpenGLTextureCache::getTexture(QOpenGLContext *ctx, qint64 key)
-{
- QReadLocker locker(&m_lock);
- const QOpenGLTextureCacheKey cacheKey = { key, ctx->shareGroup() };
- return m_cache.object(cacheKey);
-}
-
QT_END_NAMESPACE
QT_END_HEADER