48QSGAbstractRendererPrivate::QSGAbstractRendererPrivate()
49 : m_root_node(
nullptr)
50 , m_clear_color(Qt::transparent)
51 , m_invertFrontFace(
false)
53 m_projection_matrix.resize(1);
54 m_projection_matrix_native_ndc.resize(1);
81void QSGAbstractRenderer::setRootNode(QSGRootNode *node)
83 Q_D(QSGAbstractRenderer);
84 if (d->m_root_node == node)
87 d->m_root_node->m_renderers.removeOne(
this);
88 nodeChanged(d->m_root_node, QSGNode::DirtyNodeRemoved);
90 d->m_root_node = node;
92 Q_ASSERT(!d->m_root_node->m_renderers.contains(
this));
93 d->m_root_node->m_renderers <<
this;
94 nodeChanged(d->m_root_node, QSGNode::DirtyNodeAdded);
199void QSGAbstractRenderer::setProjectionMatrixToRect(
const QRectF &rect, MatrixTransformFlags flags)
201 setProjectionMatrixToRect(rect, flags, flags.testFlag(MatrixTransformFlipY));
222void QSGAbstractRenderer::setProjectionMatrixToRect(
const QRectF &rect, MatrixTransformFlags flags,
225 const bool flipY = flags.testFlag(MatrixTransformFlipY);
227 const float left = rect.x();
228 const float right = rect.x() + rect.width();
229 float bottom = rect.y() + rect.height();
230 float top = rect.y();
233 std::swap(top, bottom);
236 matrix.ortho(left, right, bottom, top, 1, -1);
237 setProjectionMatrix(matrix, 0);
239 if (nativeNDCFlipY) {
240 std::swap(top, bottom);
242 matrix.setToIdentity();
243 matrix.ortho(left, right, bottom, top, 1, -1);
245 setProjectionMatrixWithNativeNDC(matrix, 0);
255void QSGAbstractRenderer::setProjectionMatrix(
const QMatrix4x4 &matrix,
int index)
257 Q_D(QSGAbstractRenderer);
258 if (d->m_projection_matrix.count() <= index)
259 d->m_projection_matrix.resize(index + 1);
260 d->m_projection_matrix[index] = matrix;
266void QSGAbstractRenderer::setProjectionMatrixWithNativeNDC(
const QMatrix4x4 &matrix,
int index)
268 Q_D(QSGAbstractRenderer);
269 if (d->m_projection_matrix_native_ndc.count() <= index)
270 d->m_projection_matrix_native_ndc.resize(index + 1);
271 d->m_projection_matrix_native_ndc[index] = matrix;