aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-08-29 15:40:52 +0200
committerGunnar Sletta <gunnar@sletta.org>2014-08-30 09:57:37 +0200
commitcf44ee7761f2e4175f9193b42ee7296a2f3b694a (patch)
tree0abcff129f905050da3bc47d0e338bdfd77cf60f
parent8f3311276e4ca44acb69c8870ccfc3167682b898 (diff)
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>
-rw-r--r--src/quick/scenegraph/util/qsgatlastexture.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
index 782beca1de..53b31104b3 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);
+ }
}