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_p.h
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
4#ifndef QSGRHIDISTANCEFIELDGLYPHCACHE_H
5#define QSGRHIDISTANCEFIELDGLYPHCACHE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
19#include <private/qsgareaallocator_p.h>
20#include <rhi/qrhi.h>
21
23
25
27{
28public:
29 QSGRhiDistanceFieldGlyphCache(QSGDefaultRenderContext *rc, const QRawFont &font, int renderTypeQuality);
31
32 void requestGlyphs(const QSet<glyph_t> &glyphs) override;
33 void storeGlyphs(const QList<QDistanceField> &glyphs) override;
34 void referenceGlyphs(const QSet<glyph_t> &glyphs) override;
35 void releaseGlyphs(const QSet<glyph_t> &glyphs) override;
36
37 bool useTextureResizeWorkaround() const;
38 bool createFullSizeTextures() const;
39 bool isActive() const override;
40 int maxTextureSize() const;
41
42 void setMaxTextureCount(int max) { m_maxTextureCount = max; }
43 int maxTextureCount() const { return m_maxTextureCount; }
44
45 void commitResourceUpdates(QRhiResourceUpdateBatch *mergeInto);
46
47 bool eightBitFormatIsAlphaSwizzled() const override;
48 bool screenSpaceDerivativesSupported() const override;
49
50#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
51 void saveTexture(QRhiTexture *texture, const QString &nameBase) const override;
52#endif
53
54private:
55 bool loadPregeneratedCache(const QRawFont &font);
56
57 struct TextureInfo {
59 QSize size;
60 QRect allocatedArea;
62 int padding = -1;
63 QVarLengthArray<QRhiTextureUploadEntry, 16> uploads;
64
65 TextureInfo(const QRect &preallocRect = QRect()) : texture(nullptr), allocatedArea(preallocRect) { }
66 };
67
68 void createTexture(TextureInfo *texInfo, int width, int height, const void *pixels);
69 void createTexture(TextureInfo *texInfo, int width, int height);
70 void resizeTexture(TextureInfo *texInfo, int width, int height);
71
72 TextureInfo *textureInfo(int index)
73 {
74 for (int i = m_textures.size(); i <= index; ++i) {
75 if (createFullSizeTextures())
76 m_textures.append(QRect(0, 0, maxTextureSize(), maxTextureSize()));
77 else
78 m_textures.append(TextureInfo());
79 }
80
81 return &m_textures[index];
82 }
83
85 QRhi *m_rhi;
86 mutable int m_maxTextureSize = 0;
87 int m_maxTextureCount = 3;
88 QSGAreaAllocator *m_areaAllocator = nullptr;
89 QList<TextureInfo> m_textures;
90 QHash<glyph_t, TextureInfo *> m_glyphsTexture;
91 QSet<glyph_t> m_unusedGlyphs;
92 QSet<glyph_t> m_referencedGlyphs;
93 QSet<QRhiTexture *> m_pendingDispose;
94};
95
97
98#endif // QSGRHIDISTANCEFIELDGLYPHCACHE_H
bool isActive
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qrhi.h:1731
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
Definition image.cpp:4
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLint GLsizei width
GLenum GLuint texture
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum const void * pixels
QObject::connect nullptr