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
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 combinedMatrix(int index) const;
44 QMatrix4x4 modelViewMatrix() const;
45 QMatrix4x4 projectionMatrix() const;
46 QMatrix4x4 projectionMatrix(int index) const;
47 int projectionMatrixCount() const;
48 QRect viewportRect() const;
49 QRect deviceRect() const;
50 float determinant() const;
51 float devicePixelRatio() const;
52
53 QByteArray *uniformData();
54 QRhiResourceUpdateBatch *resourceUpdateBatch();
55 QRhi *rhi();
56
57 private:
58 friend class QSGRenderer;
59 DirtyStates m_dirty;
60 const void *m_data;
61 };
62
129
130 enum Flag {
131 UpdatesGraphicsPipelineState = 0x0001
132 };
134
139
141 virtual ~QSGMaterialShader();
142
143 virtual bool updateUniformData(RenderState &state,
144 QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
145
146 virtual void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
147 QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
148
149 virtual bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
150 QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
151
152 Flags flags() const;
153 void setFlag(Flags flags, bool on = true);
154 void setFlags(Flags flags);
155
156 int combinedImageSamplerCount(int binding) const;
157
158protected:
159 Q_DECLARE_PRIVATE(QSGMaterialShader)
161
162 // filename is for a file containing a serialized QShader.
163 void setShaderFileName(Stage stage, const QString &filename);
164 void setShaderFileName(Stage stage, const QString &filename, int viewCount);
165
166 void setShader(Stage stage, const QShader &shader);
167
168private:
169 QScopedPointer<QSGMaterialShaderPrivate> d_ptr;
170};
171
172Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::RenderState::DirtyStates)
173Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::GraphicsPipelineState::ColorMask)
174Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::Flags)
175
177
178#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:1731
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
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 QtGui
Definition qshader.h:81
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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
GLuint index
[2]
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.