Texture coordinates fixed in subrect tiling in SG image node.
authorTero Tiittanen <tero.tiittanen@nokia.com>
Tue, 15 Nov 2011 15:05:53 +0000 (17:05 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 16 Nov 2011 06:43:17 +0000 (07:43 +0100)
Fixes the texture coordinates for the inner tiles in a tiling
algorithm that scenegraph default image node uses when texture
is a subrect and image repeats.

Change-Id: Iacf3e63c4c02bdbdc473f8128efecc7908322a50
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>

src/declarative/scenegraph/qsgdefaultimagenode.cpp

index 657f8d0..f30a7e2 100644 (file)
@@ -221,18 +221,23 @@ void QSGDefaultImageNode::updateGeometry()
             float a, b;
             b = m_targetRect.width() / m_sourceRect.width();
             a = m_targetRect.x() - m_sourceRect.x() * b;
+
+            float tex_x1 = textureRect.x();
+            float tex_x2 = textureRect.right();
+            float tex_y1 = textureRect.y();
+            float tex_y2 = textureRect.bottom();
             for (int i = floorLeft + 1; i <= ceilRight - 1; ++i) {
                 xs[0].x = xs[1].x = a + b * i;
-                xs[0].tx = 1;
-                xs[1].tx = 0;
+                xs[0].tx = tex_x2;
+                xs[1].tx = tex_x1;
                 xs += 2;
             }
             b = m_targetRect.height() / m_sourceRect.height();
             a = m_targetRect.y() - m_sourceRect.y() * b;
             for (int i = floorTop + 1; i <= ceilBottom - 1; ++i) {
                 ys[0].y = ys[1].y = a + b * i;
-                ys[0].ty = 1;
-                ys[1].ty = 0;
+                ys[0].ty = tex_y2;
+                ys[1].ty = tex_y1;
                 ys += 2;
             }