49QSGAbstractRendererPrivate::QSGAbstractRendererPrivate()
50 : m_root_node(
nullptr)
51 , m_clear_color(Qt::transparent)
52 , m_invertFrontFace(
false)
54 m_projection_matrix.resize(1);
55 m_projection_matrix_native_ndc.resize(1);
82void QSGAbstractRenderer::setRootNode(QSGRootNode *node)
84 Q_D(QSGAbstractRenderer);
85 if (d->m_root_node == node)
88 d->m_root_node->m_renderers.removeOne(
this);
89 nodeChanged(d->m_root_node, QSGNode::DirtyNodeRemoved);
91 d->m_root_node = node;
93 Q_ASSERT(!d->m_root_node->m_renderers.contains(
this));
94 d->m_root_node->m_renderers <<
this;
95 nodeChanged(d->m_root_node, QSGNode::DirtyNodeAdded);
200void QSGAbstractRenderer::setProjectionMatrixToRect(
const QRectF &rect, MatrixTransformFlags flags)
202 setProjectionMatrixToRect(rect, flags, flags.testFlag(MatrixTransformFlipY));
223void QSGAbstractRenderer::setProjectionMatrixToRect(
const QRectF &rect, MatrixTransformFlags flags,
226 const bool flipY = flags.testFlag(MatrixTransformFlipY);
228 const float left = rect.x();
229 const float right = rect.x() + rect.width();
230 float bottom = rect.y() + rect.height();
231 float top = rect.y();
234 std::swap(top, bottom);
237 matrix.ortho(left, right, bottom, top, 1, -1);
238 setProjectionMatrix(matrix, 0);
240 if (nativeNDCFlipY) {
241 std::swap(top, bottom);
243 matrix.setToIdentity();
244 matrix.ortho(left, right, bottom, top, 1, -1);
246 setProjectionMatrixWithNativeNDC(matrix, 0);
256void QSGAbstractRenderer::setProjectionMatrix(
const QMatrix4x4 &matrix,
int index)
258 Q_D(QSGAbstractRenderer);
259 if (d->m_projection_matrix.count() <= index)
260 d->m_projection_matrix.resize(index + 1);
261 d->m_projection_matrix[index] = matrix;
267void QSGAbstractRenderer::setProjectionMatrixWithNativeNDC(
const QMatrix4x4 &matrix,
int index)
269 Q_D(QSGAbstractRenderer);
270 if (d->m_projection_matrix_native_ndc.count() <= index)
271 d->m_projection_matrix_native_ndc.resize(index + 1);
272 d->m_projection_matrix_native_ndc[index] = matrix;