diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2011-05-18 15:10:40 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2011-05-18 15:57:38 +0200 |
commit | f4c1c2f939e1cd6e08197284edb84b202cd6749e (patch) | |
tree | 985fe8d4d137f7f4e6c6951ae1b2c7cd45acea10 /src/gui/painting/qpaintengineex.cpp | |
parent | e8c95790d9d03678f9c0d30a7cc7c2edec6eba81 (diff) | |
download | qtbase-f4c1c2f939e1cd6e08197284edb84b202cd6749e.tar.gz |
Fall back to using paths for large fonts in drawStaticText()
QStaticText had an implicit risk which meant you had to make sure the
text size did not grow unreasonably large. This was intended to avoid
hiding the performance impact of using QStaticText for such a purpose,
but it's too inconvenient. Thus, the same fall back as in drawTextItem()
has been introduced. This will also fix a bug recently introduced when
we started using the FT cache to draw static text in the raster engine,
since this will fail for large fonts.
Task-number: QTBUG-19084, QTBUG-19370
Reviewed-by: Jiang Jiang
(cherry picked from commit 0aa9b30432cec3b7f366983f451fc9a7f8f83243)
Diffstat (limited to 'src/gui/painting/qpaintengineex.cpp')
-rw-r--r-- | src/gui/painting/qpaintengineex.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index bbdf76f0c0..304e5fc486 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -44,6 +44,8 @@ #include "qstroker_p.h" #include "qbezier_p.h" #include <private/qpainterpath_p.h> +#include <private/qfontengine_p.h> +#include <private/qstatictext_p.h> #include <qvarlengtharray.h> #include <qdebug.h> @@ -1057,5 +1059,38 @@ Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path) return p; } +void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) +{ + QPainterPath path; +#ifndef Q_WS_MAC + path.setFillRule(Qt::WindingFill); +#endif + + if (staticTextItem->numGlyphs == 0) + return; + + QFontEngine *fontEngine = staticTextItem->fontEngine(); + fontEngine->addGlyphsToPath(staticTextItem->glyphs, staticTextItem->glyphPositions, + staticTextItem->numGlyphs, &path, 0); + if (!path.isEmpty()) { + QPainterState *s = state(); + QPainter::RenderHints oldHints = s->renderHints; + bool changedHints = false; + if (bool(oldHints & QPainter::TextAntialiasing) + && !bool(fontEngine->fontDef.styleStrategy & QFont::NoAntialias) + && !bool(oldHints & QPainter::Antialiasing)) { + s->renderHints |= QPainter::Antialiasing; + renderHintsChanged(); + changedHints = true; + } + + fill(qtVectorPathForPath(path), staticTextItem->color); + + if (changedHints) { + s->renderHints = oldHints; + renderHintsChanged(); + } + } +} QT_END_NAMESPACE |