diff options
Diffstat (limited to 'src/gui/opengl/qopengl_p.h')
-rw-r--r-- | src/gui/opengl/qopengl_p.h | 93 |
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 |