Fix QSGSimpleTextureNode's dirty signals for atlas textures
authorGunnar Sletta <gunnar.sletta@digia.com>
Sat, 3 Aug 2013 18:42:44 +0000 (20:42 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 12 Aug 2013 15:03:08 +0000 (17:03 +0200)
When used in an atlas, changing the texture also changes the
geometry.

Change-Id: I744eb0ef58aed9f3a5e51ea89c4da1fad5824633
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
src/quick/scenegraph/util/qsgsimpletexturenode.cpp

index e5b351e..a50cfa9 100644 (file)
@@ -51,9 +51,11 @@ public:
     QSGSimpleTextureNodePrivate()
         : QSGGeometryNodePrivate()
         , m_texCoordMode(QSGSimpleTextureNode::NoTransform)
+        , isAtlasTexture(false)
     {}
 
     QSGSimpleTextureNode::TextureCoordinatesTransformMode m_texCoordMode;
+    uint isAtlasTexture : 1;
 };
 
 static void qsgsimpletexturenode_update(QSGGeometry *g,
@@ -177,7 +179,16 @@ void QSGSimpleTextureNode::setTexture(QSGTexture *texture)
     m_opaque_material.setTexture(texture);
     Q_D(QSGSimpleTextureNode);
     qsgsimpletexturenode_update(&m_geometry, texture, m_rect, d->m_texCoordMode);
-    markDirty(DirtyMaterial);
+
+    DirtyState dirty = DirtyMaterial;
+    // It would be tempting to skip the extra bit here and instead use
+    // m_material.texture to get the old state, but that texture could
+    // have been deleted in the mean time.
+    bool wasAtlas = d->isAtlasTexture;
+    d->isAtlasTexture = texture->isAtlasTexture();
+    if (wasAtlas || d->isAtlasTexture)
+        dirty |= DirtyGeometry;
+    markDirty(dirty);
 }