summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengine_raster.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-06-01 11:06:55 +0200
committerQt Continuous Integration System <qt-info@nokia.com>2011-06-03 10:57:42 +0200
commit43c0e08ba2e3487840b4063b2099bc17cdd4dce2 (patch)
treed07d1a6a52af2a661c90fd743c6d6865210bd082 /src/gui/painting/qpaintengine_raster.cpp
parentc8dead71865de3e09414c413faa38b53df09223b (diff)
Refactor glyph pretransform check
Move paintEngineSupportsTransformations logic from QPainter to paint engine subclasses. Simplify and consolidate checks for cached drawing (pretransformed) and path drawing (untransformed) in raster paint engine. Fix unnecessary transform when paint engines actually take the path drawing track. Fix scaling and rotation transform in raster engine for Mac. Task-number: QTBUG-19086 Change-Id: I1c0c1800a5173d3db765b9fccfd0e7a3628e3815 Reviewed-on: http://codereview.qt.nokia.com/298 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 1f7ab21ca7..f5daef7878 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -3029,11 +3029,8 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
ensurePen();
ensureState();
- QRasterPaintEngineState *s = state();
-
QFontEngine *fontEngine = textItem->fontEngine();
- const qreal pixelSize = fontEngine->fontDef.pixelSize;
- if (pixelSize * pixelSize * qAbs(s->matrix.determinant()) < 64 * 64) {
+ if (!supportsTransformations(fontEngine)) {
drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
fontEngine);
} else {
@@ -3061,36 +3058,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
#if defined (Q_WS_WIN) || defined(Q_WS_MAC)
- bool drawCached = true;
-
- if (s->matrix.type() >= QTransform::TxProject)
- drawCached = false;
-
- // don't try to cache huge fonts
- const qreal pixelSize = ti.fontEngine->fontDef.pixelSize;
- if (pixelSize * pixelSize * qAbs(s->matrix.determinant()) >= 64 * 64)
- drawCached = false;
-
- // ### Remove the TestFontEngine and Box engine crap, in these
- // ### cases we should delegate painting to the font engine
- // ### directly...
-
-#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
- QFontEngine::Type fontEngineType = ti.fontEngine->type();
- // qDebug() << "type" << fontEngineType << s->matrix.type();
- if ((fontEngineType == QFontEngine::Win && !((QFontEngineWin *) ti.fontEngine)->ttf && s->matrix.type() > QTransform::TxTranslate)
- || (s->matrix.type() <= QTransform::TxTranslate
- && (fontEngineType == QFontEngine::TestFontEngine
- || fontEngineType == QFontEngine::Box))) {
- drawCached = false;
- }
-#else
- if (s->matrix.type() > QTransform::TxTranslate)
- drawCached = false;
-#endif
- if (drawCached) {
- QRasterPaintEngineState *s = state();
-
+ if (!supportsTransformations(ti.fontEngine)) {
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
@@ -3386,6 +3354,37 @@ void QRasterPaintEngine::releaseDC(HDC) const
#endif
+bool QRasterPaintEngine::supportsTransformations(const QFontEngine *fontEngine) const
+{
+ const QTransform &m = state()->matrix;
+#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
+ QFontEngine::Type fontEngineType = ti.fontEngine->type();
+ if ((fontEngineType == QFontEngine::Win && !((QFontEngineWin *) ti.fontEngine)->ttf && m.type() > QTransform::TxTranslate)
+ || (m.type() <= QTransform::TxTranslate
+ && (fontEngineType == QFontEngine::TestFontEngine
+ || fontEngineType == QFontEngine::Box))) {
+ return true;
+ }
+#endif
+ return supportsTransformations(fontEngine->fontDef.pixelSize, m);
+}
+
+bool QRasterPaintEngine::supportsTransformations(qreal pixelSize, const QTransform &m) const
+{
+#if defined(Q_WS_MAC)
+ // Mac font engines don't support scaling and rotation
+ if (m.type() > QTransform::TxTranslate)
+#else
+ if (m.type() >= QTransform::TxProject)
+#endif
+ return true;
+
+ if (pixelSize * pixelSize * qAbs(m.determinant()) >= 64 * 64)
+ return true;
+
+ return false;
+}
+
/*!
\internal
*/