Add begin-end virtuals to the internal glyph cache

Just having a single fillTexture() is not sufficient for efficient
operation with modern, low-level graphics APIs.

Having a begin-end pair of functions that are invoked before the stream of
calls to fillTexture allow glyph caches to build command lists and defer
command submission until it is known that all pending glyphs have been
processed.

Change-Id: Ifac645f83e9cfb6f246be9c8e79e5aa3bde5758d
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2016-03-16 11:01:28 +01:00
parent b122989e73
commit d64f078173
2 changed files with 4 additions and 0 deletions

View File

@ -247,6 +247,7 @@ void QTextureGlyphCache::fillInPendingGlyphs()
resizeCache(qNextPowerOfTwo(requiredWidth - 1), qNextPowerOfTwo(requiredHeight - 1));
}
beginFillTexture();
{
QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
while (iter != m_pendingGlyphs.end()) {
@ -256,6 +257,7 @@ void QTextureGlyphCache::fillInPendingGlyphs()
++iter;
}
}
endFillTexture();
m_pendingGlyphs.clear();
}

View File

@ -117,7 +117,9 @@ public:
virtual void resizeTextureData(int width, int height) = 0;
virtual int glyphPadding() const { return 0; }
virtual void beginFillTexture() { }
virtual void fillTexture(const Coord &coord, glyph_t glyph, QFixed subPixelPosition) = 0;
virtual void endFillTexture() { }
inline void createCache(int width, int height) {
m_w = width;