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 QSGRHITEXTUREGLYPHCACHE_P_H |
5 | #define QSGRHITEXTUREGLYPHCACHE_P_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 | |
18 | #include <QtGui/private/qtextureglyphcache_p.h> |
19 | #include <rhi/qrhi.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QSGDefaultRenderContext; |
24 | |
25 | class QSGRhiTextureGlyphCache : public QImageTextureGlyphCache |
26 | { |
27 | public: |
28 | QSGRhiTextureGlyphCache(QSGDefaultRenderContext *rc, |
29 | QFontEngine::GlyphFormat format, const QTransform &matrix, |
30 | const QColor &color = QColor()); |
31 | ~QSGRhiTextureGlyphCache(); |
32 | |
33 | void createTextureData(int width, int height) override; |
34 | void resizeTextureData(int width, int height) override; |
35 | void beginFillTexture() override; |
36 | void fillTexture(const Coord &c, glyph_t glyph, const QFixedPoint &subPixelPosition) override; |
37 | void endFillTexture() override; |
38 | int glyphPadding() const override; |
39 | int maxTextureWidth() const override; |
40 | int maxTextureHeight() const override; |
41 | |
42 | QRhiTexture *texture() const { return m_texture; } |
43 | void commitResourceUpdates(QRhiResourceUpdateBatch *mergeInto); |
44 | |
45 | // Clamp the default -1 width and height to 0 for compatibility with |
46 | // QOpenGLTextureGlyphCache. |
47 | int width() const { return qMax(a: 0, b: m_size.width()); } |
48 | int height() const { return qMax(a: 0, b: m_size.height()); } |
49 | |
50 | bool eightBitFormatIsAlphaSwizzled() const; |
51 | |
52 | private: |
53 | void prepareGlyphImage(QImage *img); |
54 | QRhiTexture *createEmptyTexture(QRhiTexture::Format format); |
55 | |
56 | QSGDefaultRenderContext *m_rc; |
57 | QRhi *m_rhi; |
58 | bool m_resizeWithTextureCopy; |
59 | QRhiTexture *m_texture = nullptr; |
60 | QSize m_size; |
61 | bool m_bgra = false; |
62 | QVarLengthArray<QRhiTextureUploadEntry, 16> m_uploads; |
63 | }; |
64 | |
65 | QT_END_NAMESPACE |
66 | |
67 | #endif // QSGRHITEXTUREGLYPHCACHE_P_H |
68 | |