41 QTextureGlyphCache(QFontEngine::GlyphFormat format,
const QTransform &matrix,
const QColor &color = QColor())
42 : QFontEngineGlyphCache(format, matrix, color), m_current_fontengine(
nullptr),
43 m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0)
46 ~QTextureGlyphCache();
48 struct GlyphAndSubPixelPosition
50 GlyphAndSubPixelPosition(glyph_t g,
const QFixedPoint &spp)
51 : glyph(g), subPixelPosition(spp) {}
53 bool operator==(
const GlyphAndSubPixelPosition &other)
const
55 return glyph == other.glyph && subPixelPosition == other.subPixelPosition;
59 QFixedPoint subPixelPosition;
73 return w == 0 || h == 0;
77 bool populate(QFontEngine *fontEngine,
79 const glyph_t *glyphs,
80 const QFixedPoint *positions,
81 QPainter::RenderHints renderHints = QPainter::RenderHints(),
82 bool includeGlyphCacheScale =
false);
83 bool hasPendingGlyphs()
const {
return !m_pendingGlyphs.isEmpty(); }
84 void fillInPendingGlyphs();
86 virtual void createTextureData(
int width,
int height) = 0;
87 virtual void resizeTextureData(
int width,
int height) = 0;
88 virtual int glyphPadding()
const {
return 0; }
90 virtual void beginFillTexture() { }
91 virtual void fillTexture(
const Coord &coord,
93 const QFixedPoint &subPixelPosition) = 0;
94 virtual void endFillTexture() { }
96 inline void createCache(
int width,
int height) {
99 createTextureData(width, height);
102 inline void resizeCache(
int width,
int height)
104 resizeTextureData(width, height);
109 inline bool isNull()
const {
return m_h == 0; }
111 QHash<GlyphAndSubPixelPosition, Coord> coords;
113 virtual int maxTextureHeight()
const {
return -1; }
115 QImage textureMapForGlyph(glyph_t g,
const QFixedPoint &subPixelPosition)
const;
118 int calculateSubPixelPositionCount(glyph_t)
const;
120 QFontEngine *m_current_fontengine;
121 QHash<GlyphAndSubPixelPosition, Coord> m_pendingGlyphs;
127 int m_currentRowHeight;
#define QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH