Fix material compare for distance field glyph nodes.
authorGlenn Watson <glenn.watson@nokia.com>
Wed, 29 Feb 2012 22:57:32 +0000 (08:57 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 1 Mar 2012 06:55:06 +0000 (07:55 +0100)
The compare function did not take into account the GL texture ID
when comparing materials. This could result in a renderer
merging glyph nodes into a single batch incorrectly.

Change-Id: Ib62c43f93fb1bbbc231197323dced4254ffa12aa
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp

index e525d2a..f9c8349 100644 (file)
@@ -233,7 +233,11 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const
     }
     QRgb c1 = m_color.rgba();
     QRgb c2 = other->m_color.rgba();
-    return int(c2 < c1) - int(c1 < c2);
+    if (c1 != c2)
+        return int(c2 < c1) - int(c1 < c2);
+    int t0 = m_texture ? m_texture->textureId : -1;
+    int t1 = other->m_texture ? other->m_texture->textureId : -1;
+    return t0 - t1;
 }