QHash<glyph_t, Metrics>::iterator metric = m_metrics.find(glyph);
if (metric == m_metrics.end()) {
QPainterPath path = m_font.pathForGlyph(glyph);
+ QRectF br = path.boundingRect();
Metrics m;
- m.width = path.boundingRect().width();
- m.height = path.boundingRect().height();
- m.baselineX = path.boundingRect().x();
- m.baselineY = -path.boundingRect().y();
+ m.width = br.width();
+ m.height = br.height();
+ m.baselineX = br.x();
+ m.baselineY = -br.y();
metric = m_metrics.insert(glyph, m);
}
m_textureData->texCoords.insert(glyphIndex, TexCoord());
continue;
}
+ QRectF br = path.boundingRect();
TexCoord c;
c.xMargin = QT_DISTANCEFIELD_RADIUS / qreal(QT_DISTANCEFIELD_SCALE);
c.yMargin = QT_DISTANCEFIELD_RADIUS / qreal(QT_DISTANCEFIELD_SCALE);
c.x = m_textureData->currX;
c.y = m_textureData->currY;
- c.width = path.boundingRect().width();
- c.height = path.boundingRect().height();
+ c.width = br.width();
+ c.height = br.height();
if (!cacheIsFull()) {
m_textureData->currX += QT_DISTANCEFIELD_TILESIZE;
if (c.y < maxTextureSize()) {
m_textureData->texCoords.insert(glyphIndex, c);
- m_textureData->pendingGlyphs.insert(glyphIndex);
+ m_textureData->pendingGlyphs.add(glyphIndex);
}
}
}
resizeTexture((requiredWidth), (requiredHeight));
glBindTexture(GL_TEXTURE_2D, m_textureData->texture);
- QSet<glyph_t>::const_iterator i = m_textureData->pendingGlyphs.constBegin();
- for (; i != m_textureData->pendingGlyphs.constEnd(); ++i) {
- QImage glyph = renderDistanceFieldGlyph(*i);
- TexCoord c = m_textureData->texCoords.value(*i);
+ for (int i = 0; i < m_textureData->pendingGlyphs.size(); ++i) {
+ glyph_t glyphIndex = m_textureData->pendingGlyphs.at(i);
+ QImage glyph = renderDistanceFieldGlyph(glyphIndex);
+ TexCoord c = m_textureData->texCoords.value(glyphIndex);
if (ctx->d_ptr->workaround_brokenFBOReadBack) {
QPainter p(&m_textureData->image);
convert_to_Format_Alpha(&glyph);
glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, glyph.width(), glyph.height(), GL_ALPHA, GL_UNSIGNED_BYTE, glyph.constBits());
}
- m_textureData->pendingGlyphs.clear();
+ m_textureData->pendingGlyphs.reset();
}
bool QSGDistanceFieldGlyphCache::useWorkaroundBrokenFBOReadback() const
#include <private/qgl_p.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
+#include <QtGui/private/qdatabuffer_p.h>
QT_BEGIN_NAMESPACE
GLuint fbo;
QSize size;
QHash<glyph_t, TexCoord> texCoords;
- QSet<glyph_t> pendingGlyphs;
+ QDataBuffer<glyph_t> pendingGlyphs;
QHash<glyph_t, quint32> glyphRefCount;
QSet<glyph_t> unusedGlyphs;
int currX;
DistanceFieldTextureData(const QGLContext *)
: texture(0)
, fbo(0)
+ , pendingGlyphs(64)
, currX(0)
, currY(0)
, doubleGlyphResolution(false)