From fc0098905f170268a649a835ce6d79050ffb6ac9 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 26 Mar 2013 09:15:10 -0500 Subject: Provide workaround to slow glyph cache updates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The environmental variable QML_USE_GLYPHCACHE_WORKAROUND can be specified to use the workaround path, which performs better on some hardware. Task-number: QTBUG-29264 Change-Id: I16d35ceabc12c990e4f791693ec4694f4e7f55f7 Reviewed-by: Samuel Rødal Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp') diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index a424f257cd..afea96b35c 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp @@ -43,12 +43,15 @@ #include #include +#include #include #include #include QT_BEGIN_NAMESPACE +DEFINE_BOOL_CONFIG_OPTION(qmlUseGlyphCacheWorkaround, QML_USE_GLYPHCACHE_WORKAROUND) + QSGDefaultDistanceFieldGlyphCache::QSGDefaultDistanceFieldGlyphCache(QSGDistanceFieldGlyphCacheManager *man, QOpenGLContext *c, const QRawFont &font) : QSGDistanceFieldGlyphCache(man, c, font) , m_maxTextureSize(0) @@ -159,7 +162,7 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash if (glyph.width() != expectedWidth) glyph = glyph.copy(0, 0, expectedWidth, glyph.height()); - if (useWorkaroundBrokenFBOReadback()) { + if (useWorkaround()) { uchar *inBits = glyph.scanLine(0); uchar *outBits = texInfo->image.scanLine(int(c.y)) + int(c.x); for (int y = 0; y < glyph.height(); ++y) { @@ -193,7 +196,7 @@ void QSGDefaultDistanceFieldGlyphCache::releaseGlyphs(const QSet &glyph void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo, int width, int height) { - if (useWorkaroundBrokenFBOReadback() && texInfo->image.isNull()) + if (useWorkaround() && texInfo->image.isNull()) texInfo->image = QImage(width, height, QImage::Format_Indexed8); while (glGetError() != GL_NO_ERROR) { } @@ -238,7 +241,7 @@ void QSGDefaultDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int updateTexture(oldTexture, texInfo->texture, texInfo->size); - if (useWorkaroundBrokenFBOReadback()) { + if (useWorkaround()) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.constBits()); texInfo->image = texInfo->image.copy(0, 0, width, height); glDeleteTextures(1, &oldTexture); @@ -332,13 +335,14 @@ void QSGDefaultDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR)); } -bool QSGDefaultDistanceFieldGlyphCache::useWorkaroundBrokenFBOReadback() const +bool QSGDefaultDistanceFieldGlyphCache::useWorkaround() const { static bool set = false; static bool useWorkaround = false; if (!set) { QOpenGLContextPrivate *ctx_p = static_cast(QOpenGLContextPrivate::get(ctx)); - useWorkaround = ctx_p->workaround_brokenFBOReadBack; + useWorkaround = ctx_p->workaround_brokenFBOReadBack + || qmlUseGlyphCacheWorkaround(); // on some hardware the workaround is faster (see QTBUG-29264) set = true; } return useWorkaround; -- cgit v1.2.3