diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2012-06-06 17:52:19 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-08 13:11:24 +0200 |
commit | 2fdc5e044c967ac7044a3b5814110469da20f6e4 (patch) | |
tree | a216d38886929766cb96421d7664f34d30dd1ce7 /src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h | |
parent | 1535da8a5923b5829b945cc9fd1dee4cdfbcfe5e (diff) |
Support for variable glyph width in QSGDefaultDistanceFieldGlyphCache.
The glyphs are not stored in a fixed 64x64px tile anymore.
Glyphs are stored in area equal to <glyph_width> + 10 (margin) x 64px.
Allocation is now done with QSGAreaAllocator.
When glyph recycling is needed, unused glyphs are freed until the new
glyph can fit in the cache.
Change-Id: I179a8f17bfe35468bdb63bca5113ea4d0f06c414
Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h')
-rw-r--r-- | src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h index 5c38c1b656..c109280d0d 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h @@ -46,6 +46,7 @@ #include <QtGui/qopenglfunctions.h> #include <qopenglshaderprogram.h> #include <QtGui/private/qopenglengineshadersource_p.h> +#include <private/qsgareaallocator_p.h> QT_BEGIN_NAMESPACE @@ -60,10 +61,6 @@ public: void referenceGlyphs(const QSet<glyph_t> &glyphs); void releaseGlyphs(const QSet<glyph_t> &glyphs); - bool cacheIsFull() const { - return m_textures.count() == m_maxTextureCount - && textureIsFull(m_currentTexture); - } bool useWorkaroundBrokenFBOReadback() const; int maxTextureSize() const; @@ -74,22 +71,22 @@ private: struct TextureInfo { GLuint texture; QSize size; - int currX; - int currY; + QRect allocatedArea; QImage image; - TextureInfo() : texture(0), currX(0), currY(0) + TextureInfo() : texture(0) { } }; void createTexture(TextureInfo * texInfo, int width, int height); void resizeTexture(TextureInfo * texInfo, int width, int height); - bool textureIsFull (const TextureInfo *tex) const { return tex->currY >= maxTextureSize(); } - TextureInfo *createTextureInfo() + TextureInfo *textureInfo(int index) { - m_textures.append(TextureInfo()); - return &m_textures.last(); + for (int i = m_textures.count(); i <= index; ++i) + m_textures.append(TextureInfo()); + + return &m_textures[index]; } void createBlitProgram() @@ -123,12 +120,13 @@ private: mutable int m_maxTextureSize; int m_maxTextureCount; - TextureInfo *m_currentTexture; QList<TextureInfo> m_textures; QHash<glyph_t, TextureInfo *> m_glyphsTexture; GLuint m_fbo; QSet<glyph_t> m_unusedGlyphs; + QSGAreaAllocator *m_areaAllocator; + QOpenGLShaderProgram *m_blitProgram; GLfloat m_blitVertexCoordinateArray[8]; GLfloat m_blitTextureCoordinateArray[8]; |