Have separate texture hashes for each window
Apparently in nvidia we get corruptions when a texture created for a window is used in another one. With this patch we tell the texture has changed when we move it from a window to another, so it's re-created and we keep textures for all windows separately. This way we ensure they don't mix. REVIEW: 119465
This commit is contained in:
parent
712de91021
commit
ebe9011253
@ -37,17 +37,23 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
typedef QHash<qint64, QWeakPointer<QSGTexture> > TexturesCache;
|
||||
typedef QHash<qint64, QHash<QWindow*, QWeakPointer<QSGTexture> > > TexturesCache;
|
||||
Q_GLOBAL_STATIC(TexturesCache, s_cache)
|
||||
|
||||
QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image)
|
||||
{
|
||||
qint64 id = image.cacheKey();
|
||||
QSharedPointer<QSGTexture> texture = s_cache->value(id).toStrongRef();
|
||||
QSharedPointer<QSGTexture> texture = s_cache->value(id).value(window).toStrongRef();
|
||||
if (!texture) {
|
||||
auto cleanAndDelete = [id](QSGTexture* texture) { s_cache->remove(id); delete texture; };
|
||||
auto cleanAndDelete = [window, id](QSGTexture* texture) {
|
||||
QHash<QWindow*, QWeakPointer<QSGTexture> >& textures = (*s_cache)[id];
|
||||
textures.remove(window);
|
||||
if (textures.isEmpty())
|
||||
s_cache->remove(id);
|
||||
delete texture;
|
||||
};
|
||||
texture = QSharedPointer<QSGTexture>(window->createTextureFromImage(image), cleanAndDelete);
|
||||
s_cache->insert(id, texture.toWeakRef());
|
||||
(*s_cache)[id][window] = texture.toWeakRef();
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user