diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-08-11 11:13:25 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-08-11 13:16:22 (GMT) |
commit | ca28af7c530e60f55556aa7efc6fe19660be53b1 (patch) | |
tree | 799f2d46fb03bc3f62bbdcd0e4ede233d04d2525 /src/opengl | |
parent | cd649261f902c96c065d44591f6ee76a9b2be5dc (diff) | |
download | Qt-ca28af7c530e60f55556aa7efc6fe19660be53b1.zip Qt-ca28af7c530e60f55556aa7efc6fe19660be53b1.tar.gz Qt-ca28af7c530e60f55556aa7efc6fe19660be53b1.tar.bz2 |
Fixed uploading of glyphs to the glyph cache in the GL2 engine.
Upload the glyph one scanline at a time to work around what probably is
a driver bug. This replaces a previous fix
6d0290b2202d4fc084595ba678c2a2d984392e72.
Reviewed-by: Tom
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a3475c7..3f14fdf 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -261,11 +261,21 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) if (mask.format() == QImage::Format_RGB32) { glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, m_height - c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); } else { - // If the width of the uploaded data is not a multiple of four bytes, we get some garbage - // in the glyph cache, probably because of a driver bug. - // Convert to ARGB32 to get a multiple of 4 bytes per line. - mask = mask.convertToFormat(QImage::Format_ARGB32); - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); +#ifdef QT_OPENGL_ES2 + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); +#else + // glTexSubImage2D() might cause some garbage to appear in the texture if the mask width is + // not a multiple of four bytes. The bug appeared on a computer with 32-bit Windows Vista + // and nVidia GeForce 8500GT. GL_UNPACK_ALIGNMENT is set to four bytes, 'mask' has a + // multiple of four bytes per line, and most of the glyph shows up correctly in the + // texture, which makes me think that this is a driver bug. + // One workaround is to make sure the mask width is a multiple of four bytes, for instance + // by converting it to a format with four bytes per pixel. Another is to copy one line at a + // time. + + for (uint i = 0; i < maskHeight; ++i) + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); +#endif } } |