Workaround for distance field glyph upload problem.
authorYoann Lopes <yoann.lopes@digia.com>
Tue, 23 Jul 2013 14:19:57 +0000 (16:19 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 26 Jul 2013 11:56:01 +0000 (13:56 +0200)
It seems uploading an image (into a texture) which has
padding at the end of each scanLine and alpha-only pixel format
is broken with some OpenGL ES drivers.
The workaround is to upload one line at a time.

Task-number: QTBUG-30908
Change-Id: Ic680654951b6aec294c1a173708c1fb75e57ff8f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp

index afea96b..4652a22 100644 (file)
@@ -172,7 +172,8 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage>
             }
         }
 
-        glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, glyph.width(), glyph.height(), GL_ALPHA, GL_UNSIGNED_BYTE, glyph.constBits());
+        for (int i = 0; i < glyph.height(); ++i)
+            glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, glyph.width(), 1, GL_ALPHA, GL_UNSIGNED_BYTE, glyph.scanLine(i));
     }
 
     QHash<TextureInfo *, QVector<glyph_t> >::const_iterator i;
@@ -242,7 +243,8 @@ void QSGDefaultDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int
     updateTexture(oldTexture, texInfo->texture, texInfo->size);
 
     if (useWorkaround()) {
-        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.constBits());
+        for (int i = 0; i < oldHeight; ++i)
+            glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, oldWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.scanLine(i));
         texInfo->image = texInfo->image.copy(0, 0, width, height);
         glDeleteTextures(1, &oldTexture);
         return;