14QSGOpenVGGlyphNode::QSGOpenVGGlyphNode(QSGRenderContext *rc)
15 : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0)
16 , m_style(QQuickText::Normal)
17 , m_glyphCache(
nullptr)
20 setMaterial((QSGMaterial*)1);
21 setGeometry(&m_geometry);
22 m_fontColorPaint = vgCreatePaint();
23 m_styleColorPaint = vgCreatePaint();
26 m_renderContext =
static_cast<QSGOpenVGRenderContext*>(rc);
41 auto oldGlyphCache = m_glyphCache;
42 m_glyphCache = m_renderContext->glyphCache(glyphs.rawFont());
43 if (m_glyphCache != oldGlyphCache) {
45 oldGlyphCache->release(m_glyphRun.glyphIndexes());
47 m_glyphCache->populate(glyphs.glyphIndexes());
49 m_position = position;
51 m_bounding_rect = glyphs.boundingRect().translated(m_position - QPointF(0.0, glyphs.rawFont().ascent()));
54 m_xAdjustments.clear();
55 m_yAdjustments.clear();
57 for (
int i = 1; i < glyphs.positions().count(); ++i) {
58 m_xAdjustments.append(glyphs.positions().at(i).x() - glyphs.positions().at(i-1).x());
59 m_yAdjustments.append(glyphs.positions().at(i).y() - glyphs.positions().at(i-1).y());
97 if (m_glyphRun.positions().count() == 0)
106 vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE);
111 offscreenSurface =
new QOpenVGOffscreenSurface(QSize(std::ceil(m_bounding_rect.width()), std::ceil(m_bounding_rect.height())));
116 vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER);
120 case QQuickText::Normal:
break;
121 case QQuickText::Outline:
123 vgSetPaint(m_styleColorPaint, VG_FILL_PATH);
124 drawGlyphsAtOffset(QPointF(0, offset));
125 drawGlyphsAtOffset(QPointF(0, -offset));
126 drawGlyphsAtOffset(QPointF(offset, 0));
127 drawGlyphsAtOffset(QPointF(-offset, 0));
129 case QQuickText::Raised:
130 vgSetPaint(m_styleColorPaint, VG_FILL_PATH);
131 drawGlyphsAtOffset(QPointF(0, offset));
133 case QQuickText::Sunken:
134 vgSetPaint(m_styleColorPaint, VG_FILL_PATH);
135 drawGlyphsAtOffset(QPointF(0, -offset));
140 vgSetPaint(m_fontColorPaint, VG_FILL_PATH);
141 drawGlyphsAtOffset(QPointF(0.0, 0.0));
144 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
147 vgDrawImage(offscreenSurface->image());
148 delete offscreenSurface;