Use the texture coordinates provided by QSGTexture
authorAlan Alpert <alan.alpert@nokia.com>
Tue, 29 May 2012 10:44:14 +0000 (20:44 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 5 Jun 2012 01:22:18 +0000 (03:22 +0200)
Change-Id: I24e377ba69b2108f3bc4f6aca3ed910fbbf77caf
Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
src/quick/items/qquickanimatedsprite.cpp
src/quick/items/qquickspritesequence.cpp

index 0e37020..724ae75 100644 (file)
@@ -526,18 +526,19 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode()
 
     AnimatedSpriteVertices *p = (AnimatedSpriteVertices *) g->vertexData();
 
-    p->v1.tx = 0;
-    p->v1.ty = 0;
+    QRectF texRect = m_material->texture->normalizedTextureSubRect();
 
-    p->v2.tx = 1.0;
-    p->v2.ty = 0;
+    p->v1.tx = texRect.topLeft().x();
+    p->v1.ty = texRect.topLeft().y();
 
-    p->v3.tx = 0;
-    p->v3.ty = 1.0;
+    p->v2.tx = texRect.topRight().x();
+    p->v2.ty = texRect.topRight().y();
 
-    p->v4.tx = 1.0;
-    p->v4.ty = 1.0;
+    p->v3.tx = texRect.bottomLeft().x();
+    p->v3.ty = texRect.bottomLeft().y();
 
+    p->v4.tx = texRect.bottomRight().x();
+    p->v4.ty = texRect.bottomRight().y();
 
     quint16 *indices = g->indexDataAsUShort();
     indices[0] = 0;
index 1112cf9..69daab7 100644 (file)
@@ -385,18 +385,19 @@ QSGGeometryNode* QQuickSpriteSequence::buildNode()
     g->setDrawingMode(GL_TRIANGLES);
 
     SpriteVertices *p = (SpriteVertices *) g->vertexData();
+    QRectF texRect = m_material->texture->normalizedTextureSubRect();
 
-    p->v1.tx = 0;
-    p->v1.ty = 0;
+    p->v1.tx = texRect.topLeft().x();
+    p->v1.ty = texRect.topLeft().y();
 
-    p->v2.tx = 1.0;
-    p->v2.ty = 0;
+    p->v2.tx = texRect.topRight().x();
+    p->v2.ty = texRect.topRight().y();
 
-    p->v3.tx = 0;
-    p->v3.ty = 1.0;
+    p->v3.tx = texRect.bottomLeft().x();
+    p->v3.ty = texRect.bottomLeft().y();
 
-    p->v4.tx = 1.0;
-    p->v4.ty = 1.0;
+    p->v4.tx = texRect.bottomRight().x();
+    p->v4.ty = texRect.bottomRight().y();
 
     quint16 *indices = g->indexDataAsUShort();
     indices[0] = 0;