aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp28
-rw-r--r--src/quick/scenegraph/shaders/styledtext.vert3
-rw-r--r--src/quick/scenegraph/shaders/styledtext_core.vert3
-rw-r--r--src/quick/scenegraph/shaders/textmask.vert3
-rw-r--r--src/quick/scenegraph/shaders/textmask_core.vert3
5 files changed, 26 insertions, 14 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index b30a504da9..5cca474ea1 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -59,6 +59,21 @@ static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity)
return QVector4D(c.x() * o, c.y() * o, c.z() * o, o);
}
+static inline int qsg_device_pixel_ratio(QOpenGLContext *ctx)
+{
+ int devicePixelRatio = 1;
+ if (ctx->surface()->surfaceClass() == QSurface::Window) {
+ QWindow *w = static_cast<QWindow *>(ctx->surface());
+ if (QQuickWindow *qw = qobject_cast<QQuickWindow *>(w))
+ devicePixelRatio = qw->effectiveDevicePixelRatio();
+ else
+ devicePixelRatio = w->devicePixelRatio();
+ } else {
+ devicePixelRatio = ctx->screen()->devicePixelRatio();
+ }
+ return devicePixelRatio;
+}
+
class QSGTextMaskShader : public QSGMaterialShader
{
public:
@@ -102,6 +117,7 @@ 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()));
}
void QSGTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
@@ -351,16 +367,8 @@ void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat)
: QFontEngine::Format_A32;
}
- qreal devicePixelRatio;
- if (ctx->surface()->surfaceClass() == QSurface::Window) {
- QWindow *w = static_cast<QWindow *>(ctx->surface());
- if (QQuickWindow *qw = qobject_cast<QQuickWindow *>(w))
- devicePixelRatio = qw->effectiveDevicePixelRatio();
- else
- devicePixelRatio = w->devicePixelRatio();
- } else {
- devicePixelRatio = ctx->screen()->devicePixelRatio();
- }
+ qreal devicePixelRatio = qsg_device_pixel_ratio(ctx);
+
QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio);
if (!fontEngine->supportsTransformation(glyphCacheTransform))
diff --git a/src/quick/scenegraph/shaders/styledtext.vert b/src/quick/scenegraph/shaders/styledtext.vert
index 14fefc2564..7001bbc262 100644
--- a/src/quick/scenegraph/shaders/styledtext.vert
+++ b/src/quick/scenegraph/shaders/styledtext.vert
@@ -1,6 +1,7 @@
uniform highp mat4 matrix;
uniform highp vec2 textureScale;
uniform highp vec2 shift;
+uniform highp float dpr;
attribute highp vec4 vCoord;
attribute highp vec2 tCoord;
@@ -12,5 +13,5 @@ void main()
{
sampleCoord = tCoord * textureScale;
shiftedSampleCoord = (tCoord - shift) * textureScale;
- gl_Position = matrix * floor(vCoord + 0.5);
+ gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr;
}
diff --git a/src/quick/scenegraph/shaders/styledtext_core.vert b/src/quick/scenegraph/shaders/styledtext_core.vert
index 65bdb66814..c522877bb3 100644
--- a/src/quick/scenegraph/shaders/styledtext_core.vert
+++ b/src/quick/scenegraph/shaders/styledtext_core.vert
@@ -9,10 +9,11 @@ out vec2 shiftedSampleCoord;
uniform mat4 matrix;
uniform vec2 textureScale;
uniform vec2 shift;
+uniform float dpr;
void main()
{
sampleCoord = tCoord * textureScale;
shiftedSampleCoord = (tCoord - shift) * textureScale;
- gl_Position = matrix * round(vCoord);
+ gl_Position = matrix * round(vCoord * dpr) / dpr;
}
diff --git a/src/quick/scenegraph/shaders/textmask.vert b/src/quick/scenegraph/shaders/textmask.vert
index dd8918839e..4c678270d0 100644
--- a/src/quick/scenegraph/shaders/textmask.vert
+++ b/src/quick/scenegraph/shaders/textmask.vert
@@ -1,5 +1,6 @@
uniform highp mat4 matrix;
uniform highp vec2 textureScale;
+uniform highp float dpr;
attribute highp vec4 vCoord;
attribute highp vec2 tCoord;
@@ -9,5 +10,5 @@ varying highp vec2 sampleCoord;
void main()
{
sampleCoord = tCoord * textureScale;
- gl_Position = matrix * floor(vCoord + 0.5);
+ gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr;
}
diff --git a/src/quick/scenegraph/shaders/textmask_core.vert b/src/quick/scenegraph/shaders/textmask_core.vert
index d145d33195..f996040f70 100644
--- a/src/quick/scenegraph/shaders/textmask_core.vert
+++ b/src/quick/scenegraph/shaders/textmask_core.vert
@@ -7,9 +7,10 @@ out vec2 sampleCoord;
uniform mat4 matrix;
uniform vec2 textureScale;
+uniform float dpr;
void main()
{
sampleCoord = tCoord * textureScale;
- gl_Position = matrix * round(vCoord);
+ gl_Position = matrix * round(vCoord * dpr) / dpr;
}