diff options
Diffstat (limited to 'src/opengl/qgl_p.h')
-rw-r--r-- | src/opengl/qgl_p.h | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index efd2090..5c4638e 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -528,14 +528,14 @@ public: ~QGLTextureCache(); void insert(QGLContext *ctx, qint64 key, QGLTexture *texture, int cost); - void remove(quint64 key) { m_cache.remove(key); } + inline void remove(quint64 key); + inline int size(); + inline void setMaxCost(int newMax); + inline int maxCost(); + inline QGLTexture* getTexture(quint64 key); + bool remove(QGLContext *ctx, GLuint textureId); void removeContextTextures(QGLContext *ctx); - int size() { return m_cache.size(); } - void setMaxCost(int newMax) { m_cache.setMaxCost(newMax); } - int maxCost() {return m_cache.maxCost(); } - QGLTexture* getTexture(quint64 key) { return m_cache.object(key); } - static QGLTextureCache *instance(); static void deleteIfEmpty(); static void imageCleanupHook(qint64 cacheKey); @@ -544,8 +544,38 @@ public: private: QCache<qint64, QGLTexture> m_cache; + QReadWriteLock m_lock; }; +int QGLTextureCache::size() { + QReadLocker locker(&m_lock); + return m_cache.size(); +} + +void QGLTextureCache::setMaxCost(int newMax) +{ + QWriteLocker locker(&m_lock); + m_cache.setMaxCost(newMax); +} + +int QGLTextureCache::maxCost() +{ + QReadLocker locker(&m_lock); + return m_cache.maxCost(); +} + +QGLTexture* QGLTextureCache::getTexture(quint64 key) +{ + QReadLocker locker(&m_lock); + return m_cache.object(key); +} + +void QGLTextureCache::remove(quint64 key) +{ + QWriteLocker locker(&m_lock); + m_cache.remove(key); +} + extern Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine(); |