Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsgdefaultglyphnode_p.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <private/qsgmaterialshader_p.h>
6
7#include <QtGui/private/qguiapplication_p.h>
8#include <qpa/qplatformintegration.h>
9#include <private/qfontengine_p.h>
10
11#include <QtQuick/qquickwindow.h>
12#include <QtQuick/private/qsgtexture_p.h>
13#include <QtQuick/private/qsgdefaultrendercontext_p.h>
14
15#include <private/qrawfont_p.h>
16#include <QtCore/qmath.h>
17
19
20static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity)
21{
22 float o = c.w() * globalOpacity;
23 return QVector4D(c.x() * o, c.y() * o, c.z() * o, o);
24}
25
27{
28public:
30
32 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
34 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
35
36protected:
38};
39
41 : m_glyphFormat(glyphFormat)
42{
44 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/textmask.vert.qsb"));
46 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/textmask.frag.qsb"));
47}
48
55
56 // + 1 float padding (vec4 must be aligned to 16)
59};
60
62 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
63{
64 Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type());
65 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
66 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
67
68 // updateUniformData() is called before updateSampledImage() by the
69 // renderer. Hence updating the glyph cache stuff here.
70 const bool updated = mat->ensureUpToDate();
71 Q_ASSERT(mat->texture());
72 Q_ASSERT(oldMat == nullptr || oldMat->texture());
73
74 bool changed = false;
75 QByteArray *buf = state.uniformData();
76 Q_ASSERT(buf->size() >= DprOffset + 4);
77
78 if (state.isMatrixDirty()) {
79 const QMatrix4x4 mv = state.modelViewMatrix();
80 memcpy(buf->data() + ModelViewMatrixOffset, mv.constData(), 64);
81 const QMatrix4x4 p = state.projectionMatrix();
82 memcpy(buf->data() + ProjectionMatrixOffset, p.constData(), 64);
83
84 changed = true;
85 }
86
87 QRhiTexture *oldRtex = oldMat ? oldMat->texture()->rhiTexture() : nullptr;
88 QRhiTexture *newRtex = mat->texture()->rhiTexture();
89 if (updated || !oldMat || oldRtex != newRtex) {
90 const QVector2D textureScale = QVector2D(1.0f / mat->rhiGlyphCache()->width(),
91 1.0f / mat->rhiGlyphCache()->height());
92 memcpy(buf->data() + TextureScaleOffset, &textureScale, 8);
93 changed = true;
94 }
95
96 if (!oldMat) {
97 float dpr = state.devicePixelRatio();
98 memcpy(buf->data() + DprOffset, &dpr, 4);
99 }
100
101 // move texture uploads/copies onto the renderer's soon-to-be-committed list
102 mat->rhiGlyphCache()->commitResourceUpdates(state.resourceUpdateBatch());
103
104 return changed;
105}
106
108 QSGMaterial *newMaterial, QSGMaterial *)
109{
111 if (binding != 1)
112 return;
113
114 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
115 QSGTexture *t = mat->texture();
117 *texture = t;
118}
119
121{
122public:
124 : QSGTextMaskRhiShader(glyphFormat)
125 {
126 if (alphaTexture)
128 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/8bittextmask_a.frag.qsb"));
129 else
131 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/8bittextmask.frag.qsb"));
132 }
133
134 bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
135};
136
138 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
139{
140 bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
141
142 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
143 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
144
145 QByteArray *buf = state.uniformData();
146 Q_ASSERT(buf->size() >= ColorOffset + 16);
147
148 if (oldMat == nullptr || mat->color() != oldMat->color() || state.isOpacityDirty()) {
149 const QVector4D color = qsg_premultiply(mat->color(), state.opacity());
150 memcpy(buf->data() + ColorOffset, &color, 16);
151 changed = true;
152 }
153
154 return changed;
155}
156
158{
159public:
161 : QSGTextMaskRhiShader(glyphFormat)
162 {
165 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/24bittextmask.frag.qsb"));
166 }
167
168 bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
169 bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
170 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
171};
172
174 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
175{
176 bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
177
178 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
179 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
180
181 QByteArray *buf = state.uniformData();
182 Q_ASSERT(buf->size() >= ColorOffset + 16);
183
184 if (oldMat == nullptr || mat->color() != oldMat->color() || state.isOpacityDirty()) {
185 // shader takes vec4 but uses alpha only; coloring happens via the blend constant
186 const QVector4D color = qsg_premultiply(mat->color(), state.opacity());
187 memcpy(buf->data() + ColorOffset, &color, 16);
188 changed = true;
189 }
190
191 return changed;
192}
193
195 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
196{
198 Q_UNUSED(oldMaterial);
199 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
200
201 ps->blendEnable = true;
202 ps->srcColor = GraphicsPipelineState::ConstantColor;
203 ps->dstColor = GraphicsPipelineState::OneMinusSrcColor;
204
205 QVector4D color = mat->color();
206
207 // this is dynamic state but it's - magic! - taken care of by the renderer
208 ps->blendConstant = QColor::fromRgbF(color.x(), color.y(), color.z(), color.w());
209
210 return true;
211}
212
214{
215public:
217 : QSGTextMaskRhiShader(glyphFormat)
218 {
220 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/32bitcolortext.frag.qsb"));
221 }
222
223 bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
224};
225
227 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
228{
229 bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
230
231 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
232 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
233
234 QByteArray *buf = state.uniformData();
235 Q_ASSERT(buf->size() >= ColorOffset + 16);
236
237 if (oldMat == nullptr || mat->color() != oldMat->color() || state.isOpacityDirty()) {
238 // shader takes vec4 but uses alpha only
239 const QVector4D color(0, 0, 0, mat->color().w() * state.opacity());
240 memcpy(buf->data() + ColorOffset, &color, 16);
241 changed = true;
242 }
243
244 return changed;
245}
246
248{
249public:
250 QSGStyledTextRhiShader(QFontEngine::GlyphFormat glyphFormat, bool alphaTexture)
251 : QSG8BitTextMaskRhiShader(glyphFormat, alphaTexture)
252 {
254 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext.vert.qsb"));
255 if (alphaTexture)
257 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext_a.frag.qsb"));
258 else
260 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext.frag.qsb"));
261 }
262
263 bool updateUniformData(RenderState &state,
264 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
265};
266
268 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
269{
270 bool changed = QSG8BitTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
271
272 QSGStyledTextMaterial *mat = static_cast<QSGStyledTextMaterial *>(newMaterial);
273 QSGStyledTextMaterial *oldMat = static_cast<QSGStyledTextMaterial *>(oldMaterial);
274
275 QByteArray *buf = state.uniformData();
276 Q_ASSERT(buf->size() >= ShiftOffset + 8);
277
278 if (oldMat == nullptr || mat->styleColor() != oldMat->styleColor() || state.isOpacityDirty()) {
279 const QVector4D styleColor = qsg_premultiply(mat->styleColor(), state.opacity());
280 memcpy(buf->data() + StyleColorOffset, &styleColor, 16);
281 changed = true;
282 }
283
284 if (oldMat == nullptr || oldMat->styleShift() != mat->styleShift()) {
285 const QVector2D v = mat->styleShift();
286 memcpy(buf->data() + ShiftOffset, &v, 8);
287 changed = true;
288 }
289
290 return changed;
291}
292
294{
295public:
297 : QSGStyledTextRhiShader(glyphFormat, alphaTexture)
298 {
300 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/outlinedtext.vert.qsb"));
301 if (alphaTexture)
303 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/outlinedtext_a.frag.qsb"));
304 else
306 QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/outlinedtext.frag.qsb"));
307 }
308};
309
310
311// ***** common material stuff
312
315 , m_texture(nullptr)
316 , m_glyphCache(nullptr)
317 , m_font(font)
318 , m_color(color)
319{
320 init(glyphFormat);
321}
322
324{
325 if (m_retainedFontEngine != nullptr)
326 m_rc->unregisterFontengineForCleanup(m_retainedFontEngine);
327 delete m_texture;
328}
329
331{
332 if (m_color == color)
333 return;
334
335 m_color = color;
336
337 // If it is an RGB cache, then the pen color is actually part of the cache key
338 // so it has to be updated
339 if (m_glyphCache != nullptr && m_glyphCache->glyphFormat() == QFontEngine::Format_ARGB)
340 updateCache(QFontEngine::Format_ARGB);
341}
342
343void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat)
344{
345 Q_ASSERT(m_font.isValid());
346
347 setFlag(Blending, true);
348
349 Q_ASSERT(m_rc);
350 m_rhi = m_rc->rhi();
351
352 updateCache(glyphFormat);
353}
354
355void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat)
356{
357 // The following piece of code will read/write to the font engine's caches,
358 // potentially from different threads. However, this is safe because this
359 // code is only called from QQuickItem::updatePaintNode() which is called
360 // only when the GUI is blocked, and multiple threads will call it in
361 // sequence. See also QSGRenderContext::invalidate
362
363 QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
364 if (QFontEngine *fontEngine = fontD->fontEngine) {
365 if (glyphFormat == QFontEngine::Format_None) {
366 glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
367 ? fontEngine->glyphFormat
369 }
370
371 qreal devicePixelRatio;
372 void *cacheKey;
373 Q_ASSERT(m_rhi);
374 Q_ASSERT(m_rc);
375 cacheKey = m_rc;
376 // Get the dpr the modern way. This value retrieved via the
377 // rendercontext matches what RenderState::devicePixelRatio()
378 // exposes to the material shaders later on.
379 devicePixelRatio = m_rc->currentDevicePixelRatio();
380
381 QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio);
382 if (!fontEngine->supportsTransformation(glyphCacheTransform))
383 glyphCacheTransform = QTransform();
384
385 QColor color = glyphFormat == QFontEngine::Format_ARGB ? QColor::fromRgbF(m_color.x(), m_color.y(), m_color.z(), m_color.w()) : QColor();
386 m_glyphCache = fontEngine->glyphCache(cacheKey, glyphFormat, glyphCacheTransform, color);
387 if (!m_glyphCache || int(m_glyphCache->glyphFormat()) != glyphFormat) {
388 m_glyphCache = new QSGRhiTextureGlyphCache(m_rc, glyphFormat, glyphCacheTransform, color);
389 fontEngine->setGlyphCache(cacheKey, m_glyphCache.data());
390 if (m_retainedFontEngine != nullptr)
391 m_rc->unregisterFontengineForCleanup(m_retainedFontEngine);
392
393 // Note: This is reference counted by the render context, so it will stay alive until
394 // we release that reference
395 m_retainedFontEngine = fontEngine;
396 m_rc->registerFontengineForCleanup(fontEngine);
397 }
398 }
399}
400
402 const QVector<quint32> &glyphIndexes,
403 const QVector<QPointF> &glyphPositions,
404 QSGGeometry *geometry,
406 QPointF *baseLine,
407 const QMargins &margins)
408{
409 Q_ASSERT(m_font.isValid());
410 QPointF position(p.x(), p.y() - m_font.ascent());
411 QVector<QFixedPoint> fixedPointPositions;
412 const int glyphPositionsSize = glyphPositions.size();
413 fixedPointPositions.reserve(glyphPositionsSize);
414 for (int i=0; i < glyphPositionsSize; ++i)
415 fixedPointPositions.append(QFixedPoint::fromPointF(position + glyphPositions.at(i)));
416
418
419 QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
420 cache->populate(fontD->fontEngine,
421 glyphIndexes.size(),
422 glyphIndexes.constData(),
423 fixedPointPositions.data(),
424 QPainter::RenderHints(),
425 true);
426 cache->fillInPendingGlyphs();
427
428 int margin = fontD->fontEngine->glyphMargin(cache->glyphFormat());
429
430 qreal glyphCacheScaleX = cache->transform().m11();
431 qreal glyphCacheScaleY = cache->transform().m22();
432 qreal glyphCacheInverseScaleX = 1.0 / glyphCacheScaleX;
433 qreal glyphCacheInverseScaleY = 1.0 / glyphCacheScaleY;
434 qreal scaledMargin = margin * glyphCacheInverseScaleX;
435
437 geometry->allocate(glyphIndexes.size() * 4, glyphIndexes.size() * 6);
439 Q_ASSERT(geometry->sizeOfVertex() == sizeof(QVector4D));
440 ushort *ip = geometry->indexDataAsUShort();
441
442 bool supportsSubPixelPositions = fontD->fontEngine->supportsHorizontalSubPixelPositions();
443 for (int i=0; i<glyphIndexes.size(); ++i) {
444 QPointF glyphPosition = glyphPositions.at(i) + position;
445 QFixedPoint fixedPointPosition = fixedPointPositions.at(i);
446
447 QFixed subPixelPosition;
448 if (supportsSubPixelPositions)
449 subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(fixedPointPosition.x.toReal() * glyphCacheScaleX));
450
452 QFixedPoint(subPixelPosition, 0));
453 const QTextureGlyphCache::Coord &c = cache->coords.value(glyph);
454
455 // On a retina screen the glyph positions are not pre-scaled (as opposed to
456 // eg. the raster paint engine). To ensure that we get the same behavior as
457 // the raster engine (and CoreText itself) when it comes to rounding of the
458 // coordinates, we need to apply the scale factor before rounding, and then
459 // apply the inverse scale to get back to the coordinate system of the node.
460
461 qreal x = (qFloor(glyphPosition.x() * glyphCacheScaleX) * glyphCacheInverseScaleX) +
462 (c.baseLineX * glyphCacheInverseScaleX) - scaledMargin;
463 qreal y = (qRound(glyphPosition.y() * glyphCacheScaleY) * glyphCacheInverseScaleY) -
464 (c.baseLineY * glyphCacheInverseScaleY) - scaledMargin;
465
466 qreal w = c.w * glyphCacheInverseScaleX;
467 qreal h = c.h * glyphCacheInverseScaleY;
468
469 *boundingRect |= QRectF(x + scaledMargin, y + scaledMargin, w, h);
470
471 float cx1 = x - margins.left();
472 float cx2 = x + w + margins.right();
473 float cy1 = y - margins.top();
474 float cy2 = y + h + margins.bottom();
475
476 float tx1 = c.x - margins.left();
477 float tx2 = c.x + c.w + margins.right();
478 float ty1 = c.y - margins.top();
479 float ty2 = c.y + c.h + margins.bottom();
480
481 if (baseLine->isNull())
482 *baseLine = glyphPosition;
483
484 vp[4 * i + 0] = QVector4D(cx1, cy1, tx1, ty1);
485 vp[4 * i + 1] = QVector4D(cx2, cy1, tx2, ty1);
486 vp[4 * i + 2] = QVector4D(cx1, cy2, tx1, ty2);
487 vp[4 * i + 3] = QVector4D(cx2, cy2, tx2, ty2);
488
489 int o = i * 4;
490 ip[6 * i + 0] = o + 0;
491 ip[6 * i + 1] = o + 2;
492 ip[6 * i + 2] = o + 3;
493 ip[6 * i + 3] = o + 3;
494 ip[6 * i + 4] = o + 1;
495 ip[6 * i + 5] = o + 0;
496 }
497}
498
500{
501 static QSGMaterialType argb, rgb, gray;
502 switch (glyphCache()->glyphFormat()) {
504 return &argb;
506 return &rgb;
508 default:
509 return &gray;
510 }
511}
512
514{
515 return static_cast<QTextureGlyphCache *>(m_glyphCache.data());
516}
517
519{
520 return static_cast<QSGRhiTextureGlyphCache *>(glyphCache());
521}
522
524{
525 Q_UNUSED(renderMode);
527 const QFontEngine::GlyphFormat glyphFormat = gc->glyphFormat();
528 switch (glyphFormat) {
530 return new QSG32BitColorTextRhiShader(glyphFormat);
532 return new QSG24BitTextMaskRhiShader(glyphFormat);
534 default:
535 return new QSG8BitTextMaskRhiShader(glyphFormat, gc->eightBitFormatIsAlphaSwizzled());
536 }
537}
538
539static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b)
540{
541 if (a.x() != b.x())
542 return a.x() > b.x() ? 1 : -1;
543 if (a.y() != b.y())
544 return a.y() > b.y() ? 1 : -1;
545 if (a.z() != b.z())
546 return a.z() > b.z() ? 1 : -1;
547 if (a.w() != b.w())
548 return a.w() > b.w() ? 1 : -1;
549 return 0;
550}
551
553{
554 Q_ASSERT(o && type() == o->type());
555 const QSGTextMaskMaterial *other = static_cast<const QSGTextMaskMaterial *>(o);
556 if (m_glyphCache != other->m_glyphCache)
557 return m_glyphCache.data() < other->m_glyphCache.data() ? -1 : 1;
558 return qsg_colorDiff(m_color, other->m_color);
559}
560
562{
564 QSize glyphCacheSize(gc->width(), gc->height());
565 if (glyphCacheSize != m_size) {
566 if (m_texture)
567 delete m_texture;
568 m_texture = new QSGPlainTexture;
569 m_texture->setTexture(gc->texture());
570 m_texture->setTextureSize(QSize(gc->width(), gc->height()));
571 m_texture->setOwnsTexture(false);
572 m_size = glyphCacheSize;
573 return true;
574 }
575 return false;
576}
577
578
580 : QSGTextMaskMaterial(rc, QVector4D(), font, QFontEngine::Format_A8)
581{
582}
583
585{
586 static QSGMaterialType type;
587 return &type;
588}
589
591{
592 Q_UNUSED(renderMode);
595}
596
598{
599 const QSGStyledTextMaterial *other = static_cast<const QSGStyledTextMaterial *>(o);
600
601 if (m_styleShift != other->m_styleShift)
602 return m_styleShift.y() - other->m_styleShift.y();
603
604 int diff = qsg_colorDiff(m_styleColor, other->m_styleColor);
605 if (diff == 0)
607 return diff;
608}
609
610
613{
614}
615
617{
618 static QSGMaterialType type;
619 return &type;
620}
621
623{
624 Q_UNUSED(renderMode);
627}
628
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
static QColor fromRgbF(float r, float g, float b, float a=1.0)
Static convenience function that returns a QColor constructed from the RGB color values,...
Definition qcolor.cpp:2427
T * data() const noexcept
Returns a pointer to the shared data object.
QFontEngine::GlyphFormat glyphFormat() const
virtual bool supportsHorizontalSubPixelPositions() const
virtual int glyphMargin(GlyphFormat format)
QFixed subPixelPositionForX(QFixed x) const
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
const_pointer constData() const noexcept
Definition qlist.h:416
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
void reserve(qsizetype size)
Definition qlist.h:746
pointer data()
Definition qlist.h:414
void append(parameter_type t)
Definition qlist.h:441
\inmodule QtCore
Definition qmargins.h:23
constexpr int bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:119
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:110
constexpr int right() const noexcept
Returns the right margin.
Definition qmargins.h:116
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:113
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
const float * constData() const
Returns a constant pointer to the raw data of this matrix.
Definition qmatrix4x4.h:147
\inmodule QtCore\reentrant
Definition qpoint.h:214
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:333
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:338
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
Definition qpoint.h:328
static QRawFontPrivate * get(const QRawFont &font)
Definition qrawfont_p.h:104
QFontEngine * fontEngine
Definition qrawfont_p.h:106
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
qreal ascent() const
Returns the ascent of this QRawFont in pixel units.
Definition qrawfont.cpp:314
bool isValid() const
Returns true if the QRawFont is valid and false otherwise.
Definition qrawfont.cpp:182
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtGui
Definition qrhi.h:883
bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to enable the material to provide a custom set of graphics...
QSG24BitTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QSG32BitColorTextRhiShader(QFontEngine::GlyphFormat glyphFormat)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QSG8BitTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat, bool alphaTexture)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
Definition qsggeometry.h:15
TexturedPoint2D * vertexDataAsTexturedPoint2D()
Convenience function to access the vertex data as a mutable array of QSGGeometry::TexturedPoint2D.
int indexType() const
Returns the primitive type used for indices in this geometry object.
void allocate(int vertexCount, int indexCount=0)
Resizes the vertex and index data of this geometry object to fit vertexCount vertices and indexCount ...
int sizeOfVertex() const
Returns the size in bytes of one vertex.
quint16 * indexDataAsUShort()
Convenience function to access the index data as a mutable array of 16-bit unsigned integers.
Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and ...
The QSGMaterialShader class represents a graphics API independent shader program.
void setShaderFileName(Stage stage, const QString &filename)
Sets the filename for the shader for the specified stage.
void setFlag(Flags flags, bool on=true)
Sets the flags on this material shader if on is true; otherwise clears the specified flags.
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
virtual QSGMaterialType * type() const =0
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
void setFlag(Flags flags, bool on=true)
Sets the flags flags on this material if on is true; otherwise clears the attribute.
QSGOutlinedTextMaterial(QSGRenderContext *rc, const QRawFont &font)
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QSGOutlinedTextRhiShader(QFontEngine::GlyphFormat glyphFormat, bool alphaTexture)
void setTextureSize(const QSize &size)
void setTexture(QRhiTexture *texture)
void setOwnsTexture(bool owns)
void registerFontengineForCleanup(QFontEngine *engine)
void unregisterFontengineForCleanup(QFontEngine *engine)
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
void commitResourceUpdates(QRhiResourceUpdateBatch *mergeInto)
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
const QVector2D & styleShift() const
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QSGStyledTextMaterial(QSGRenderContext *rc, const QRawFont &font)
const QVector4D & styleColor() const
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QSGStyledTextRhiShader(QFontEngine::GlyphFormat glyphFormat, bool alphaTexture)
QSGTextMaskMaterial(QSGRenderContext *rc, const QVector4D &color, const QRawFont &font, QFontEngine::GlyphFormat glyphFormat=QFontEngine::Format_None)
const QVector4D & color() const
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
void setColor(const QColor &c)
QTextureGlyphCache * glyphCache() const
QSGRhiTextureGlyphCache * rhiGlyphCache() const
void populate(const QPointF &position, const QVector< quint32 > &glyphIndexes, const QVector< QPointF > &glyphPositions, QSGGeometry *geometry, QRectF *boundingRect, QPointF *baseLine, const QMargins &margins=QMargins(0, 0, 0, 0))
QSGTexture * texture() const
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
QFontEngine::GlyphFormat m_glyphFormat
QSGTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
\inmodule QtQuick
Definition qsgtexture.h:20
void setFiltering(Filtering filter)
Sets the sampling mode to filter.
virtual QRhiTexture * rhiTexture() const
\inmodule QtCore
Definition qsize.h:25
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
static QTransform fromScale(qreal dx, qreal dy)
Creates a matrix which corresponds to a scaling of sx horizontally and sy vertically.
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
constexpr float y() const noexcept
Returns the y coordinate of this point.
Definition qvectornd.h:502
The QVector4D class represents a vector or vertex in 4D space.
Definition qvectornd.h:330
constexpr float x() const noexcept
Returns the x coordinate of this point.
Definition qvectornd.h:878
constexpr float w() const noexcept
Returns the w coordinate of this point.
Definition qvectornd.h:881
constexpr float y() const noexcept
Returns the y coordinate of this point.
Definition qvectornd.h:879
constexpr float z() const noexcept
Returns the z coordinate of this point.
Definition qvectornd.h:880
QCache< int, Employee > cache
[0]
else opt state
[0]
Combined button and popup list for selecting options.
#define rgb(r, g, b)
Definition qcolor.cpp:124
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:281
int qFloor(T v)
Definition qmath.h:42
T qobject_cast(QObject *object)
\variable QObject::staticMetaObject
Definition qobject.h:385
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint texture
GLint y
GLfloat GLfloat GLfloat GLfloat h
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
static const QRectF boundingRect(const QPointF *points, int pointCount)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
@ ModelViewMatrixOffset
@ TextureScaleOffset
@ ProjectionMatrixOffset
static QT_BEGIN_NAMESPACE QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity)
static int qsg_colorDiff(const QVector4D &a, const QVector4D &b)
#define QStringLiteral(str)
#define Q_UNUSED(x)
unsigned short ushort
Definition qtypes.h:28
double qreal
Definition qtypes.h:92
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
static constexpr QFixedPoint fromPointF(const QPointF &p)
Definition qfixed_p.h:167
QFixed x
Definition qfixed_p.h:162
static constexpr QFixed fromReal(qreal r)
Definition qfixed_p.h:35
constexpr qreal toReal() const
Definition qfixed_p.h:42
Describes state changes that the material wants to apply to the currently active graphics pipeline st...
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.