summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengine_raster.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index aaa0a4b87e..801a5689c1 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2858,7 +2858,19 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
// x, y,
// positions[i].x.toInt(), positions[i].y.toInt());
- alphaPenBlt(bits + ((c.x << leftShift) >> rightShift) + c.y * bpl, bpl, depth, x, y, c.w, c.h);
+ const uchar *glyphBits = bits + ((c.x << leftShift) >> rightShift) + c.y * bpl;
+
+ if (glyphType == QFontEngineGlyphCache::Raster_ARGB) {
+ // The current state transform has already been applied to the positions,
+ // so we prevent drawImage() from re-applying the transform by clearing
+ // the state for the duration of the call.
+ QTransform originalTransform = s->matrix;
+ s->matrix = QTransform();
+ drawImage(QPoint(x, y), QImage(glyphBits, c.w, c.h, bpl, image.format()));
+ s->matrix = originalTransform;
+ } else {
+ alphaPenBlt(glyphBits, bpl, depth, x, y, c.w, c.h);
+ }
}
}
return true;
@@ -3011,13 +3023,15 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
ensurePen();
ensureRasterState();
+ QTransform matrix = state()->matrix;
+
QFontEngine *fontEngine = textItem->fontEngine();
- if (!supportsTransformations(fontEngine)) {
+ if (shouldDrawCachedGlyphs(fontEngine, matrix)) {
drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
fontEngine);
- } else if (state()->matrix.type() < QTransform::TxProject) {
+ } else if (matrix.type() < QTransform::TxProject) {
bool invertible;
- QTransform invMat = state()->matrix.inverted(&invertible);
+ QTransform invMat = matrix.inverted(&invertible);
if (!invertible)
return;
@@ -3056,7 +3070,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
QRasterPaintEngineState *s = state();
QTransform matrix = s->matrix;
- if (!supportsTransformations(ti.fontEngine)) {
+ if (shouldDrawCachedGlyphs(ti.fontEngine, matrix)) {
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
@@ -3300,21 +3314,25 @@ void QRasterPaintEngine::releaseDC(HDC) const
/*!
\internal
*/
-bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine) const
+bool QRasterPaintEngine::requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const
{
- const QTransform &m = state()->matrix;
- return supportsTransformations(fontEngine, m);
+ // Cached glyphs always require pretransformed positions
+ if (shouldDrawCachedGlyphs(fontEngine, m))
+ return true;
+
+ // Otherwise let the base-class decide based on the transform
+ return QPaintEngineEx::requiresPretransformedGlyphPositions(fontEngine, m);
}
-/*!
- \internal
-*/
-bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const
+bool QRasterPaintEngine::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
{
- if (fontEngine->supportsTransformations(m))
- return true;
+ // The font engine might not support filling the glyph cache
+ // with the given transform applied, in which case we need to
+ // fall back to the QPainterPath code-path.
+ if (!fontEngine->supportsTransformation(m))
+ return false;
- return !shouldDrawCachedGlyphs(fontEngine, m);
+ return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, m);
}
/*!