summaryrefslogtreecommitdiff
path: root/src/gui/text/qstatictext_p.h
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-17 13:09:51 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-14 13:54:04 +0100
commit91e96d6c730aac4accef64e5eaab1b289939ef8e (patch)
tree23a5303b53c29f3ec0ec24fccff176ef76fdc1f0 /src/gui/text/qstatictext_p.h
parent49dfc4ed6a89cdd7377e4b88236bb7303fdfdc15 (diff)
downloadqt4-tools-91e96d6c730aac4accef64e5eaab1b289939ef8e.tar.gz
Optimize QStaticText for space
By caching the results of getGlyphPositions() we can make a code path in the critical paint engines which is optimal both in space and speed. The engines where speed is of less importance (pdf engine etc.) which may need more information, we choose the slower code path of drawText() which lays out the text again. We should have optimal paths in raster, vg and GL2 paint engines. The others are less important. Memory consumption of static text is now 14 bytes per glyph, 8 bytes per item and a static overhead of 40 bytes per QStaticText object.
Diffstat (limited to 'src/gui/text/qstatictext_p.h')
-rw-r--r--src/gui/text/qstatictext_p.h38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
index f5fd8d3535..2a8d23a418 100644
--- a/src/gui/text/qstatictext_p.h
+++ b/src/gui/text/qstatictext_p.h
@@ -54,8 +54,26 @@
//
#include <private/qtextengine_p.h>
+#include <private/qfontengine_p.h>
-QT_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
+
+class QStaticTextItem
+{
+public:
+ QStaticTextItem() : chars(0), numChars(0), fontEngine(0) {}
+
+ QVarLengthArray<QFixedPoint> glyphPositions; // 8 bytes per glyph
+ QVarLengthArray<glyph_t> glyphs; // 4 bytes per glyph
+ const QChar *chars; // 2 bytes per glyph
+ // =================
+ // 14 bytes per glyph
+
+ int numChars; // 4 bytes per item
+ QFontEngine *fontEngine; // 4 bytes per item
+ // ================
+ // 8 bytes per item
+};
class QStaticText;
class QStaticTextPrivate
@@ -67,19 +85,17 @@ public:
void init();
- QAtomicInt ref;
+ QAtomicInt ref; // 4 bytes per text
- QString text;
- QFont font;
- QSizeF size;
+ QString text; // 4 bytes per text
+ QFont font; // 8 bytes per text
+ QSizeF size; // 16 bytes per text
- QTextItemInt *items;
- QPointF *itemPositions;
- int itemCount;
+ QStaticTextItem *items; // 4 bytes per text
+ int itemCount; // 4 bytes per text
+ // ================
+ // 40 bytes per text
- char *glyphLayoutMemory;
- unsigned short *logClusterMemory;
-
static QStaticTextPrivate *get(const QStaticText *q);
};