Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsgmaterialshader.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 QSGMATERIALSHADER_H
5#define QSGMATERIALSHADER_H
6
7#include <QtQuick/qtquickglobal.h>
8#include <QtCore/QRect>
9#include <QtGui/QMatrix4x4>
10#include <QtGui/QColor>
11#include <QtQuick/qsgmaterialtype.h>
12
14
15class QSGMaterial;
17class QSGTexture;
19class QRhi;
20class QShader;
21
22class Q_QUICK_EXPORT QSGMaterialShader
23{
24public:
25 class Q_QUICK_EXPORT RenderState {
26 public:
28 {
29 DirtyMatrix = 0x0001,
30 DirtyOpacity = 0x0002,
31 DirtyCachedMaterialData = 0x0004,
32 DirtyAll = 0xFFFF
33 };
34 Q_DECLARE_FLAGS(DirtyStates, DirtyState)
35
36 inline DirtyStates dirtyStates() const { return m_dirty; }
37
38 inline bool isMatrixDirty() const { return bool(m_dirty & QSGMaterialShader::RenderState::DirtyMatrix); }
39 inline bool isOpacityDirty() const { return bool(m_dirty & QSGMaterialShader::RenderState::DirtyOpacity); }
40
41 float opacity() const;
42 QMatrix4x4 combinedMatrix() const;
43 QMatrix4x4 modelViewMatrix() const;
44 QMatrix4x4 projectionMatrix() const;
45 QRect viewportRect() const;
46 QRect deviceRect() const;
47 float determinant() const;
48 float devicePixelRatio() const;
49
50 QByteArray *uniformData();
51 QRhiResourceUpdateBatch *resourceUpdateBatch();
52 QRhi *rhi();
53
54 private:
55 friend class QSGRenderer;
56 DirtyStates m_dirty;
57 const void *m_data;
58 };
59
80 OneMinusSrc1Alpha
81 };
82
84 R = 1 << 0,
85 G = 1 << 1,
86 B = 1 << 2,
87 A = 1 << 3
88 };
89 Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)
90
91 enum CullMode {
94 CullBack
95 };
96
100 };
101
105 ColorMask colorWrite;
112 // This struct is extensible while keeping BC since apps only ever get
113 // a ptr to the struct, it is not created by them.
114 };
115
116 enum Flag {
117 UpdatesGraphicsPipelineState = 0x0001
118 };
120
121 enum Stage {
124 };
125
127 virtual ~QSGMaterialShader();
128
129 virtual bool updateUniformData(RenderState &state,
130 QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
131
132 virtual void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
133 QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
134
135 virtual bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
136 QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
137
138 Flags flags() const;
139 void setFlag(Flags flags, bool on = true);
140 void setFlags(Flags flags);
141
142 int combinedImageSamplerCount(int binding) const;
143
144protected:
145 Q_DECLARE_PRIVATE(QSGMaterialShader)
147
148 // filename is for a file containing a serialized QShader.
149 void setShaderFileName(Stage stage, const QString &filename);
150
151 void setShader(Stage stage, const QShader &shader);
152
153private:
155};
156
157Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::RenderState::DirtyStates)
158Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::GraphicsPipelineState::ColorMask)
159Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::Flags)
160
162
163#endif
NSData * m_data
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qrhi.h:1694
\inmodule QtGui
Definition qrhi.h:1767
Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and ...
bool isMatrixDirty() const
Returns true if the dirtyStates() contain the dirty matrix state, otherwise returns false.
DirtyState
\value DirtyMatrix Used to indicate that the matrix has changed and must be updated.
bool isOpacityDirty() const
Returns true if the dirtyStates() contains the dirty opacity state, otherwise returns false.
The QSGMaterialShader class represents a graphics API independent shader program.
Flag
Flag values to indicate special material properties.
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
The renderer class is the abstract baseclass used for rendering the QML scene graph.
\inmodule QtQuick
Definition qsgtexture.h:20
\inmodule QtCore
\inmodule QtGui
Definition qshader.h:81
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
else opt state
[0]
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Flags
n varying highp vec2 A
GLbitfield flags
GLenum GLuint texture
GLuint shader
Definition qopenglext.h:665
Describes state changes that the material wants to apply to the currently active graphics pipeline st...
PolygonMode
Specifies the polygon rasterization mode.