42 QTextureGlyphCache(QFontEngine::GlyphFormat format,
const QTransform &matrix,
const QColor &color = QColor())
43 : QFontEngineGlyphCache(format, matrix, color), m_current_fontengine(
nullptr),
44 m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0)
47 ~QTextureGlyphCache();
49 struct GlyphAndSubPixelPosition
51 GlyphAndSubPixelPosition(glyph_t g,
const QFixedPoint &spp)
52 : glyph(g), subPixelPosition(spp) {}
54 bool operator==(
const GlyphAndSubPixelPosition &other)
const
56 return glyph == other.glyph && subPixelPosition == other.subPixelPosition;
60 QFixedPoint subPixelPosition;
74 return w == 0 || h == 0;
78 bool populate(QFontEngine *fontEngine,
80 const glyph_t *glyphs,
81 const QFixedPoint *positions,
82 QPainter::RenderHints renderHints = QPainter::RenderHints(),
83 bool includeGlyphCacheScale =
false);
84 bool hasPendingGlyphs()
const {
return !m_pendingGlyphs.isEmpty(); }
85 void fillInPendingGlyphs();
87 virtual void createTextureData(
int width,
int height) = 0;
88 virtual void resizeTextureData(
int width,
int height) = 0;
89 virtual int glyphPadding()
const {
return 0; }
91 virtual void beginFillTexture() { }
92 virtual void fillTexture(
const Coord &coord,
94 const QFixedPoint &subPixelPosition) = 0;
95 virtual void endFillTexture() { }
97 inline void createCache(
int width,
int height) {
100 createTextureData(width, height);
103 inline void resizeCache(
int width,
int height)
105 resizeTextureData(width, height);
110 inline bool isNull()
const {
return m_h == 0; }
112 QHash<GlyphAndSubPixelPosition, Coord> coords;
114 virtual int maxTextureHeight()
const {
return -1; }
116 QImage textureMapForGlyph(glyph_t g,
const QFixedPoint &subPixelPosition)
const;
119 int calculateSubPixelPositionCount(glyph_t)
const;
121 QFontEngine *m_current_fontengine;
122 QHash<GlyphAndSubPixelPosition, Coord> m_pendingGlyphs;
128 int m_currentRowHeight;
#define QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH