summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-11-16 12:27:57 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-11-16 13:11:45 (GMT)
commita40e77495612db0b89730debbacc585a22d0eb3a (patch)
tree1102634dabfaecb832b8007e282aa0af878f173e /src/opengl
parent32817efdfec402f2e839535c326a49f884cb984f (diff)
downloadQt-a40e77495612db0b89730debbacc585a22d0eb3a.zip
Qt-a40e77495612db0b89730debbacc585a22d0eb3a.tar.gz
Qt-a40e77495612db0b89730debbacc585a22d0eb3a.tar.bz2
Fix possible missing glyphs in text when using GL engine
If you create/destroy gl contexts a lot, you may sometimes get a new context with the same pointer as a destroyed context. When you look up the glyph cache in the font engine using the context pointer as a key, you will then get a glyph cache which contains no valid data. We need to reset the glyph cache completely in this case and set up bindings for the new context so that the glyph cache can be repopulated and reused. Note that there is a different solution for this in Qt 4.8, so this is temporary solution for the Qt 4.7.x series. Task-number: QT-4162 Reviewed-by: Fabien Freling
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp2
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp9
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h15
3 files changed, 24 insertions, 2 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 1dcb773..73915cb 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1479,6 +1479,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
if (!cache || cache->cacheType() != glyphType) {
cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform());
staticTextItem->fontEngine()->setGlyphCache(ctx, cache);
+ } else if (cache->context() == 0) { // Old context has been destroyed, new context has same ptr value
+ cache->setContext(ctx);
}
bool recreateVertexArrays = false;
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index 919c542..28e8c40 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -54,11 +54,18 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled;
QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix)
: QImageTextureGlyphCache(type, matrix)
- , ctx(context)
+ , ctx(0)
, m_width(0)
, m_height(0)
, m_filterMode(Nearest)
{
+ setContext(context);
+}
+
+void QGLTextureGlyphCache::setContext(QGLContext *context)
+{
+ ctx = context;
+
// broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where
// copying between FBO's is broken if the texture is either GL_ALPHA or POT. The
// workaround is to use a system-memory copy of the glyph cache for this device.
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index e22146d..fa2b091 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -90,6 +90,9 @@ public:
FilterMode filterMode() const { return m_filterMode; }
void setFilterMode(FilterMode m) { m_filterMode = m; }
+ void setContext(QGLContext *context);
+ QGLContext *context() const { return ctx; }
+
public Q_SLOTS:
void contextDestroyed(const QGLContext *context) {
if (context == ctx) {
@@ -98,10 +101,20 @@ public Q_SLOTS:
// the context may not be current, so we cannot directly
// destroy the fbo and texture here, but since the context
// is about to be destroyed, the GL server will do the
- // clean up for us anyway
+ // clean up for us anyway. We reset everything, so that the
+ // glyph cache object can be reused later by setting a new
+ // context on it.
m_fbo = 0;
m_texture = 0;
ctx = 0;
+ m_width = 0;
+ m_height = 0;
+ m_w = 0;
+ m_h = 0;
+ m_cx = 0;
+ m_cy = 0;
+ m_currentRowHeight = 0;
+ coords.clear();
} else {
// since the context holding the texture is shared, and
// about to be destroyed, we have to transfer ownership