File 0002-Support-padding-in-images-stored-in-atlas-texture.patch of Package libqt5-qtdeclarative

From cf44ee7761f2e4175f9193b42ee7296a2f3b694a Mon Sep 17 00:00:00 2001
From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Date: Fri, 29 Aug 2014 15:40:52 +0200
Subject: [PATCH 2/6] Support padding in images stored in atlas texture

If the stride does not match the width of the image, we upload
it line-by-line instead of as one big rect.

Change-Id: I5e08afcf5c35dc810fed25e45255d55d932b2a4c
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
---
 src/quick/scenegraph/util/qsgatlastexture.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
index 782beca..53b3110 100644
--- a/src/quick/scenegraph/util/qsgatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgatlastexture.cpp
@@ -319,7 +319,16 @@ void Atlas::uploadBgra(Texture *texture)
     glTexSubImage2D(GL_TEXTURE_2D, 0, r.x() + iw + 1, r.y() + 1, 1, ih, m_externalFormat, GL_UNSIGNED_BYTE, dst);
 
     // Inner part of the image....
-    glTexSubImage2D(GL_TEXTURE_2D, 0, r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, m_externalFormat, GL_UNSIGNED_BYTE, src);
+    if (bpl != iw) {
+        int sy = r.y() + 1;
+        int ey = sy + r.height() - 2;
+        for (int y = sy; y < ey; ++y) {
+            glTexSubImage2D(GL_TEXTURE_2D, 0, r.x() + 1, y, r.width() - 2, 1, m_externalFormat, GL_UNSIGNED_BYTE, src);
+            src += bpl;
+        }
+    } else {
+        glTexSubImage2D(GL_TEXTURE_2D, 0, r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, m_externalFormat, GL_UNSIGNED_BYTE, src);
+    }
 
 }
 
-- 
2.1.0

openSUSE Build Service is sponsored by