aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp1
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp22
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h1
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp1
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp2
6 files changed, 28 insertions, 1 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp b/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
index 63edb33ad0..404fe06f35 100644
--- a/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
@@ -450,6 +450,7 @@ void QSGDefaultRenderer::renderNodes(const QDataBuffer<QSGGeometryNode *> &list)
m_current_model_view_matrix = *m_currentMatrix;
else
m_current_model_view_matrix.setToIdentity();
+ m_current_determinant = m_current_model_view_matrix.determinant();
updates |= QSGMaterialShader::RenderState::DirtyMatrix;
}
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 3c7a401314..308a1fa572 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -334,7 +334,15 @@ float QSGMaterialShader::RenderState::opacity() const
return static_cast<const QSGRenderer *>(m_data)->currentOpacity();
}
+/*!
+ Returns the modelview determinant to be used for rendering
+ */
+float QSGMaterialShader::RenderState::determinant() const
+{
+ Q_ASSERT(m_data);
+ return static_cast<const QSGRenderer *>(m_data)->determinant();
+}
/*!
Returns the matrix combined of modelview matrix and project matrix.
@@ -350,6 +358,20 @@ QMatrix4x4 QSGMaterialShader::RenderState::combinedMatrix() const
/*!
Returns the model view matrix.
+
+ If the material has the RequiresFullMatrix flag
+ set, this is guaranteed to be the complete transform
+ matrix calculated from the scenegraph.
+
+ However, if this flag is not set, the renderer may
+ choose to alter this matrix. For example, it may
+ pre-transform vertices on the CPU and set this matrix
+ to identity.
+
+ In a situation such as the above, it is still possible
+ to retrieve the actual matrix determinant by setting
+ the RequiresDeterminant flag in the material and
+ calling the determinant() accessor.
*/
QMatrix4x4 QSGMaterialShader::RenderState::modelViewMatrix() const
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index 65c8df219f..0673aca814 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -73,6 +73,7 @@ public:
QMatrix4x4 modelViewMatrix() const;
QRect viewportRect() const;
QRect deviceRect() const;
+ float determinant() const;
QOpenGLContext *context() const;
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index 6a894ee6c2..eb7cab557b 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -137,6 +137,7 @@ QSGRenderer::QSGRenderer(QSGContext *context)
, m_clear_color(Qt::transparent)
, m_clear_mode(ClearColorBuffer | ClearDepthBuffer)
, m_current_opacity(1)
+ , m_current_determinant(1)
, m_context(context)
, m_root_node(0)
, m_node_updater(0)
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index ff4196cd49..ec09ed4868 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -104,6 +104,7 @@ public:
QMatrix4x4 currentModelViewMatrix() const { return m_current_model_view_matrix; }
QMatrix4x4 currentCombinedMatrix() const { return m_current_projection_matrix * m_current_model_view_matrix; }
qreal currentOpacity() const { return m_current_opacity; }
+ qreal determinant() const { return m_current_determinant; }
void setProjectionMatrixToDeviceRect();
void setProjectionMatrixToRect(const QRectF &rect);
@@ -153,6 +154,7 @@ protected:
QMatrix4x4 m_current_projection_matrix;
QMatrix4x4 m_current_model_view_matrix;
qreal m_current_opacity;
+ qreal m_current_determinant;
QSGContext *m_context;
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index f17958cdf4..e525d2a458 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -157,7 +157,7 @@ void QSGDistanceFieldTextMaterialShader::updateState(const RenderState &state, Q
}
if (state.isMatrixDirty()) {
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
- m_matrixScale = qSqrt(qAbs(state.modelViewMatrix().determinant()));
+ m_matrixScale = qSqrt(qAbs(state.determinant()));
updateRange = true;
}
if (updateRange) {