From: Michael Brasser Date: Tue, 26 Mar 2013 14:15:10 +0000 (-0500) Subject: Provide workaround to slow glyph cache updates. X-Git-Tag: upstream/5.2.1~810^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc0098905f170268a649a835ce6d79050ffb6ac9;p=platform%2Fupstream%2Fqtdeclarative.git Provide workaround to slow glyph cache updates. 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 --- diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index a424f25..afea96b 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; diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h index b1eea1f..ef722d8 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h @@ -62,7 +62,7 @@ public: void referenceGlyphs(const QSet &glyphs); void releaseGlyphs(const QSet &glyphs); - bool useWorkaroundBrokenFBOReadback() const; + bool useWorkaround() const; int maxTextureSize() const; void setMaxTextureCount(int max) { m_maxTextureCount = max; }