diff options
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 9 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h | 15 |
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 |