summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-05-08 14:24:17 +0300
committerQt by Nokia <qt-info@nokia.com>2012-05-09 02:28:49 +0200
commit7fbc80f0eb2325b6abc33286f02b065605eb4490 (patch)
tree942395127bb6a8ac50c652d1706f6772ea7ec440
parent025d544caa93afd2bc9af5f0bf8cebd2d988cc24 (diff)
QTextEngine: simplify the code a bit
by using QVarLengthArray so we can avoid the manual clean-up code. Change-Id: I35e2f7150d777c1760f722553e6fe7a20f6ecc46 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
-rw-r--r--src/gui/text/qtextengine.cpp29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 9848898d66..41bc249a55 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1008,11 +1008,11 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
entire_shaper_item.item.length = length(item);
entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel;
- HB_UChar16 upperCased[256]; // XXX what about making this 4096, so we don't have to extend it ever.
+ QVarLengthArray<HB_UChar16, 256> casedString;
if (hasCaseChange(si)) {
- HB_UChar16 *uc = upperCased;
- if (entire_shaper_item.item.length > 256)
- uc = new HB_UChar16[entire_shaper_item.item.length];
+ if (casedString.size() < entire_shaper_item.item.length)
+ casedString.resize(entire_shaper_item.item.length);
+ HB_UChar16 *uc = casedString.data();
for (uint i = 0; i < entire_shaper_item.item.length; ++i) {
if(si.analysis.flags == QScriptAnalysis::Lowercase)
uc[i] = QChar::toLower(entire_shaper_item.string[si.position + i]);
@@ -1031,25 +1031,16 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics;
entire_shaper_item.num_glyphs = qMax(layoutData->glyphLayout.numGlyphs - layoutData->used, int(entire_shaper_item.item.length));
- if (! ensureSpace(entire_shaper_item.num_glyphs)) {
- if (hasCaseChange(si))
- delete [] const_cast<HB_UChar16 *>(entire_shaper_item.string);
+ if (!ensureSpace(entire_shaper_item.num_glyphs))
return;
- }
QGlyphLayout initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) {
- if (! ensureSpace(entire_shaper_item.num_glyphs)) {
- if (hasCaseChange(si))
- delete [] const_cast<HB_UChar16 *>(entire_shaper_item.string);
+ if (!ensureSpace(entire_shaper_item.num_glyphs))
return;
- }
initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
-
if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) {
// ############ if this happens there's a bug in the fontengine
- if (hasCaseChange(si) && entire_shaper_item.string != upperCased)
- delete [] const_cast<HB_UChar16 *>(entire_shaper_item.string);
return;
}
}
@@ -1119,11 +1110,8 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
remaining_glyphs -= shaper_item.initialGlyphCount;
do {
- if (! ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs)) {
- if (hasCaseChange(si))
- delete [] const_cast<HB_UChar16 *>(entire_shaper_item.string);
+ if (!ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs))
return;
- }
const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);
if (shaper_item.num_glyphs > shaper_item.item.length)
@@ -1163,9 +1151,6 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
si.num_glyphs = glyph_pos;
layoutData->used += si.num_glyphs;
-
- if (hasCaseChange(si) && entire_shaper_item.string != upperCased)
- delete [] const_cast<HB_UChar16 *>(entire_shaper_item.string);
}
static void init(QTextEngine *e)