diff options
author | Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com> | 2009-08-04 09:17:42 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-14 12:48:38 (GMT) |
commit | 9e40703796bf2a2d9b1dbb4ad09c22f9d036c985 (patch) | |
tree | 3ac4af2bbbc6951e14743e257d830ac3adcf4116 /src/gui/text/qstatictext.cpp | |
parent | e459416e357c86f32146de4e7dce220153a132b2 (diff) | |
download | Qt-9e40703796bf2a2d9b1dbb4ad09c22f9d036c985.zip Qt-9e40703796bf2a2d9b1dbb4ad09c22f9d036c985.tar.gz Qt-9e40703796bf2a2d9b1dbb4ad09c22f9d036c985.tar.bz2 |
Space optimization in QStaticText
The engine.layoutData's glyph count is the number allocated, which may
be larger than the actual number of glyphs. To minimize the space needed
we base allocation on "used" which contains the number of glyphs
actually used to represent the text.
Diffstat (limited to 'src/gui/text/qstatictext.cpp')
-rw-r--r-- | src/gui/text/qstatictext.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 90fde9d..e9fd9c5 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -242,8 +242,8 @@ QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other) QStaticTextPrivate::~QStaticTextPrivate() { - delete glyphLayoutMemory; - delete logClusterMemory; + delete[] glyphLayoutMemory; + delete[] logClusterMemory; qDeleteAll(items); } @@ -254,11 +254,11 @@ QStaticTextPrivate *QStaticTextPrivate::get(const QStaticText *q) void QStaticTextPrivate::init() { - delete glyphLayoutMemory; - delete logClusterMemory; + delete[] glyphLayoutMemory; + delete[] logClusterMemory; qDeleteAll(items); - QStackTextEngine engine = QStackTextEngine(text, font); + QStackTextEngine engine(text, font); engine.itemize(); engine.option.setTextDirection(QApplication::layoutDirection()); @@ -273,7 +273,7 @@ void QStaticTextPrivate::init() levels[i] = engine.layoutData->items[i].analysis.bidiLevel; QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); - int numGlyphs = engine.layoutData->glyphLayout.numGlyphs; + int numGlyphs = engine.layoutData->used; glyphLayoutMemory = new char[QGlyphLayout::spaceNeededForGlyphLayout(numGlyphs)]; logClusterMemory = new unsigned short[numGlyphs]; @@ -289,10 +289,9 @@ void QStaticTextPrivate::init() gf->width = si.width; items.append(gf); continue; - } + } QTextItemInt *gf = new QTextItemInt(si, &f); - QGlyphLayout l = engine.shapedGlyphs(&si); gf->glyphs = l.clone(currentGlyphLayout); currentGlyphLayout += QGlyphLayout::spaceNeededForGlyphLayout(l.numGlyphs); |