diff options
Diffstat (limited to 'src/gui/text/qtextengine_p.h')
-rw-r--r-- | src/gui/text/qtextengine_p.h | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index f2e16cf546..fce2bd808d 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -190,11 +190,15 @@ Q_DECLARE_TYPEINFO(QGlyphJustification, Q_PRIMITIVE_TYPE); struct QGlyphLayout { + enum { + SpaceNeeded = sizeof(glyph_t) + sizeof(QFixed) + sizeof(QFixedPoint) + + sizeof(QGlyphAttributes) + sizeof(QGlyphJustification) + }; + // init to 0 not needed, done when shaping QFixedPoint *offsets; // 8 bytes per element glyph_t *glyphs; // 4 bytes per element - QFixed *advances_x; // 4 bytes per element - QFixed *advances_y; // 4 bytes per element + QFixed *advances; // 4 bytes per element QGlyphJustification *justifications; // 4 bytes per element QGlyphAttributes *attributes; // 2 bytes per element @@ -208,9 +212,7 @@ struct QGlyphLayout int offset = totalGlyphs * sizeof(QFixedPoint); glyphs = reinterpret_cast<glyph_t *>(address + offset); offset += totalGlyphs * sizeof(glyph_t); - advances_x = reinterpret_cast<QFixed *>(address + offset); - offset += totalGlyphs * sizeof(QFixed); - advances_y = reinterpret_cast<QFixed *>(address + offset); + advances = reinterpret_cast<QFixed *>(address + offset); offset += totalGlyphs * sizeof(QFixed); justifications = reinterpret_cast<QGlyphJustification *>(address + offset); offset += totalGlyphs * sizeof(QGlyphJustification); @@ -221,8 +223,7 @@ struct QGlyphLayout inline QGlyphLayout mid(int position, int n = -1) const { QGlyphLayout copy = *this; copy.glyphs += position; - copy.advances_x += position; - copy.advances_y += position; + copy.advances += position; copy.offsets += position; copy.justifications += position; copy.attributes += position; @@ -233,27 +234,20 @@ struct QGlyphLayout return copy; } - static inline int spaceNeededForGlyphLayout(int totalGlyphs) { - return totalGlyphs * (sizeof(glyph_t) + sizeof(QGlyphAttributes) - + sizeof(QFixed) + sizeof(QFixed) + sizeof(QFixedPoint) - + sizeof(QGlyphJustification)); - } - inline QFixed effectiveAdvance(int item) const - { return (advances_x[item] + QFixed::fromFixed(justifications[item].space_18d6)) * !attributes[item].dontPrint; } + { return (advances[item] + QFixed::fromFixed(justifications[item].space_18d6)) * !attributes[item].dontPrint; } inline void clear(int first = 0, int last = -1) { if (last == -1) last = numGlyphs; if (first == 0 && last == numGlyphs && reinterpret_cast<char *>(offsets + numGlyphs) == reinterpret_cast<char *>(glyphs)) { - memset(offsets, 0, spaceNeededForGlyphLayout(numGlyphs)); + memset(offsets, 0, (numGlyphs * SpaceNeeded)); } else { const int num = last - first; memset(offsets + first, 0, num * sizeof(QFixedPoint)); memset(glyphs + first, 0, num * sizeof(glyph_t)); - memset(advances_x + first, 0, num * sizeof(QFixed)); - memset(advances_y + first, 0, num * sizeof(QFixed)); + memset(advances + first, 0, num * sizeof(QFixed)); memset(justifications + first, 0, num * sizeof(QGlyphJustification)); memset(attributes + first, 0, num * sizeof(QGlyphAttributes)); } @@ -272,7 +266,7 @@ private: typedef QVarLengthArray<void *> Array; public: QVarLengthGlyphLayoutArray(int totalGlyphs) - : Array(spaceNeededForGlyphLayout(totalGlyphs) / sizeof(void *) + 1) + : Array((totalGlyphs * SpaceNeeded) / sizeof(void *) + 1) , QGlyphLayout(reinterpret_cast<char *>(Array::data()), totalGlyphs) { memset(Array::data(), 0, Array::size() * sizeof(void *)); @@ -280,7 +274,7 @@ public: void resize(int totalGlyphs) { - Array::resize(spaceNeededForGlyphLayout(totalGlyphs) / sizeof(void *) + 1); + Array::resize((totalGlyphs * SpaceNeeded) / sizeof(void *) + 1); *((QGlyphLayout *)this) = QGlyphLayout(reinterpret_cast<char *>(Array::data()), totalGlyphs); memset(Array::data(), 0, Array::size() * sizeof(void *)); @@ -297,10 +291,7 @@ public: } private: - void *buffer[(N * (sizeof(glyph_t) + sizeof(QGlyphAttributes) - + sizeof(QFixed) + sizeof(QFixed) + sizeof(QFixedPoint) - + sizeof(QGlyphJustification))) - / sizeof(void *) + 1]; + void *buffer[(N * SpaceNeeded) / sizeof(void *) + 1]; }; struct QScriptItem; |