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
4#ifndef QSGDISTANCEFIELDGLYPHNODE_P_P_H
5#define QSGDISTANCEFIELDGLYPHNODE_P_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 <QtQuick/qsgmaterial.h>
19#include <QtQuick/private/qsgplaintexture_p.h>
20#include "qsgdistancefieldglyphnode_p.h"
21#include "qsgadaptationlayer_p.h"
22
23QT_BEGIN_NAMESPACE
24
25class QSGPlainTexture;
26
27class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldTextMaterial: public QSGMaterial
28{
29public:
30 QSGDistanceFieldTextMaterial();
31 ~QSGDistanceFieldTextMaterial();
32
33 QSGMaterialType *type() const override;
34 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
35 int compare(const QSGMaterial *other) const override;
36
37 virtual void setColor(const QColor &color);
38 const QVector4D &color() const { return m_color; }
39
40 void setGlyphCache(QSGDistanceFieldGlyphCache *a) { m_glyph_cache = a; }
41 QSGDistanceFieldGlyphCache *glyphCache() const { return m_glyph_cache; }
42
43 void setTexture(const QSGDistanceFieldGlyphCache::Texture * tex) { m_texture = tex; }
44 const QSGDistanceFieldGlyphCache::Texture * texture() const { return m_texture; }
45
46 void setFontScale(qreal fontScale) { m_fontScale = fontScale; }
47 qreal fontScale() const { return m_fontScale; }
48
49 QSize textureSize() const { return m_size; }
50
51 bool updateTextureSize();
52 bool updateTextureSizeAndWrapper();
53 QSGTexture *wrapperTexture() const { return m_sgTexture; }
54
55protected:
56 QSize m_size;
57 QVector4D m_color;
58 QSGDistanceFieldGlyphCache *m_glyph_cache;
59 const QSGDistanceFieldGlyphCache::Texture *m_texture;
60 qreal m_fontScale;
61 QSGPlainTexture *m_sgTexture;
62};
63
64class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldStyledTextMaterial : public QSGDistanceFieldTextMaterial
65{
66public:
67 QSGDistanceFieldStyledTextMaterial();
68 ~QSGDistanceFieldStyledTextMaterial();
69
70 QSGMaterialType *type() const override = 0;
71 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override = 0;
72 int compare(const QSGMaterial *other) const override;
73
74 void setStyleColor(const QColor &color);
75 const QVector4D &styleColor() const { return m_styleColor; }
76
77protected:
78 QVector4D m_styleColor;
79};
80
81class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldOutlineTextMaterial : public QSGDistanceFieldStyledTextMaterial
82{
83public:
84 QSGDistanceFieldOutlineTextMaterial();
85 ~QSGDistanceFieldOutlineTextMaterial();
86
87 QSGMaterialType *type() const override;
88 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
89};
90
91class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldShiftedStyleTextMaterial : public QSGDistanceFieldStyledTextMaterial
92{
93public:
94 QSGDistanceFieldShiftedStyleTextMaterial();
95 ~QSGDistanceFieldShiftedStyleTextMaterial();
96
97 QSGMaterialType *type() const override;
98 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
99 int compare(const QSGMaterial *other) const override;
100
101 void setShift(const QPointF &shift) { m_shift = shift; }
102 const QPointF &shift() const { return m_shift; }
103
104protected:
105 QPointF m_shift;
106};
107
108class Q_QUICK_PRIVATE_EXPORT QSGHiQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial
109{
110public:
111 QSGMaterialType *type() const override;
112 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
113 void setColor(const QColor &color) override {
114 const auto rgbColor = color.toRgb();
115 m_color = QVector4D(rgbColor.redF(), rgbColor.greenF(), rgbColor.blueF(), rgbColor.alphaF());
116 }
117};
118
119class Q_QUICK_PRIVATE_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial
120{
121public:
122 QSGMaterialType *type() const override;
123 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
124 void setColor(const QColor &color) override {
125 const auto rgbColor = color.toRgb();
126 m_color = QVector4D(rgbColor.redF(), rgbColor.greenF(), rgbColor.blueF(), rgbColor.alphaF());
127 }
128};
129
130QT_END_NAMESPACE
131
132#endif
133

source code of qtdeclarative/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h