From af48e0ba36aed330e8b262687e3192d7e09796f7 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 23 Jan 2012 15:06:41 +0100 Subject: Move glyphMargin() to QFontEngine glyphMargin() support for QTextureGlyphCache is implemented in respective font engines, thus this function is platform dependent. Before Qt 5 the code is guarded in macros like #ifdef Q_WS_MAC, now we should move them into QFontEngine and its subclasses. So far only Windows font engines support it. FreeType and Core Text based font engines all ignore it. Change-Id: Ia14016533d8fbfaacf848a7d3bc928f8197318f5 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/opengl') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0ae3a18e44..c20a9c1f7a 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1569,11 +1569,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp void *cacheKey = const_cast(QGLContextPrivate::contextGroup(ctx)->context()); bool recreateVertexArrays = false; + QFontEngine *fe = staticTextItem->fontEngine(); QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) staticTextItem->fontEngine()->glyphCache(cacheKey, glyphType, QTransform()); + (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, QTransform()); if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) { cache = new QGLTextureGlyphCache(glyphType, QTransform()); - staticTextItem->fontEngine()->setGlyphCache(cacheKey, cache); + fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; } @@ -1597,11 +1598,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp // cache so this text is performed before we test if the cache size has changed. if (recreateVertexArrays) { cache->setPaintEnginePrivate(this); - if (!cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs, + if (!cache->populate(fe, staticTextItem->numGlyphs, staticTextItem->glyphs, staticTextItem->glyphPositions)) { // No space for glyphs in cache. We need to reset it and try again. cache->clear(); - cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs, + cache->populate(fe, staticTextItem->numGlyphs, staticTextItem->glyphs, staticTextItem->glyphPositions); } cache->fillInPendingGlyphs(); @@ -1612,7 +1613,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp transferMode(TextDrawingMode); - int margin = cache->glyphMargin(); + int margin = fe->glyphMargin(glyphType); GLfloat dx = 1.0 / cache->width(); GLfloat dy = 1.0 / cache->height(); @@ -1652,11 +1653,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp vertexCoordinates->clear(); textureCoordinates->clear(); - bool supportsSubPixelPositions = staticTextItem->fontEngine()->supportsSubPixelPositions(); + bool supportsSubPixelPositions = fe->supportsSubPixelPositions(); for (int i=0; inumGlyphs; ++i) { QFixed subPixelPosition; if (supportsSubPixelPositions) - subPixelPosition = staticTextItem->fontEngine()->subPixelPositionForX(staticTextItem->glyphPositions[i].x); + subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x); QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition); -- cgit v1.2.3