diff options
author | Harald Fernengel <harald.fernengel@nokia.com> | 2010-12-07 14:19:37 (GMT) |
---|---|---|
committer | Harald Fernengel <harald.fernengel@nokia.com> | 2010-12-07 14:19:37 (GMT) |
commit | 82ae06cf32514ae60ce5b9c04a48a4619c2252e0 (patch) | |
tree | 3da263d6ff809c64bd272736536e439188e96592 /src/opengl | |
parent | 71f8955e0a2744bccff94495c4db5e054db8ab95 (diff) | |
download | Qt-82ae06cf32514ae60ce5b9c04a48a4619c2252e0.zip Qt-82ae06cf32514ae60ce5b9c04a48a4619c2252e0.tar.gz Qt-82ae06cf32514ae60ce5b9c04a48a4619c2252e0.tar.bz2 |
Optimize behavior of QGLTextureCache
When we iterate over the cache to figure out which objects to remove,
we would change the internal order of the cache,
leading to a suboptimal caching behavior.
Instead, let QCache decide which objects to remove when the cache
overflows, based on its internal last-recently-used algorithm.
Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index dc7a333..63df8c3 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1853,18 +1853,6 @@ QGLTextureCache::~QGLTextureCache() void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost) { QWriteLocker locker(&m_lock); - if (m_cache.totalCost() + cost > m_cache.maxCost()) { - // the cache is full - make an attempt to remove something - const QList<QGLTextureCacheKey> keys = m_cache.keys(); - int i = 0; - while (i < m_cache.count() - && (m_cache.totalCost() + cost > m_cache.maxCost())) { - QGLTexture *tex = m_cache.object(keys.at(i)); - if (tex->context == ctx) - m_cache.remove(keys.at(i)); - ++i; - } - } const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)}; m_cache.insert(cacheKey, texture, cost); } |