From ddc43cdffaffe8e78b9bb9d8620dafdbe39971ae Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 27 Mar 2015 15:32:16 +0100 Subject: Update the shader when devicePixelRatio changes Task-number: QTBUG-45076 Change-Id: I03de20da2e3f436339dcf48fc7d7d3d11a509577 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph/qsgdefaultglyphnode_p.cpp') diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index ffee43852d..102985f2c7 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -92,6 +92,7 @@ protected: int m_matrix_id; int m_color_id; int m_textureScale_id; + float m_devicePixelRatio; QFontEngine::GlyphFormat m_glyphFormat; }; @@ -121,7 +122,8 @@ void QSGTextMaskShader::initialize() m_matrix_id = program()->uniformLocation("matrix"); m_color_id = program()->uniformLocation("color"); m_textureScale_id = program()->uniformLocation("textureScale"); - program()->setUniformValue("dpr", (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext())); + m_devicePixelRatio = (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext()); + program()->setUniformValue("dpr", m_devicePixelRatio); } void QSGTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) @@ -149,6 +151,12 @@ void QSGTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEf } } + float devicePixelRatio = (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext()); + if (m_devicePixelRatio != devicePixelRatio) { + m_devicePixelRatio = devicePixelRatio; + program()->setUniformValue("dpr", m_devicePixelRatio); + } + if (state.isMatrixDirty()) program()->setUniformValue(m_matrix_id, state.combinedMatrix()); } -- cgit v1.2.3