Enable glyph caching on QPA
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Fri, 16 Sep 2011 12:16:44 +0000 (14:16 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Sep 2011 08:24:25 +0000 (10:24 +0200)
The glyph caching was disabled on QPA, possibly due to some
bugs which have gone away now. To avoid the performance hit
of this, we need to enable it. Simple tests of QTextEdit
indicate that this works fine.

Change-Id: I40845b327331b366161f1ca55bf00853bca87358
Reviewed-on: http://codereview.qt-project.org/5096
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/gui/painting/qpaintengine_raster.cpp

index 4d4b88b..62701eb 100644 (file)
@@ -3031,7 +3031,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
     ensurePen();
     ensureState();
 
-#if defined (Q_WS_WIN) || defined(Q_WS_MAC)
+#if defined (Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
 
     if (!supportsTransformations(ti.fontEngine)) {
         QVarLengthArray<QFixedPoint> positions;
@@ -3046,45 +3046,17 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
         return;
     }
 
-#elif defined (Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) // Q_OS_WIN || Q_WS_MAC
+#elif defined (Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) // Q_OS_WIN || Q_WS_MAC || Q_WS_QPA
     if (s->matrix.type() <= QTransform::TxTranslate
         || (s->matrix.type() == QTransform::TxScale
                 && (qFuzzyCompare(s->matrix.m11(), s->matrix.m22())))) {
         drawGlyphsS60(p, ti);
         return;
     }
-#else // Q_OS_WIN || Q_WS_MAC
+#else // Q_OS_WIN || Q_WS_MAC || Q_WS_QPA
 
     QFontEngine *fontEngine = ti.fontEngine;
 
-#ifdef Q_WS_QPA
-    if (s->matrix.type() < QTransform::TxScale) {
-
-        QVarLengthArray<QFixedPoint> positions;
-        QVarLengthArray<glyph_t> glyphs;
-        QTransform matrix = state()->transform();
-
-        qreal _x = qFloor(p.x());
-        qreal _y = qFloor(p.y());
-        matrix.translate(_x, _y);
-
-        fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
-        if (glyphs.size() == 0)
-            return;
-
-        for(int i = 0; i < glyphs.size(); i++) {
-            QImage img = fontEngine->alphaMapForGlyph(glyphs[i]);
-            glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[i]);
-            // ### hm, perhaps an QFixed offs = QFixed::fromReal(aliasedCoordinateDelta) is needed here?
-            alphaPenBlt(img.bits(), img.bytesPerLine(), img.depth(),
-                                         qRound(positions[i].x + metrics.x),
-                                         qRound(positions[i].y + metrics.y),
-                                         img.width(), img.height());
-        }
-        return;
-    }
-#endif //Q_WS_QPA
-
 #if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
 
     if (fontEngine->type() != QFontEngine::Freetype) {