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
qsgabstractrenderer.cpp
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
5
7
55
63
70
81{
83 if (d->m_root_node == node)
84 return;
85 if (d->m_root_node) {
86 d->m_root_node->m_renderers.removeOne(this);
88 }
89 d->m_root_node = node;
90 if (d->m_root_node) {
91 Q_ASSERT(!d->m_root_node->m_renderers.contains(this));
92 d->m_root_node->m_renderers << this;
94 }
95}
96
103{
104 Q_D(const QSGAbstractRenderer);
105 return d->m_root_node;
106}
107
108
124{
126 d->m_device_rect = rect;
127}
128
135{
136 Q_D(const QSGAbstractRenderer);
137 return d->m_device_rect;
138}
139
157{
159 d->m_viewport_rect = rect;
160}
161
168{
169 Q_D(const QSGAbstractRenderer);
170 return d->m_viewport_rect;
171}
172
186
202
222 bool nativeNDCFlipY)
223{
224 const bool flipY = flags.testFlag(MatrixTransformFlipY);
225
226 const float left = rect.x();
227 const float right = rect.x() + rect.width();
228 float bottom = rect.y() + rect.height();
229 float top = rect.y();
230
231 if (flipY)
232 std::swap(top, bottom);
233
235 matrix.ortho(left, right, bottom, top, 1, -1);
237
238 if (nativeNDCFlipY) {
239 std::swap(top, bottom);
240
241 matrix.setToIdentity();
242 matrix.ortho(left, right, bottom, top, 1, -1);
243 }
245}
246
255{
257 if (d->m_projection_matrix.count() <= index)
258 d->m_projection_matrix.resize(index + 1);
259 d->m_projection_matrix[index] = matrix;
260}
261
266{
268 if (d->m_projection_matrix_native_ndc.count() <= index)
269 d->m_projection_matrix_native_ndc.resize(index + 1);
270 d->m_projection_matrix_native_ndc[index] = matrix;
271}
272
279{
280 Q_D(const QSGAbstractRenderer);
281 return d->m_projection_matrix[index];
282}
283
285{
286 Q_D(const QSGAbstractRenderer);
287 return d->m_projection_matrix.count();
288}
289
291{
292 Q_D(const QSGAbstractRenderer);
293 return d->m_projection_matrix_native_ndc.count();
294}
295
300{
301 Q_D(const QSGAbstractRenderer);
302 return d->m_projection_matrix_native_ndc[index];
303}
304
311{
313 d->m_clear_color = color;
314}
315
323{
324 Q_D(const QSGAbstractRenderer);
325 return d->m_clear_color;
326}
327
336
340
342
343#include "moc_qsgabstractrenderer_p.cpp"
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
void ortho(const QRect &rect)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
QVarLengthArray< QMatrix4x4, 1 > m_projection_matrix_native_ndc
QVarLengthArray< QMatrix4x4, 1 > m_projection_matrix
QSGAbstractRenderer gives access to the scene graph nodes and rendering.
QRect deviceRect() const
Returns the device rect of the surface being rendered to.
void setProjectionMatrix(const QMatrix4x4 &matrix, int index=0)
Use matrix to project the QSGNode coordinates onto surface pixels.
QRect viewportRect() const
Returns the rect of the viewport to render.
void setViewportRect(const QRect &rect)
Sets rect as the geometry of the viewport to render on the surface.
virtual void prepareSceneInline()
QSGRootNode * rootNode() const
Returns the root of the QSGNode scene.
QMatrix4x4 projectionMatrixWithNativeNDC(int index) const
void setProjectionMatrixToRect(const QRectF &rect)
Convenience method that calls setProjectionMatrix() with an orthographic matrix generated from rect.
void setDeviceRect(const QRect &rect)
Sets rect as the geometry of the surface being rendered to.
void setClearColor(const QColor &color)
Sets the color to clear the framebuffer.
QSGAbstractRenderer(QObject *parent=nullptr)
int projectionMatrixWithNativeNDCCount() const
void setProjectionMatrixWithNativeNDC(const QMatrix4x4 &matrix, int index=0)
QMatrix4x4 projectionMatrix(int index) const
Returns the projection matrix.
QColor clearColor() const
Returns the color that clears the framebuffer at the beginning of the rendering.
void setRootNode(QSGRootNode *node)
Sets the node as the root of the QSGNode scene that you want to render.
virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state)=0
@ DirtyNodeAdded
Definition qsgnode.h:72
@ DirtyNodeRemoved
Definition qsgnode.h:73
The QSGRootNode is the toplevel root of any scene graph.
Definition qsgnode.h:259
void resize(qsizetype sz)
rect
[4]
Combined button and popup list for selecting options.
Definition qcompare.h:63
GLuint index
[2]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLuint color
[2]
GLint left
GLint GLint bottom
GLbitfield flags
GLuint GLenum matrix
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QObject::connect nullptr