Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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:
29 QSGTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat, int viewCount);
30
32 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
34 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
35
36protected:
39};
40
42 : m_glyphFormat(glyphFormat)
43{
44 setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/textmask.vert.qsb"), viewCount);
45 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/textmask.frag.qsb"), viewCount);
46}
47
48// uniform block layout:
49// mat4 modelViewMatrix
50// mat4 projectionMatrix or mat4 projectionMatrix[QSHADER_VIEW_COUNT]
51// vec2 textureScale
52// float dpr
53// vec4 color
54// [styled/outline only]
55// vec4 styleColor
56// vec2 shift
57
59 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
60{
61 Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type());
62 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
63 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
64
65 // updateUniformData() is called before updateSampledImage() by the
66 // renderer. Hence updating the glyph cache stuff here.
67 const bool updated = mat->ensureUpToDate();
68 Q_ASSERT(mat->texture());
69 Q_ASSERT(oldMat == nullptr || oldMat->texture());
70
71 bool changed = false;
72 QByteArray *buf = state.uniformData();
73 const int projectionMatrixCount = qMin(state.projectionMatrixCount(), newMaterial->viewCount());
74
75 quint32 offset = 0; // ModelViewMatrix
76 if (state.isMatrixDirty()) {
77 const QMatrix4x4 mv = state.modelViewMatrix();
78 memcpy(buf->data() + offset, mv.constData(), 64);
79 changed = true;
80 }
81 offset += 64; // now at ProjectionMatrix or ProjectionMatrix[0]
82
83 for (int viewIndex = 0; viewIndex < projectionMatrixCount; ++viewIndex) {
84 if (state.isMatrixDirty()) {
85 const QMatrix4x4 p = state.projectionMatrix(viewIndex);
86 memcpy(buf->data() + offset, p.constData(), 64);
87 changed = true;
88 }
89 offset += 64;
90 }
91
92 // offset is now at TextureScale
93 QRhiTexture *oldRtex = oldMat ? oldMat->texture()->rhiTexture() : nullptr;
94 QRhiTexture *newRtex = mat->texture()->rhiTexture();
95 if (updated || !oldMat || oldRtex != newRtex) {
96 const QVector2D textureScale = QVector2D(1.0f / mat->rhiGlyphCache()->width(),
97 1.0f / mat->rhiGlyphCache()->height());
98 memcpy(buf->data() + offset, &textureScale, 8);
99 changed = true;
100 }
101 offset += 8; // now at Dpr
102
103 if (!oldMat) {
104 float dpr = state.devicePixelRatio();
105 memcpy(buf->data() + offset, &dpr, 4);
106 }
107 offset += 4 + 4; // now at Color (with padding to ensure vec4 alignment)
108
109 // move texture uploads/copies onto the renderer's soon-to-be-committed list
110 mat->rhiGlyphCache()->commitResourceUpdates(state.resourceUpdateBatch());
111
113 return changed;
114}
115
117 QSGMaterial *newMaterial, QSGMaterial *)
118{
120 if (binding != 1)
121 return;
122
123 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
124 QSGTexture *t = mat->texture();
126 *texture = t;
127}
128
130{
131public:
132 QSG8BitTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat, int viewCount, bool alphaTexture)
133 : QSGTextMaskRhiShader(glyphFormat, viewCount)
134 {
135 if (alphaTexture)
136 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/8bittextmask_a.frag.qsb"), viewCount);
137 else
138 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/8bittextmask.frag.qsb"), viewCount);
139 }
140
141 bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
142};
143
145 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
146{
147 bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
148
149 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
150 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
151
152 QByteArray *buf = state.uniformData();
153
154 if (oldMat == nullptr || mat->color() != oldMat->color() || state.isOpacityDirty()) {
155 const QVector4D color = qsg_premultiply(mat->color(), state.opacity());
156 memcpy(buf->data() + m_currentUbufOffset, &color, 16);
157 changed = true;
158 }
159 m_currentUbufOffset += 16; // now at StyleColor
160
161 return changed;
162}
163
165{
166public:
168 : QSGTextMaskRhiShader(glyphFormat, viewCount)
169 {
171 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/24bittextmask.frag.qsb"), viewCount);
172 }
173
174 bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
175 bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
176 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
177};
178
180 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
181{
182 bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
183
184 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
185 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
186
187 QByteArray *buf = state.uniformData();
188
189 if (oldMat == nullptr || mat->color() != oldMat->color() || state.isOpacityDirty()) {
190 // shader takes vec4 but uses alpha only; coloring happens via the blend constant
191 const QVector4D color = qsg_premultiply(mat->color(), state.opacity());
192 memcpy(buf->data() + m_currentUbufOffset, &color, 16);
193 changed = true;
194 }
195 m_currentUbufOffset += 16; // now at StyleColor
196
197 return changed;
198}
199
201 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
202{
204 Q_UNUSED(oldMaterial);
205 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
206
207 ps->blendEnable = true;
208 ps->srcColor = GraphicsPipelineState::ConstantColor;
209 ps->dstColor = GraphicsPipelineState::OneMinusSrcColor;
210
211 QVector4D color = mat->color();
212
213 // this is dynamic state but it's - magic! - taken care of by the renderer
214 ps->blendConstant = QColor::fromRgbF(color.x(), color.y(), color.z());
215
216 return true;
217}
218
220{
221public:
223 : QSGTextMaskRhiShader(glyphFormat, viewCount)
224 {
225 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/32bitcolortext.frag.qsb"), viewCount);
226 }
227
228 bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
229};
230
232 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
233{
234 bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
235
236 QSGTextMaskMaterial *mat = static_cast<QSGTextMaskMaterial *>(newMaterial);
237 QSGTextMaskMaterial *oldMat = static_cast<QSGTextMaskMaterial *>(oldMaterial);
238
239 QByteArray *buf = state.uniformData();
240
241 if (oldMat == nullptr || mat->color() != oldMat->color() || state.isOpacityDirty()) {
242 // shader takes vec4 but uses alpha only
243 const QVector4D color(0, 0, 0, mat->color().w() * state.opacity());
244 memcpy(buf->data() + m_currentUbufOffset, &color, 16);
245 changed = true;
246 }
247 m_currentUbufOffset += 16; // now at StyleColor
248
249 return changed;
250}
251
253{
254public:
255 QSGStyledTextRhiShader(QFontEngine::GlyphFormat glyphFormat, int viewCount, bool alphaTexture)
256 : QSG8BitTextMaskRhiShader(glyphFormat, viewCount, alphaTexture)
257 {
258 setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext.vert.qsb"), viewCount);
259 if (alphaTexture)
260 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext_a.frag.qsb"), viewCount);
261 else
262 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext.frag.qsb"), viewCount);
263 }
264
265 bool updateUniformData(RenderState &state,
266 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
267};
268
270 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
271{
272 bool changed = QSG8BitTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
273
274 QSGStyledTextMaterial *mat = static_cast<QSGStyledTextMaterial *>(newMaterial);
275 QSGStyledTextMaterial *oldMat = static_cast<QSGStyledTextMaterial *>(oldMaterial);
276
277 QByteArray *buf = state.uniformData();
278
279 if (oldMat == nullptr || mat->styleColor() != oldMat->styleColor() || state.isOpacityDirty()) {
280 const QVector4D styleColor = qsg_premultiply(mat->styleColor(), state.opacity());
281 memcpy(buf->data() + m_currentUbufOffset, &styleColor, 16);
282 changed = true;
283 }
284 m_currentUbufOffset += 16; // now at StyleShift
285
286 if (oldMat == nullptr || oldMat->styleShift() != mat->styleShift()) {
287 const QVector2D v = mat->styleShift();
288 memcpy(buf->data() + m_currentUbufOffset, &v, 8);
289 changed = true;
290 }
291
292 return changed;
293}
294
296{
297public:
298 QSGOutlinedTextRhiShader(QFontEngine::GlyphFormat glyphFormat, int viewCount, bool alphaTexture)
299 : QSGStyledTextRhiShader(glyphFormat, viewCount, alphaTexture)
300 {
301 setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/outlinedtext.vert.qsb"), viewCount);
302 if (alphaTexture)
303 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/outlinedtext_a.frag.qsb"), viewCount);
304 else
305 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/outlinedtext.frag.qsb"), viewCount);
306 }
307};
308
309
310// ***** common material stuff
311
314 , m_texture(nullptr)
315 , m_glyphCache(nullptr)
316 , m_font(font)
317 , m_color(color)
318{
319 init(glyphFormat);
320}
321
323{
324 if (m_retainedFontEngine != nullptr)
325 m_rc->unregisterFontengineForCleanup(m_retainedFontEngine);
326 delete m_texture;
327}
328
330{
331 if (m_color == color)
332 return;
333
334 m_color = color;
335
336 // If it is an RGB cache, then the pen color is actually part of the cache key
337 // so it has to be updated
338 if (m_glyphCache != nullptr && m_glyphCache->glyphFormat() == QFontEngine::Format_ARGB)
339 updateCache(QFontEngine::Format_ARGB);
340}
341
342void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat)
343{
344 Q_ASSERT(m_font.isValid());
345
346 setFlag(Blending, true);
347
348 Q_ASSERT(m_rc);
349 m_rhi = m_rc->rhi();
350
351 updateCache(glyphFormat);
352}
353
354void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat)
355{
356 // The following piece of code will read/write to the font engine's caches,
357 // potentially from different threads. However, this is safe because this
358 // code is only called from QQuickItem::updatePaintNode() which is called
359 // only when the GUI is blocked, and multiple threads will call it in
360 // sequence. See also QSGRenderContext::invalidate
361
362 QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
363 if (QFontEngine *fontEngine = fontD->fontEngine) {
364 if (glyphFormat == QFontEngine::Format_None) {
365 glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
366 ? fontEngine->glyphFormat
368 }
369
370 qreal devicePixelRatio;
371 void *cacheKey;
372 Q_ASSERT(m_rhi);
373 Q_ASSERT(m_rc);
374 cacheKey = m_rc;
375 // Get the dpr the modern way. This value retrieved via the
376 // rendercontext matches what RenderState::devicePixelRatio()
377 // exposes to the material shaders later on.
378 devicePixelRatio = m_rc->currentDevicePixelRatio();
379
380 QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio);
381 if (!fontEngine->supportsTransformation(glyphCacheTransform))
382 glyphCacheTransform = QTransform();
383
384 QColor color = glyphFormat == QFontEngine::Format_ARGB ? QColor::fromRgbF(m_color.x(), m_color.y(), m_color.z(), m_color.w()) : QColor();
385 m_glyphCache = fontEngine->glyphCache(cacheKey, glyphFormat, glyphCacheTransform, color);
386 if (!m_glyphCache || int(m_glyphCache->glyphFormat()) != glyphFormat) {
387 m_glyphCache = new QSGRhiTextureGlyphCache(m_rc, glyphFormat, glyphCacheTransform, color);
388 fontEngine->setGlyphCache(cacheKey, m_glyphCache.data());
389 if (m_retainedFontEngine != nullptr)
390 m_rc->unregisterFontengineForCleanup(m_retainedFontEngine);
391
392 // Note: This is reference counted by the render context, so it will stay alive until
393 // we release that reference
394 m_retainedFontEngine = fontEngine;
395 m_rc->registerFontengineForCleanup(fontEngine);
396 }
397 }
398}
399
401 const QVector<quint32> &glyphIndexes,
402 const QVector<QPointF> &glyphPositions,
403 QSGGeometry *geometry,
405 QPointF *baseLine,
406 const QMargins &margins)
407{
408 Q_ASSERT(m_font.isValid());
409 QPointF position(p.x(), p.y() - m_font.ascent());
410 QVector<QFixedPoint> fixedPointPositions;
411 const int glyphPositionsSize = glyphPositions.size();
412 fixedPointPositions.reserve(glyphPositionsSize);
413 for (int i=0; i < glyphPositionsSize; ++i)
414 fixedPointPositions.append(QFixedPoint::fromPointF(position + glyphPositions.at(i)));
415
417
418 QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
419 cache->populate(fontD->fontEngine,
420 glyphIndexes.size(),
421 glyphIndexes.constData(),
422 fixedPointPositions.data(),
423 QPainter::RenderHints(),
424 true);
425 cache->fillInPendingGlyphs();
426
427 int margin = fontD->fontEngine->glyphMargin(cache->glyphFormat());
428
429 qreal glyphCacheScaleX = cache->transform().m11();
430 qreal glyphCacheScaleY = cache->transform().m22();
431 qreal glyphCacheInverseScaleX = 1.0 / glyphCacheScaleX;
432 qreal glyphCacheInverseScaleY = 1.0 / glyphCacheScaleY;
433 qreal scaledMargin = margin * glyphCacheInverseScaleX;
434
436 geometry->allocate(glyphIndexes.size() * 4, glyphIndexes.size() * 6);
438 Q_ASSERT(geometry->sizeOfVertex() == sizeof(QVector4D));
439 ushort *ip = geometry->indexDataAsUShort();
440
441 bool supportsSubPixelPositions = fontD->fontEngine->supportsHorizontalSubPixelPositions();
442 for (int i=0; i<glyphIndexes.size(); ++i) {
443 QPointF glyphPosition = glyphPositions.at(i) + position;
444 QFixedPoint fixedPointPosition = fixedPointPositions.at(i);
445
446 QFixed subPixelPosition;
447 if (supportsSubPixelPositions)
448 subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(fixedPointPosition.x.toReal() * glyphCacheScaleX));
449
450 QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphIndexes.at(i),
451 QFixedPoint(subPixelPosition, 0));
452 const QTextureGlyphCache::Coord &c = cache->coords.value(glyph);
453
454 // On a retina screen the glyph positions are not pre-scaled (as opposed to
455 // eg. the raster paint engine). To ensure that we get the same behavior as
456 // the raster engine (and CoreText itself) when it comes to rounding of the
457 // coordinates, we need to apply the scale factor before rounding, and then
458 // apply the inverse scale to get back to the coordinate system of the node.
459
460 qreal x = (qFloor(glyphPosition.x() * glyphCacheScaleX) * glyphCacheInverseScaleX) +
461 (c.baseLineX * glyphCacheInverseScaleX) - scaledMargin;
462 qreal y = (qRound(glyphPosition.y() * glyphCacheScaleY) * glyphCacheInverseScaleY) -
463 (c.baseLineY * glyphCacheInverseScaleY) - scaledMargin;
464
465 qreal w = c.w * glyphCacheInverseScaleX;
466 qreal h = c.h * glyphCacheInverseScaleY;
467
468 *boundingRect |= QRectF(x + scaledMargin, y + scaledMargin, w, h);
469
470 float cx1 = x - margins.left();
471 float cx2 = x + w + margins.right();
472 float cy1 = y - margins.top();
473 float cy2 = y + h + margins.bottom();
474
475 float tx1 = c.x - margins.left();
476 float tx2 = c.x + c.w + margins.right();
477 float ty1 = c.y - margins.top();
478 float ty2 = c.y + c.h + margins.bottom();
479
480 if (baseLine->isNull())
481 *baseLine = glyphPosition;
482
483 vp[4 * i + 0] = QVector4D(cx1, cy1, tx1, ty1);
484 vp[4 * i + 1] = QVector4D(cx2, cy1, tx2, ty1);
485 vp[4 * i + 2] = QVector4D(cx1, cy2, tx1, ty2);
486 vp[4 * i + 3] = QVector4D(cx2, cy2, tx2, ty2);
487
488 int o = i * 4;
489 ip[6 * i + 0] = o + 0;
490 ip[6 * i + 1] = o + 2;
491 ip[6 * i + 2] = o + 3;
492 ip[6 * i + 3] = o + 3;
493 ip[6 * i + 4] = o + 1;
494 ip[6 * i + 5] = o + 0;
495 }
496}
497
499{
500 static QSGMaterialType argb, rgb, gray;
501 switch (glyphCache()->glyphFormat()) {
503 return &argb;
505 return &rgb;
507 default:
508 return &gray;
509 }
510}
511
513{
514 return static_cast<QTextureGlyphCache *>(m_glyphCache.data());
515}
516
521
523{
524 Q_UNUSED(renderMode);
526 const QFontEngine::GlyphFormat glyphFormat = gc->glyphFormat();
527 switch (glyphFormat) {
529 return new QSG32BitColorTextRhiShader(glyphFormat, viewCount());
531 return new QSG24BitTextMaskRhiShader(glyphFormat, viewCount());
533 default:
534 return new QSG8BitTextMaskRhiShader(glyphFormat, viewCount(), gc->eightBitFormatIsAlphaSwizzled());
535 }
536}
537
538static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b)
539{
540 if (a.x() != b.x())
541 return a.x() > b.x() ? 1 : -1;
542 if (a.y() != b.y())
543 return a.y() > b.y() ? 1 : -1;
544 if (a.z() != b.z())
545 return a.z() > b.z() ? 1 : -1;
546 if (a.w() != b.w())
547 return a.w() > b.w() ? 1 : -1;
548 return 0;
549}
550
552{
553 Q_ASSERT(o && type() == o->type());
554 const QSGTextMaskMaterial *other = static_cast<const QSGTextMaskMaterial *>(o);
555 if (m_glyphCache != other->m_glyphCache)
556 return m_glyphCache.data() < other->m_glyphCache.data() ? -1 : 1;
557 return qsg_colorDiff(m_color, other->m_color);
558}
559
561{
563 QSize glyphCacheSize(gc->width(), gc->height());
564 if (glyphCacheSize != m_size) {
565 if (m_texture)
566 delete m_texture;
567 m_texture = new QSGPlainTexture;
568 m_texture->setTexture(gc->texture());
569 m_texture->setTextureSize(QSize(gc->width(), gc->height()));
570 m_texture->setOwnsTexture(false);
571 m_size = glyphCacheSize;
572 return true;
573 }
574 return false;
575}
576
577
582
584{
585 static QSGMaterialType type;
586 return &type;
587}
588
590{
591 Q_UNUSED(renderMode);
593 return new QSGStyledTextRhiShader(gc->glyphFormat(), viewCount(), gc->eightBitFormatIsAlphaSwizzled());
594}
595
597{
598 const QSGStyledTextMaterial *other = static_cast<const QSGStyledTextMaterial *>(o);
599
600 if (m_styleShift != other->m_styleShift)
601 return m_styleShift.y() - other->m_styleShift.y();
602
603 int diff = qsg_colorDiff(m_styleColor, other->m_styleColor);
604 if (diff == 0)
606 return diff;
607}
608
609
614
616{
617 static QSGMaterialType type;
618 return &type;
619}
620
622{
623 Q_UNUSED(renderMode);
625 return new QSGOutlinedTextRhiShader(gc->glyphFormat(), viewCount(), gc->eightBitFormatIsAlphaSwizzled());
626}
627
\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
\inmodule QtCore
Definition qmargins.h:24
constexpr int bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:115
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:106
constexpr int right() const noexcept
Returns the right margin.
Definition qmargins.h:112
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:109
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtCore\reentrant
Definition qpoint.h:217
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:338
static QRawFontPrivate * get(const QRawFont &font)
Definition qrawfont_p.h:104
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:484
\inmodule QtGui
Definition qrhi.h:895
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, int viewCount)
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, int viewCount)
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, int viewCount, 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
int viewCount() const
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, int viewCount, 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...
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...
QSGStyledTextMaterial(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...
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, int viewCount, 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))
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, int viewCount)
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.
\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:327
static QByteArray cacheKey(Args &&...args)
int qFloor(T v)
Definition qmath.h:42
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
T qobject_cast(QObject *object)
\variable QObject::staticMetaObject
Definition qobject.h:419
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]
GLuint color
[2]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint texture
GLenum GLuint GLintptr offset
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
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)
void gc(QV4::ExecutionEngine &engine, GCFlags flags)
Definition qmlutils.cpp:118
#define Q_UNUSED(x)
unsigned int quint32
Definition qtypes.h:50
unsigned short ushort
Definition qtypes.h:33
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
static constexpr QFixedPoint fromPointF(const QPointF &p)
Definition qfixed_p.h:167
static constexpr QFixed fromReal(qreal r)
Definition qfixed_p.h:35
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.