From 2406a8b45f2ba25ab250d36f520dd903b88189f2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 12 May 2014 18:11:25 +0200 Subject: Remove an unused workaround and fix up the comments in the glyph cache This old workaround is not necessary and could not be used anyhow since it would affect a way too wide range of drivers. Modern drivers should be able to honor the default GL_UNPACK_ALIGNMENT of 4 even for 1 byte per pixel formats like GL_ALPHA. Instead, document why the behavior is correct. Change-Id: I1687448ba92875c8ff772ccc371894e88ff64096 Reviewed-by: Gunnar Sletta --- src/gui/opengl/qopengltextureglyphcache.cpp | 31 ++--------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp index ac88d9d3a5..f721d5cb8c 100644 --- a/src/gui/opengl/qopengltextureglyphcache.cpp +++ b/src/gui/opengl/qopengltextureglyphcache.cpp @@ -408,41 +408,14 @@ void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed #endif funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, fmt, 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. - -#if 0 - if (!ctx->d_func()->workaround_brokenAlphaTexSubImage_init) { - // don't know which driver versions exhibit this bug, so be conservative for now - const QByteArray versionString(reinterpret_cast(glGetString(GL_VERSION))); - glctx->d_func()->workaround_brokenAlphaTexSubImage = versionString.indexOf("NVIDIA") >= 0; - glctx->d_func()->workaround_brokenAlphaTexSubImage_init = true; - } -#endif - -#if 0 - if (ctx->d_func()->workaround_brokenAlphaTexSubImage) { - for (int i = 0; i < maskHeight; ++i) - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); - } else { -#endif - + // The scanlines in mask are 32-bit aligned, even for mono or 8-bit formats. This + // is good because it matches the default of 4 bytes for GL_UNPACK_ALIGNMENT. #if !defined(QT_OPENGL_ES_2) const GLenum format = isCoreProfile() ? GL_RED : GL_ALPHA; #else const GLenum format = GL_ALPHA; #endif funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, format, GL_UNSIGNED_BYTE, mask.bits()); - -#if 0 - } -#endif } } -- cgit v1.2.3