summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine_p.h
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-01-30 05:46:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-30 12:43:33 +0100
commita5614264d5a5d6d1cc0f2773f4d7cd70195a0546 (patch)
tree23ce986e78fd6d84e57972be6502fa9ac7f2d7dc /src/gui/text/qtextengine_p.h
parentdca65cd2bc1a999b81df9d45c317a92651db3f82 (diff)
Get rid of QGlyphLayout::advances_y
...and thus consume 4 bytes less per glyph and increase the performance a bit. It seems, the only CTFontGetAdvancesForGlyphs() returns both x and y advances, though y advances are always equal to 0 for horizontal orientation and x advances are always equal to 0 for vertical orientation. Also, rename `advances_x` to `advances` for consistency and declare QGlyphLayout's data size in a single place. Change-Id: I56b20f893f8a6feb7aa870e3edbca99dd93ba2e2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/gui/text/qtextengine_p.h')
-rw-r--r--src/gui/text/qtextengine_p.h37
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;