summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-11-19 11:38:36 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-11-19 11:57:48 (GMT)
commit72f161739b270b01807f97cd853030440f0fd430 (patch)
tree430f86276b70fcc59a839eeff1d7c1b585026017 /src/opengl
parent06d60696fcc88f058b53d08785cc01a580dfb4ed (diff)
downloadQt-72f161739b270b01807f97cd853030440f0fd430.zip
Qt-72f161739b270b01807f97cd853030440f0fd430.tar.gz
Qt-72f161739b270b01807f97cd853030440f0fd430.tar.bz2
Fix possible corrupted text when gl glyph cache becomes full
When the OpenGL glyph cache filled up (the max texture size on the hardware was exceeded) the characters would be drawn as black blocks instead. As a work-around for this, the cache will now be cleared and repopulated whenever this happens, meaning that once in a while (when a lot of different glyphs have been drawn in a font) there will be a performance hit. A more complete solution is described in QTBUG-13784, but this requires so much refactoring that it was deemed too risky for a patch release. This patch fixes the problem with a small penalty and low risk. Task-number: QT-3971 Reviewed-by: Samuel
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp9
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp19
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h2
3 files changed, 27 insertions, 3 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 37552ac..3ddc15a 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1499,8 +1499,13 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
// cache so this text is performed before we test if the cache size has changed.
if (recreateVertexArrays) {
cache->setPaintEnginePrivate(this);
- cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs,
- staticTextItem->glyphs, staticTextItem->glyphPositions);
+ if (!cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs,
+ staticTextItem->glyphs, staticTextItem->glyphPositions)) {
+ // No space in cache. We need to clear the cache and try again
+ cache->clear();
+ cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs,
+ staticTextItem->glyphs, staticTextItem->glyphPositions);
+ }
}
if (cache->width() == 0 || cache->height() == 0)
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index 28e8c40..705ad09 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -78,7 +78,7 @@ void QGLTextureGlyphCache::setContext(QGLContext *context)
SLOT(contextDestroyed(const QGLContext*)));
}
-QGLTextureGlyphCache::~QGLTextureGlyphCache()
+void QGLTextureGlyphCache::clear()
{
if (ctx) {
QGLShareContextScope scope(ctx);
@@ -88,7 +88,24 @@ QGLTextureGlyphCache::~QGLTextureGlyphCache()
if (m_width || m_height)
glDeleteTextures(1, &m_texture);
+
+ m_fbo = 0;
+ m_texture = 0;
+ m_width = 0;
+ m_height = 0;
+ m_w = 0;
+ m_h = 0;
+ m_cx = 0;
+ m_cy = 0;
+ m_currentRowHeight = 0;
+ coords.clear();
}
+
+}
+
+QGLTextureGlyphCache::~QGLTextureGlyphCache()
+{
+ clear();
}
void QGLTextureGlyphCache::createTextureData(int width, int height)
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index fa2b091..aaef350 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -124,6 +124,8 @@ public Q_SLOTS:
}
}
+ void clear();
+
private:
QGLContext *ctx;