diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-03-26 15:56:44 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-03-29 12:10:09 (GMT) |
commit | 3bdff93c991bfabcaa729a89a2b171c562633ced (patch) | |
tree | 552323ceba27a1b8bd5551cda789ded0e7791128 /src/gui | |
parent | 732fbde53bd39d9b99e65e4aad7b028df246fce2 (diff) | |
download | Qt-3bdff93c991bfabcaa729a89a2b171c562633ced.zip Qt-3bdff93c991bfabcaa729a89a2b171c562633ced.tar.gz Qt-3bdff93c991bfabcaa729a89a2b171c562633ced.tar.bz2 |
Implement proper QStaticText support in QPaintBuffer
Use qt_draw_glyphs() to implement a QPaintBuffer::drawStaticText() which
will actually replay via drawStaticTextItem() on engines that support
it.
Task-number: QTBUG-9064
Reviewed-by: Gunnar
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qpaintbuffer.cpp | 33 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 10 |
2 files changed, 29 insertions, 14 deletions
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index ca2077f..e1156dc 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -557,11 +557,7 @@ QString QPaintBuffer::commandDescription(int command) const debug << "Cmd_Translate:" << delta; break; } case QPaintBufferPrivate::Cmd_DrawStaticText: { - QPointF delta(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1)); - QVariantList variants(d_ptr->variants.at(cmd.offset).value<QVariantList>()); - - QStaticText text(variants.at(0).value<QStaticText>()); - debug << "Cmd_DrawStaticText:" << text.text(); + debug << "Cmd_DrawStaticText"; break; } } @@ -1272,13 +1268,14 @@ void QPaintBufferEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con void QPaintBufferEngine::drawStaticTextItem(QStaticTextItem *staticTextItem) { - QString text = QString(staticTextItem->chars, staticTextItem->numChars); + QVariantList variants; - QStaticText staticText(text); - staticText.prepare(state()->matrix, staticTextItem->font); + variants << QVariant(staticTextItem->font); + for (int i=0; i<staticTextItem->numGlyphs; ++i) { + variants.append(staticTextItem->glyphs[i]); + variants.append(staticTextItem->glyphPositions[i].toPointF()); + } - QVariantList variants; - variants << QVariant(staticTextItem->font) << QVariant::fromValue(staticText); buffer->addCommand(QPaintBufferPrivate::Cmd_DrawStaticText, QVariant(variants)); } @@ -1761,11 +1758,19 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) QVariantList variants(d->variants.at(cmd.offset).value<QVariantList>()); - QFont font(variants.at(0).value<QFont>()); - QStaticText text(variants.at(0).value<QStaticText>()); - + QFont font = variants.at(0).value<QFont>(); + + QVector<quint32> glyphs; + QVector<QPointF> positions; + + for (int i=0; i<(variants.size() - 1) / 2; ++i) { + glyphs.append(variants.at(i*2 + 1).toUInt()); + positions.append(variants.at(i*2 + 2).toPointF()); + } + painter->setFont(font); - painter->drawStaticText(QPointF(0, 0), text); + + qt_draw_glyphs(painter, glyphs.constData(), positions.constData(), glyphs.size()); break; } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 93f2265..7b5fcc2 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5720,6 +5720,16 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit QFontEngine *fontEngine = state->font.d->engineForScript(QUnicodeTables::Common); + while (fontEngine->type() == QFontEngine::Multi) { + // Pick engine based on first glyph in array if we are using a multi engine. + // (all glyphs must be for same font) + int engineIdx = 0; + if (glyphCount > 0) + engineIdx = glyphArray[0] >> 24; + + fontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx); + } + QVarLengthArray<QFixedPoint, 128> positions; for (int i=0; i<glyphCount; ++i) { QFixedPoint fp = QFixedPoint::fromPointF(positionArray[i]); |