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
qsgrhidistancefieldglyphcache.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 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 "qsgcontext_p.h"
7#include <QtGui/private/qdistancefield_p.h>
8#include <QtCore/qelapsedtimer.h>
9#include <QtQml/private/qqmlglobal_p.h>
10#include <qmath.h>
11#include <qendian.h>
12
14
15DEFINE_BOOL_CONFIG_OPTION(qmlUseGlyphCacheWorkaround, QML_USE_GLYPHCACHE_WORKAROUND)
16DEFINE_BOOL_CONFIG_OPTION(qsgPreferFullSizeGlyphCacheTextures, QSG_PREFER_FULLSIZE_GLYPHCACHE_TEXTURES)
17
18#if !defined(QSG_RHI_DISTANCEFIELD_GLYPH_CACHE_PADDING)
19# define QSG_RHI_DISTANCEFIELD_GLYPH_CACHE_PADDING 2
20#endif
21
23 const QRawFont &font,
24 int renderTypeQuality)
25 : QSGDistanceFieldGlyphCache(font, renderTypeQuality)
26 , m_rc(rc)
27 , m_rhi(rc->rhi())
28{
29 // Load a pregenerated cache if the font contains one
30 loadPregeneratedCache(font);
31}
32
34{
35 for (const TextureInfo &t : std::as_const(m_textures))
37
38 delete m_areaAllocator;
39}
40
41void QSGRhiDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyphs)
42{
43 QList<GlyphPosition> glyphPositions;
44 QVector<glyph_t> glyphsToRender;
45
46 if (m_areaAllocator == nullptr)
47 m_areaAllocator = new QSGAreaAllocator(QSize(maxTextureSize(), m_maxTextureCount * maxTextureSize()));
48
49 for (QSet<glyph_t>::const_iterator it = glyphs.constBegin(); it != glyphs.constEnd() ; ++it) {
50 glyph_t glyphIndex = *it;
51
54 int glyphWidth = qCeil(boundingRect.width() + distanceFieldRadius() * 2);
55 int glyphHeight = qCeil(boundingRect.height() + distanceFieldRadius() * 2);
56 QSize glyphSize(glyphWidth + padding * 2, glyphHeight + padding * 2);
57 QRect alloc = m_areaAllocator->allocate(glyphSize);
58
59 if (alloc.isNull()) {
60 // Unallocate unused glyphs until we can allocated the new glyph
61 while (alloc.isNull() && !m_unusedGlyphs.isEmpty()) {
62 glyph_t unusedGlyph = *m_unusedGlyphs.constBegin();
63
64 TexCoord unusedCoord = glyphTexCoord(unusedGlyph);
65 QRectF unusedGlyphBoundingRect = glyphData(unusedGlyph).boundingRect;
66 int unusedGlyphWidth = qCeil(unusedGlyphBoundingRect.width() + distanceFieldRadius() * 2);
67 int unusedGlyphHeight = qCeil(unusedGlyphBoundingRect.height() + distanceFieldRadius() * 2);
68 m_areaAllocator->deallocate(QRect(unusedCoord.x - padding,
69 unusedCoord.y - padding,
70 padding * 2 + unusedGlyphWidth,
71 padding * 2 + unusedGlyphHeight));
72
73 m_unusedGlyphs.remove(unusedGlyph);
74 m_glyphsTexture.remove(unusedGlyph);
75 removeGlyph(unusedGlyph);
76
77 alloc = m_areaAllocator->allocate(glyphSize);
78 }
79
80 // Not enough space left for this glyph... skip to the next one
81 if (alloc.isNull())
82 continue;
83 }
84
85 TextureInfo *tex = textureInfo(alloc.y() / maxTextureSize());
86 alloc = QRect(alloc.x(), alloc.y() % maxTextureSize(), alloc.width(), alloc.height());
87
88 tex->allocatedArea |= alloc;
89 Q_ASSERT(tex->padding == padding || tex->padding < 0);
90 tex->padding = padding;
91
93 p.glyph = glyphIndex;
94 p.position = alloc.topLeft() + QPoint(padding, padding);
95
96 glyphPositions.append(p);
97 glyphsToRender.append(glyphIndex);
98 m_glyphsTexture.insert(glyphIndex, tex);
99 }
100
101 setGlyphsPosition(glyphPositions);
102 markGlyphsToRender(glyphsToRender);
103}
104
106{
107 return !m_referencedGlyphs.empty();
108}
109
110void QSGRhiDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &glyphs)
111{
112 typedef QHash<TextureInfo *, QVector<glyph_t> > GlyphTextureHash;
113 typedef GlyphTextureHash::const_iterator GlyphTextureHashConstIt;
114
115 GlyphTextureHash glyphTextures;
116
117 QVarLengthArray<QRhiTextureUploadEntry, 32> uploads;
118 for (int i = 0; i < glyphs.size(); ++i) {
119 QDistanceField glyph = glyphs.at(i);
120 glyph_t glyphIndex = glyph.glyph();
121 TexCoord c = glyphTexCoord(glyphIndex);
122 TextureInfo *texInfo = m_glyphsTexture.value(glyphIndex);
123
124 resizeTexture(texInfo, texInfo->allocatedArea.width(), texInfo->allocatedArea.height());
125
126 glyphTextures[texInfo].append(glyphIndex);
127
128 int padding = texInfo->padding;
129 int expectedWidth = qCeil(c.width + c.xMargin * 2);
130 glyph = glyph.copy(-padding, -padding,
131 expectedWidth + padding * 2, glyph.height() + padding * 2);
132
134 uchar *inBits = glyph.scanLine(0);
135 uchar *outBits = texInfo->image.scanLine(int(c.y) - padding) + int(c.x) - padding;
136 for (int y = 0; y < glyph.height(); ++y) {
137 memcpy(outBits, inBits, glyph.width());
138 inBits += glyph.width();
139 outBits += texInfo->image.width();
140 }
141 }
142
143 QRhiTextureSubresourceUploadDescription subresDesc(glyph.constBits(), glyph.width() * glyph.height());
144 subresDesc.setSourceSize(QSize(glyph.width(), glyph.height()));
145 subresDesc.setDestinationTopLeft(QPoint(c.x - padding, c.y - padding));
146 texInfo->uploads.append(QRhiTextureUploadEntry(0, 0, subresDesc));
147 }
148
149 QRhiResourceUpdateBatch *resourceUpdates = m_rc->glyphCacheResourceUpdates();
150 for (int i = 0; i < glyphs.size(); ++i) {
151 TextureInfo *texInfo = m_glyphsTexture.value(glyphs.at(i).glyph());
152 if (!texInfo->uploads.isEmpty()) {
154 desc.setEntries(texInfo->uploads.cbegin(), texInfo->uploads.cend());
155 resourceUpdates->uploadTexture(texInfo->texture, desc);
156 texInfo->uploads.clear();
157 }
158 }
159
160 for (GlyphTextureHashConstIt i = glyphTextures.constBegin(), cend = glyphTextures.constEnd(); i != cend; ++i) {
161 Texture t;
162 t.texture = i.key()->texture;
163 t.size = i.key()->size;
164 setGlyphsTexture(i.value(), t);
165 }
166}
167
168void QSGRhiDistanceFieldGlyphCache::referenceGlyphs(const QSet<glyph_t> &glyphs)
169{
170 m_referencedGlyphs += glyphs;
171 m_unusedGlyphs -= glyphs;
172}
173
174void QSGRhiDistanceFieldGlyphCache::releaseGlyphs(const QSet<glyph_t> &glyphs)
175{
176 m_referencedGlyphs -= glyphs;
177 m_unusedGlyphs += glyphs;
178}
179
180void QSGRhiDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo,
181 int width,
182 int height)
183{
184 QByteArray zeroBuf(width * height, 0);
185 createTexture(texInfo, width, height, zeroBuf.constData());
186}
187
188void QSGRhiDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo,
189 int width,
190 int height,
191 const void *pixels)
192{
193 if (useTextureResizeWorkaround() && texInfo->image.isNull()) {
194 texInfo->image = QDistanceField(width, height);
195 memcpy(texInfo->image.bits(), pixels, width * height);
196 }
197
199 if (texInfo->texture->create()) {
200 QRhiResourceUpdateBatch *resourceUpdates = m_rc->glyphCacheResourceUpdates();
202 subresDesc.setSourceSize(QSize(width, height));
203 resourceUpdates->uploadTexture(texInfo->texture, QRhiTextureUploadEntry(0, 0, subresDesc));
204 } else {
205 qWarning("Failed to create distance field glyph cache");
206 }
207
208 texInfo->size = QSize(width, height);
209}
210
211void QSGRhiDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int width, int height)
212{
213 int oldWidth = texInfo->size.width();
214 int oldHeight = texInfo->size.height();
215 if (width == oldWidth && height == oldHeight)
216 return;
217
218 QRhiTexture *oldTexture = texInfo->texture;
219 createTexture(texInfo, width, height);
220
221 if (!oldTexture)
222 return;
223
224 updateRhiTexture(oldTexture, texInfo->texture, texInfo->size);
225
226 QRhiResourceUpdateBatch *resourceUpdates = m_rc->glyphCacheResourceUpdates();
228 QRhiTextureSubresourceUploadDescription subresDesc(texInfo->image.constBits(),
229 oldWidth * oldHeight);
230 subresDesc.setSourceSize(QSize(oldWidth, oldHeight));
231 resourceUpdates->uploadTexture(texInfo->texture, QRhiTextureUploadEntry(0, 0, subresDesc));
232 texInfo->image = texInfo->image.copy(0, 0, width, height);
233 } else {
234 resourceUpdates->copyTexture(texInfo->texture, oldTexture);
235 }
236
237 m_rc->deferredReleaseGlyphCacheTexture(oldTexture);
238}
239
241{
242 static bool set = false;
243 static bool useWorkaround = false;
244 if (!set) {
245 useWorkaround = m_rhi->backend() == QRhi::OpenGLES2 || qmlUseGlyphCacheWorkaround();
246 set = true;
247 }
248 return useWorkaround;
249}
250
252{
253 return qsgPreferFullSizeGlyphCacheTextures() && glyphCount() > QT_DISTANCEFIELD_HIGHGLYPHCOUNT();
254}
255
257{
258 if (!m_maxTextureSize)
259 m_maxTextureSize = m_rhi->resourceLimit(QRhi::TextureSizeMax);
260 return m_maxTextureSize;
261}
262
263namespace {
264 struct Qtdf {
265 // We need these structs to be tightly packed, but some compilers we use do not
266 // support #pragma pack(1), so we need to hardcode the offsets/sizes in the
267 // file format
268 enum TableSize {
269 HeaderSize = 14,
270 GlyphRecordSize = 46,
271 TextureRecordSize = 17
272 };
273
274 enum Offset {
275 // Header
276 majorVersion = 0,
277 minorVersion = 1,
278 pixelSize = 2,
279 textureSize = 4,
280 flags = 8,
281 headerPadding = 9,
282 numGlyphs = 10,
283
284 // Glyph record
285 glyphIndex = 0,
286 textureOffsetX = 4,
287 textureOffsetY = 8,
288 textureWidth = 12,
289 textureHeight = 16,
290 xMargin = 20,
291 yMargin = 24,
292 boundingRectX = 28,
293 boundingRectY = 32,
294 boundingRectWidth = 36,
295 boundingRectHeight = 40,
296 textureIndex = 44,
297
298 // Texture record
299 allocatedX = 0,
300 allocatedY = 4,
301 allocatedWidth = 8,
302 allocatedHeight = 12,
303 texturePadding = 16
304
305 };
306
307 template <typename T>
308 static inline T fetch(const char *data, Offset offset)
309 {
310 return qFromBigEndian<T>(data + int(offset));
311 }
312 };
313}
314
315bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
316{
317 // The pregenerated data must be loaded first, otherwise the area allocator
318 // will be wrong
319 if (m_areaAllocator != nullptr) {
320 qWarning("Font cache must be loaded before cache is used");
321 return false;
322 }
323
324 static QElapsedTimer timer;
325
326 bool profile = QSG_LOG_TIME_GLYPH().isDebugEnabled();
327 if (profile)
328 timer.start();
329
330 QByteArray qtdfTable = font.fontTable("qtdf");
331 if (qtdfTable.isEmpty())
332 return false;
333
334 typedef QHash<TextureInfo *, QVector<glyph_t> > GlyphTextureHash;
335
336 GlyphTextureHash glyphTextures;
337
338 if (uint(qtdfTable.size()) < Qtdf::HeaderSize) {
339 qWarning("Invalid qtdf table in font '%s'",
340 qPrintable(font.familyName()));
341 return false;
342 }
343
344 const char *qtdfTableStart = qtdfTable.constData();
345 const char *qtdfTableEnd = qtdfTableStart + qtdfTable.size();
346
347 int padding = 0;
348 int textureCount = 0;
349 {
350 quint8 majorVersion = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::majorVersion);
351 quint8 minorVersion = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::minorVersion);
352 if (majorVersion != 5 || minorVersion != 12) {
353 qWarning("Invalid version of qtdf table %d.%d in font '%s'",
354 majorVersion,
355 minorVersion,
356 qPrintable(font.familyName()));
357 return false;
358 }
359
360 qreal pixelSize = qreal(Qtdf::fetch<quint16>(qtdfTableStart, Qtdf::pixelSize));
361 m_maxTextureSize = Qtdf::fetch<quint32>(qtdfTableStart, Qtdf::textureSize);
362 m_doubleGlyphResolution = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::flags) == 1;
363 padding = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::headerPadding);
364
365 if (pixelSize <= 0.0) {
366 qWarning("Invalid pixel size in '%s'", qPrintable(font.familyName()));
367 return false;
368 }
369
370 if (m_maxTextureSize <= 0) {
371 qWarning("Invalid texture size in '%s'", qPrintable(font.familyName()));
372 return false;
373 }
374
375 int systemMaxTextureSize = m_rhi->resourceLimit(QRhi::TextureSizeMax);
376
377 if (m_maxTextureSize > systemMaxTextureSize) {
378 qWarning("System maximum texture size is %d. This is lower than the value in '%s', which is %d",
379 systemMaxTextureSize,
380 qPrintable(font.familyName()),
381 m_maxTextureSize);
382 }
383
385 qWarning("Padding mismatch in '%s'. Font requires %d, but Qt is compiled with %d.",
386 qPrintable(font.familyName()),
387 padding,
389 }
390
391 m_referenceFont.setPixelSize(pixelSize);
392
393 quint32 glyphCount = Qtdf::fetch<quint32>(qtdfTableStart, Qtdf::numGlyphs);
394 m_unusedGlyphs.reserve(glyphCount);
395
396 const char *allocatorData = qtdfTableStart + Qtdf::HeaderSize;
397 {
398 m_areaAllocator = new QSGAreaAllocator(QSize(0, 0));
399 allocatorData = m_areaAllocator->deserialize(allocatorData, qtdfTableEnd - allocatorData);
400 if (allocatorData == nullptr)
401 return false;
402 }
403
404 if (m_areaAllocator->size().height() % m_maxTextureSize != 0) {
405 qWarning("Area allocator size mismatch in '%s'", qPrintable(font.familyName()));
406 return false;
407 }
408
409 textureCount = m_areaAllocator->size().height() / m_maxTextureSize;
410 m_maxTextureCount = qMax(m_maxTextureCount, textureCount);
411
412 const char *textureRecord = allocatorData;
413 for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
414 if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
415 qWarning("qtdf table too small in font '%s'.",
416 qPrintable(font.familyName()));
417 return false;
418 }
419
420 TextureInfo *tex = textureInfo(i);
421 tex->allocatedArea.setX(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedX));
422 tex->allocatedArea.setY(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedY));
423 tex->allocatedArea.setWidth(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedWidth));
424 tex->allocatedArea.setHeight(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedHeight));
425 tex->padding = Qtdf::fetch<quint8>(textureRecord, Qtdf::texturePadding);
426 }
427
428 const char *glyphRecord = textureRecord;
429 for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
430 if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
431 qWarning("qtdf table too small in font '%s'.",
432 qPrintable(font.familyName()));
433 return false;
434 }
435
436 glyph_t glyph = Qtdf::fetch<quint32>(glyphRecord, Qtdf::glyphIndex);
437 m_unusedGlyphs.insert(glyph);
438
439 GlyphData &glyphData = emptyData(glyph);
440
441#define FROM_FIXED_POINT(value) \
442(((qreal)value)/(qreal)65536)
443
444 glyphData.texCoord.x = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureOffsetX));
445 glyphData.texCoord.y = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureOffsetY));
446 glyphData.texCoord.width = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureWidth));
447 glyphData.texCoord.height = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureHeight));
448 glyphData.texCoord.xMargin = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::xMargin));
449 glyphData.texCoord.yMargin = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::yMargin));
450 glyphData.boundingRect.setX(FROM_FIXED_POINT(Qtdf::fetch<qint32>(glyphRecord, Qtdf::boundingRectX)));
451 glyphData.boundingRect.setY(FROM_FIXED_POINT(Qtdf::fetch<qint32>(glyphRecord, Qtdf::boundingRectY)));
452 glyphData.boundingRect.setWidth(FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::boundingRectWidth)));
453 glyphData.boundingRect.setHeight(FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::boundingRectHeight)));
454
455#undef FROM_FIXED_POINT
456
457 int textureIndex = Qtdf::fetch<quint16>(glyphRecord, Qtdf::textureIndex);
458 if (textureIndex < 0 || textureIndex >= textureCount) {
459 qWarning("Invalid texture index %d (texture count == %d) in '%s'",
460 textureIndex,
461 textureCount,
462 qPrintable(font.familyName()));
463 return false;
464 }
465
466
467 TextureInfo *texInfo = textureInfo(textureIndex);
468 m_glyphsTexture.insert(glyph, texInfo);
469
470 glyphTextures[texInfo].append(glyph);
471 }
472
473 const uchar *textureData = reinterpret_cast<const uchar *>(glyphRecord);
474 for (int i = 0; i < textureCount; ++i) {
475
476 TextureInfo *texInfo = textureInfo(i);
477
478 int width = texInfo->allocatedArea.width();
479 int height = texInfo->allocatedArea.height();
481 if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
482 qWarning("qtdf table too small in font '%s'.",
483 qPrintable(font.familyName()));
484 return false;
485 }
486
487 createTexture(texInfo, width, height, textureData);
488
489 QVector<glyph_t> glyphs = glyphTextures.value(texInfo);
490
491 Texture t;
492 t.texture = texInfo->texture;
493 t.size = texInfo->size;
494
495 setGlyphsTexture(glyphs, t);
496
497 textureData += size;
498 }
499 }
500
501 if (profile) {
502 quint64 now = timer.elapsed();
503 qCDebug(QSG_LOG_TIME_GLYPH,
504 "distancefield: %d pre-generated glyphs loaded in %dms",
505 int(m_unusedGlyphs.size()),
506 int(now));
507 }
508
509 return true;
510}
511
513{
514 if (QRhiResourceUpdateBatch *resourceUpdates = m_rc->maybeGlyphCacheResourceUpdates()) {
515 mergeInto->merge(resourceUpdates);
517 }
518}
519
521{
522 // return true when the shaders for 8-bit formats need .a instead of .r
523 // when sampling the texture
525}
526
531
532#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
533void QSGRhiDistanceFieldGlyphCache::saveTexture(QRhiTexture *texture, const QString &nameBase) const
534{
535 quint64 textureId = texture->nativeTexture().object;
536 QString fileName = nameBase + QLatin1Char('_') + QString::number(textureId, 16);
537 fileName.replace(QLatin1Char('/'), QLatin1Char('_'));
538 fileName.replace(QLatin1Char(' '), QLatin1Char('_'));
539 fileName.append(QLatin1String(".png"));
540
542 rbResult->completed = [rbResult, fileName] {
543 const QSize size = rbResult->pixelSize;
544 const qint64 numPixels = qint64(size.width()) * size.height();
545 if (numPixels == rbResult->data.size()) {
546 // 1 bpp data, may be packed; copy it to ensure QImage scanline alignment
548 const char *p = rbResult->data.constData();
549 for (int i = 0; i < size.height(); i++)
550 memcpy(image.scanLine(i), p + (i * size.width()), size.width());
551 image.save(fileName);
552 } else if (4 * numPixels == rbResult->data.size()) {
553 // 4 bpp data
554 const uchar *p = reinterpret_cast<const uchar *>(rbResult->data.constData());
555 QImage image(p, size.width(), size.height(), QImage::Format_RGBA8888);
556 image.save(fileName);
557 } else {
558 qWarning("Unhandled data format in glyph texture");
559 }
560 delete rbResult;
561 };
562
564 QRhiResourceUpdateBatch *resourceUpdates = m_rc->glyphCacheResourceUpdates();
565 resourceUpdates->readBackTexture(rb, rbResult);
566}
567#endif
568
\inmodule QtCore
Definition qbytearray.h:57
glyph_t glyph() const
QDistanceField copy(const QRect &rect=QRect()) const
const uchar * constBits() const
uchar * scanLine(int)
\inmodule QtCore
bool remove(const Key &key)
Removes the item that has the key from the hash.
Definition qhash.h:958
T value(const Key &key) const noexcept
Definition qhash.h:1054
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
\inmodule QtGui
Definition qimage.h:37
@ Format_RGBA8888
Definition qimage.h:59
@ Format_Grayscale8
Definition qimage.h:66
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
void setPixelSize(qreal pixelSize)
Sets the pixel size with which this font should be rendered to pixelSize.
Definition qrawfont.cpp:774
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr void setY(qreal pos) noexcept
Sets the top edge of the rectangle to the given finite y coordinate.
Definition qrect.h:509
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
Definition qrect.h:818
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
Definition qrect.h:821
constexpr void setX(qreal pos) noexcept
Sets the left edge of the rectangle to the given finite x coordinate.
Definition qrect.h:508
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition qrect.h:164
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:221
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:188
\inmodule QtGui
Definition qrhi.h:777
\inmodule QtGui
Definition qrhi.h:1731
void readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Enqueues a texture-to-host copy operation as described by rb.
Definition qrhi.cpp:9186
void setDestinationTopLeft(const QPoint &p)
Sets the destination top-left position p.
Definition qrhi.h:673
void setSourceSize(const QSize &size)
Sets the source size in pixels.
Definition qrhi.h:676
\inmodule QtGui
Definition qrhi.h:716
\inmodule QtGui
Definition qrhi.h:693
\inmodule QtGui
Definition qrhi.h:895
@ UsedAsTransferSource
Definition qrhi.h:902
@ RED_OR_ALPHA8
Definition qrhi.h:923
int resourceLimit(ResourceLimit limit) const
Definition qrhi.cpp:10121
bool isFeatureSupported(QRhi::Feature feature) const
Definition qrhi.cpp:10110
Implementation backend() const
Definition qrhi.cpp:8651
@ OpenGLES2
Definition qrhi.h:1809
@ TextureSizeMax
Definition qrhi.h:1888
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
Definition qrhi.cpp:10562
@ RedOrAlpha8IsRed
Definition qrhi.h:1842
@ ScreenSpaceDerivatives
Definition qrhi.h:1855
const char * deserialize(const char *data, int size)
QRect allocate(const QSize &size)
bool deallocate(const QRect &rect)
void deferredReleaseGlyphCacheTexture(QRhiTexture *texture)
QRhiResourceUpdateBatch * maybeGlyphCacheResourceUpdates()
QRhiResourceUpdateBatch * glyphCacheResourceUpdates()
void markGlyphsToRender(const QVector< glyph_t > &glyphs)
GlyphData & emptyData(glyph_t glyph)
void setGlyphsTexture(const QVector< glyph_t > &glyphs, const Texture &tex)
void setGlyphsPosition(const QList< GlyphPosition > &glyphs)
TexCoord glyphTexCoord(glyph_t glyph)
void updateRhiTexture(QRhiTexture *oldTex, QRhiTexture *newTex, const QSize &newTexSize)
GlyphData & glyphData(glyph_t glyph)
void releaseGlyphs(const QSet< glyph_t > &glyphs) override
void referenceGlyphs(const QSet< glyph_t > &glyphs) override
void commitResourceUpdates(QRhiResourceUpdateBatch *mergeInto)
void storeGlyphs(const QList< QDistanceField > &glyphs) override
void requestGlyphs(const QSet< glyph_t > &glyphs) override
QSGRhiDistanceFieldGlyphCache(QSGDefaultRenderContext *rc, const QRawFont &font, int renderTypeQuality)
qsizetype size() const
Definition qset.h:50
bool remove(const T &value)
Definition qset.h:63
bool isEmpty() const
Definition qset.h:52
const_iterator constBegin() const noexcept
Definition qset.h:139
void reserve(qsizetype size)
Definition qset.h:226
iterator insert(const T &value)
Definition qset.h:155
bool empty() const
Definition qset.h:177
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition qtimer.cpp:241
QSet< QString >::iterator it
Combined button and popup list for selecting options.
Definition image.cpp:4
int QT_DISTANCEFIELD_HIGHGLYPHCOUNT()
quint16 Offset
#define qWarning
Definition qlogging.h:166
#define qCDebug(category,...)
int qCeil(T v)
Definition qmath.h:36
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const void GLbitfield GLsizei numGlyphs
GLint GLsizei width
GLbitfield flags
GLenum GLuint texture
GLenum GLuint GLintptr offset
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum const void * pixels
GLint y
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QSG_RHI_DISTANCEFIELD_GLYPH_CACHE_PADDING
#define FROM_FIXED_POINT(value)
#define qPrintable(string)
Definition qstring.h:1531
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
unsigned int glyph_t
unsigned int quint32
Definition qtypes.h:50
unsigned char uchar
Definition qtypes.h:32
unsigned long long quint64
Definition qtypes.h:61
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
unsigned char quint8
Definition qtypes.h:46
QFuture< QSet< QChar > > set
[10]
QTimer * timer
[3]
\inmodule QtCore \reentrant
Definition qchar.h:18
\inmodule QtGui
Definition qrhi.h:1723
std::function< void()> completed
Definition qrhi.h:1724