Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgdefaultglyphnode_p_p.h
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
4#ifndef QSGDEFAULTGLYPHNODE_P_P_H
5#define QSGDEFAULTGLYPHNODE_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 <qcolor.h>
19#include <QtQuick/qsgmaterial.h>
20#include <QtQuick/qsgtexture.h>
21#include <QtQuick/qsggeometry.h>
22#include <qshareddata.h>
23#include <QtQuick/private/qsgplaintexture_p.h>
24#include <QtQuick/private/qsgrhitextureglyphcache_p.h>
25#include <qrawfont.h>
26#include <qmargins.h>
27
28QT_BEGIN_NAMESPACE
29
30class QFontEngine;
31class Geometry;
32class QSGRenderContext;
33class QSGDefaultRenderContext;
34
36{
37public:
38 QSGTextMaskMaterial(QSGRenderContext *rc, const QVector4D &color, const QRawFont &font, QFontEngine::GlyphFormat glyphFormat = QFontEngine::Format_None);
39 virtual ~QSGTextMaskMaterial();
40
41 QSGMaterialType *type() const override;
42 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
43 int compare(const QSGMaterial *other) const override;
44
45 void setColor(const QColor &c) {
46 const auto rgbC = c.toRgb();
47 setColor(QVector4D(rgbC.redF(), rgbC.greenF(), rgbC.blueF(), rgbC.alphaF()));
48 }
49 void setColor(const QVector4D &color);
50 const QVector4D &color() const { return m_color; }
51
52 QSGTexture *texture() const { return m_texture; }
53
54 bool ensureUpToDate();
55
58
59 void populate(const QPointF &position,
60 const QVector<quint32> &glyphIndexes, const QVector<QPointF> &glyphPositions,
61 QSGGeometry *geometry, QRectF *boundingRect, QPointF *baseLine,
62 const QMargins &margins = QMargins(0, 0, 0, 0));
63
64private:
65 void init(QFontEngine::GlyphFormat glyphFormat);
66 void updateCache(QFontEngine::GlyphFormat glyphFormat);
67
68 QSGDefaultRenderContext *m_rc;
69 QSGPlainTexture *m_texture;
70 QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache;
71 QRawFont m_font;
72 QFontEngine *m_retainedFontEngine = nullptr;
73 QRhi *m_rhi;
74 QVector4D m_color;
75 QSize m_size;
76};
77
79{
80public:
81 QSGStyledTextMaterial(QSGRenderContext *rc, const QRawFont &font);
82 virtual ~QSGStyledTextMaterial() { }
83
84 void setStyleShift(const QVector2D &shift) { m_styleShift = shift; }
85 const QVector2D &styleShift() const { return m_styleShift; }
86
87 void setStyleColor(const QColor &c) {
88 const auto rgbC = c.toRgb();
89 m_styleColor = QVector4D(rgbC.redF(), rgbC.greenF(), rgbC.blueF(), rgbC.alphaF());
90 }
91 void setStyleColor(const QVector4D &color) { m_styleColor = color; }
92 const QVector4D &styleColor() const { return m_styleColor; }
93
94 QSGMaterialType *type() const override;
95 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
96 int compare(const QSGMaterial *other) const override;
97
98private:
99 QVector2D m_styleShift;
100 QVector4D m_styleColor;
101};
102
104{
105public:
106 QSGOutlinedTextMaterial(QSGRenderContext *rc, const QRawFont &font);
108
109 QSGMaterialType *type() const override;
110 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
111};
112
113QT_END_NAMESPACE
114
115#endif
\inmodule QtCore
Definition qmargins.h:26
constexpr void setTop(int top) noexcept
Sets the Top margin to Top.
Definition qmargins.h:147
constexpr void setBottom(int bottom) noexcept
Sets the bottom margin to bottom.
Definition qmargins.h:153
constexpr QMargins(int left, int top, int right, int bottom) noexcept
Constructs margins with the given left, top, right, and bottom.
Definition qmargins.h:125
friend class QFontEngine
Definition qpainter.h:432
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
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...
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...
void setStyleColor(const QVector4D &color)
const QVector2D & styleShift() const
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
void setStyleShift(const QVector2D &shift)
QSGStyledTextMaterial(QSGRenderContext *rc, const QRawFont &font)
const QVector4D & styleColor() const
void setStyleColor(const QColor &c)
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QSGTextMaskMaterial(QSGRenderContext *rc, const QVector4D &color, const QRawFont &font, QFontEngine::GlyphFormat glyphFormat=QFontEngine::Format_None)
void setColor(const QVector4D &color)
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))
QSGTexture * texture() const