diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> | 2014-08-29 15:40:52 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2014-08-30 09:57:37 +0200 |
commit | cf44ee7761f2e4175f9193b42ee7296a2f3b694a (patch) | |
tree | 0abcff129f905050da3bc47d0e338bdfd77cf60f /src/quick/scenegraph/util/qsgatlastexture.cpp | |
parent | 8f3311276e4ca44acb69c8870ccfc3167682b898 (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>
Diffstat (limited to 'src/quick/scenegraph/util/qsgatlastexture.cpp')
-rw-r--r-- | src/quick/scenegraph/util/qsgatlastexture.cpp | 11 |
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); + } } |