summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-02-11 02:50:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-03 11:10:56 +0100
commitfd498ad1c0f331a42b8c9ee18f5bb48647d13df1 (patch)
tree22fbd05daee749898062b697194c8912714aa573 /src/gui
parent25e34dadabe844099885045c0e53c8136508698a (diff)
Make QGlyphLayout consume one byte less per glyph
Change-Id: Iddcc2e1f284dcf13ae98b57ea2d5854e57c83530 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qtextengine.cpp16
-rw-r--r--src/gui/text/qtextengine_p.h25
2 files changed, 23 insertions, 18 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index e2c45f9bab..45894d27b6 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1206,7 +1206,6 @@ QT_BEGIN_INCLUDE_NAMESPACE
QT_END_INCLUDE_NAMESPACE
Q_STATIC_ASSERT(sizeof(HB_Glyph) == sizeof(glyph_t));
-Q_STATIC_ASSERT(sizeof(HB_GlyphAttributes) == sizeof(QGlyphAttributes));
Q_STATIC_ASSERT(sizeof(HB_Fixed) == sizeof(QFixed));
Q_STATIC_ASSERT(sizeof(HB_FixedPoint) == sizeof(QFixedPoint));
@@ -1272,18 +1271,23 @@ int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *stri
remaining_glyphs -= shaper_item.initialGlyphCount;
+ QVarLengthArray<HB_GlyphAttributes, 128> hbGlyphAttributes;
do {
if (!ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs))
return 0;
+ if (hbGlyphAttributes.size() < int(shaper_item.num_glyphs)) {
+ hbGlyphAttributes.resize(shaper_item.num_glyphs);
+ memset(hbGlyphAttributes.data(), 0, hbGlyphAttributes.size() * sizeof(HB_GlyphAttributes));
+ }
const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);
if (fontEngine->type() == QFontEngine::Multi && shaper_item.num_glyphs > shaper_item.item.length)
moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
shaper_item.glyphs = reinterpret_cast<HB_Glyph *>(g.glyphs);
- shaper_item.attributes = reinterpret_cast<HB_GlyphAttributes *>(g.attributes);
shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances);
shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets);
+ shaper_item.attributes = hbGlyphAttributes.data();
if (engineIdx != 0 && shaper_item.glyphIndicesPresent) {
for (quint32 i = 0; i < shaper_item.initialGlyphCount; ++i)
@@ -1297,6 +1301,14 @@ int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *stri
if (fontEngine->type() == QFontEngine::Multi)
moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
+ for (quint32 i = 0; i < shaper_item.num_glyphs; ++i) {
+ HB_GlyphAttributes hbAttrs = hbGlyphAttributes.at(i);
+ QGlyphAttributes &attrs = g.attributes[i];
+ attrs.clusterStart = hbAttrs.clusterStart;
+ attrs.dontPrint = hbAttrs.dontPrint;
+ attrs.justification = hbAttrs.justification;
+ }
+
for (quint32 i = 0; i < shaper_item.item.length; ++i)
shaper_item.log_clusters[i] += glyph_pos;
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 06075eb992..342a94de66 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -89,21 +89,6 @@ class QAbstractTextDocumentLayout;
typedef quint32 glyph_t;
-#ifdef __xlC__
-typedef unsigned q_hb_bitfield;
-#else
-typedef quint8 q_hb_bitfield;
-#endif
-
-struct QGlyphAttributes {
- q_hb_bitfield justification :4;
- q_hb_bitfield clusterStart :1;
- q_hb_bitfield unused1 :1;
- q_hb_bitfield unused2 :1;
- q_hb_bitfield dontPrint :1;
- q_hb_bitfield unused3 :8;
-};
-
// this uses the same coordinate system as Qt, but a different one to freetype.
// * y is usually negative, and is equal to the ascent.
// * negative yoff means the following stuff is drawn higher up.
@@ -174,6 +159,14 @@ struct QGlyphJustification
};
Q_DECLARE_TYPEINFO(QGlyphJustification, Q_PRIMITIVE_TYPE);
+struct QGlyphAttributes {
+ uchar clusterStart : 1;
+ uchar dontPrint : 1;
+ uchar justification : 4;
+ uchar reserved : 2;
+};
+Q_STATIC_ASSERT(sizeof(QGlyphAttributes) == 1);
+
struct QGlyphLayout
{
enum {
@@ -186,7 +179,7 @@ struct QGlyphLayout
glyph_t *glyphs; // 4 bytes per element
QFixed *advances; // 4 bytes per element
QGlyphJustification *justifications; // 4 bytes per element
- QGlyphAttributes *attributes; // 2 bytes per element
+ QGlyphAttributes *attributes; // 1 byte per element
int numGlyphs;