From ebe901125335ba32a9cc920e88a382509fdbd121 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 28 Jul 2014 19:01:33 +0200 Subject: [PATCH] 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 --- src/declarativeimports/core/framesvgitem.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index ebac29f14..af4ddf29a 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -37,17 +37,23 @@ namespace Plasma { -typedef QHash > TexturesCache; +typedef QHash > > TexturesCache; Q_GLOBAL_STATIC(TexturesCache, s_cache) QSharedPointer loadTexture(QQuickWindow *window, const QImage &image) { qint64 id = image.cacheKey(); - QSharedPointer texture = s_cache->value(id).toStrongRef(); + QSharedPointer 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 >& textures = (*s_cache)[id]; + textures.remove(window); + if (textures.isEmpty()) + s_cache->remove(id); + delete texture; + }; texture = QSharedPointer(window->createTextureFromImage(image), cleanAndDelete); - s_cache->insert(id, texture.toWeakRef()); + (*s_cache)[id][window] = texture.toWeakRef(); } return texture; }