aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode_p.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 210e9f23f5..9e0cfca069 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -178,7 +178,7 @@ void QSGTextMaskMaterialData::updateState(const RenderState &state, QSGMaterial
1.0 / material->cacheTextureHeight()));
glBindTexture(GL_TEXTURE_2D, material->texture()->textureId());
- // Set the mag/min filters to be linear. We only need to do this when the texture
+ // Set the mag/min filters to be nearest. We only need to do this when the texture
// has been recreated.
if (updated) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -186,8 +186,28 @@ void QSGTextMaskMaterialData::updateState(const RenderState &state, QSGMaterial
}
}
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
+ if (state.isMatrixDirty()) {
+ QMatrix4x4 transform = state.modelViewMatrix();
+ qreal xTranslation = transform(0, 3);
+ qreal yTranslation = transform(1, 3);
+
+ // Remove translation and check identity to see if matrix is only translating.
+ // If it is, we can round the translation to make sure the text is pixel aligned,
+ // which is the only thing that works with GL_NEAREST filtering. Adding rotations
+ // and scales to native rendered text is not a prioritized use case, since the
+ // default rendering type is designed for that.
+ transform(0, 3) = 0.0;
+ transform(1, 3) = 0.0;
+ if (transform.isIdentity()) {
+ transform(0, 3) = qRound(xTranslation);
+ transform(1, 3) = qRound(yTranslation);
+
+ transform = state.projectionMatrix() * transform;
+ program()->setUniformValue(m_matrix_id, transform);
+ } else {
+ program()->setUniformValue(m_matrix_id, state.combinedMatrix());
+ }
+ }
}
QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font)