Qt 6.x
The Qt SDK
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
62 : m_root_node(nullptr)
63 , m_clear_color(Qt::transparent)
64 , m_clear_mode(QSGAbstractRenderer::ClearColorBuffer | QSGAbstractRenderer::ClearDepthBuffer)
65{
66}
67
73{
74}
75
80{
81}
82
93{
95 if (d->m_root_node == node)
96 return;
97 if (d->m_root_node) {
98 d->m_root_node->m_renderers.removeOne(this);
100 }
101 d->m_root_node = node;
102 if (d->m_root_node) {
103 Q_ASSERT(!d->m_root_node->m_renderers.contains(this));
104 d->m_root_node->m_renderers << this;
106 }
107}
108
115{
116 Q_D(const QSGAbstractRenderer);
117 return d->m_root_node;
118}
119
120
136{
138 d->m_device_rect = rect;
139}
140
147{
148 Q_D(const QSGAbstractRenderer);
149 return d->m_device_rect;
150}
151
169{
171 d->m_viewport_rect = rect;
172}
173
180{
181 Q_D(const QSGAbstractRenderer);
182 return d->m_viewport_rect;
183}
184
195{
197 matrix.ortho(rect.x(),
198 rect.x() + rect.width(),
199 rect.y() + rect.height(),
200 rect.y(),
201 1,
202 -1);
205}
206
219{
220 const bool flipY = flags.testFlag(MatrixTransformFlipY);
222 matrix.ortho(rect.x(),
223 rect.x() + rect.width(),
224 flipY ? rect.y() : rect.y() + rect.height(),
225 flipY ? rect.y() + rect.height() : rect.y(),
226 1,
227 -1);
229
230 if (flipY) {
231 matrix.setToIdentity();
232 matrix.ortho(rect.x(),
233 rect.x() + rect.width(),
234 rect.y() + rect.height(),
235 rect.y(),
236 1,
237 -1);
238 }
240}
241
248{
250 d->m_projection_matrix = matrix;
251}
252
257{
259 d->m_projection_matrix_native_ndc = matrix;
260}
261
268{
269 Q_D(const QSGAbstractRenderer);
270 return d->m_projection_matrix;
271}
272
277{
278 Q_D(const QSGAbstractRenderer);
279 return d->m_projection_matrix_native_ndc;
280}
281
289{
291 d->m_clear_color = color;
292}
293
301{
302 Q_D(const QSGAbstractRenderer);
303 return d->m_clear_color;
304}
305
313{
315 d->m_clear_mode = mode;
316}
317
324QSGAbstractRenderer::ClearMode QSGAbstractRenderer::clearMode() const
325{
326 Q_D(const QSGAbstractRenderer);
327 return d->m_clear_mode;
328}
329
336{
337}
338
340{
341}
342
344
345#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
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore\reentrant
Definition qrect.h:30
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)
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.
QMatrix4x4 projectionMatrix() const
Returns the projection matrix.
virtual void prepareSceneInline()
QSGRootNode * rootNode() const
Returns the root of the QSGNode scene.
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)
Use color to clear the framebuffer when clearMode() is set to QSGAbstractRenderer::ClearColorBuffer.
QMatrix4x4 projectionMatrixWithNativeNDC() const
QSGAbstractRenderer(QObject *parent=nullptr)
void setClearMode(ClearMode mode)
Defines which attachment of the framebuffer should be cleared before each scene render with the mode ...
void setProjectionMatrixWithNativeNDC(const QMatrix4x4 &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
ClearMode clearMode() const
Flags defining which attachment of the framebuffer will be cleared before each scene render.
@ DirtyNodeAdded
Definition qsgnode.h:72
@ DirtyNodeRemoved
Definition qsgnode.h:73
The QSGRootNode is the toplevel root of any scene graph.
Definition qsgnode.h:262
rect
[4]
Combined button and popup list for selecting options.
GLenum mode
GLbitfield flags
GLuint GLenum matrix
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QObject::connect nullptr
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent