From 9e7a7afcccba8575b71ea8245caf99a5956b1258 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Fri, 5 Aug 2022 11:36:41 +0200 Subject: [PATCH] snaphelper: Account for render target scale when creating geometry --- src/effects/snaphelper/snaphelper.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/effects/snaphelper/snaphelper.cpp b/src/effects/snaphelper/snaphelper.cpp index 8abb681789..4d96ddf4b2 100644 --- a/src/effects/snaphelper/snaphelper.cpp +++ b/src/effects/snaphelper/snaphelper.cpp @@ -99,6 +99,8 @@ void SnapHelperEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD : 1.0; const QList screens = effects->screens(); + const auto scale = effects->renderTargetScale(); + // Display the guide if (effects->isOpenGLCompositing()) { GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); @@ -124,28 +126,28 @@ void SnapHelperEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD const int halfHeight = m_geometry.height() / 2; // Center vertical line. - verts << rect.x() + rect.width() / 2 << rect.y(); - verts << rect.x() + rect.width() / 2 << rect.y() + rect.height(); + verts << (rect.x() + rect.width() / 2) * scale << rect.y() * scale; + verts << (rect.x() + rect.width() / 2) * scale << (rect.y() + rect.height()) * scale; // Center horizontal line. - verts << rect.x() << rect.y() + rect.height() / 2; - verts << rect.x() + rect.width() << rect.y() + rect.height() / 2; + verts << rect.x() * scale << (rect.y() + rect.height() / 2) * scale; + verts << (rect.x() + rect.width()) * scale << (rect.y() + rect.height() / 2) * scale; // Top edge of the window outline. - verts << midX - halfWidth - s_lineWidth / 2 << midY - halfHeight; - verts << midX + halfWidth + s_lineWidth / 2 << midY - halfHeight; + verts << (midX - halfWidth - s_lineWidth / 2) * scale << (midY - halfHeight) * scale; + verts << (midX + halfWidth + s_lineWidth / 2) * scale << (midY - halfHeight) * scale; // Right edge of the window outline. - verts << midX + halfWidth << midY - halfHeight + s_lineWidth / 2; - verts << midX + halfWidth << midY + halfHeight - s_lineWidth / 2; + verts << (midX + halfWidth) * scale << (midY - halfHeight + s_lineWidth / 2) * scale; + verts << (midX + halfWidth) * scale << (midY + halfHeight - s_lineWidth / 2) * scale; // Bottom edge of the window outline. - verts << midX + halfWidth + s_lineWidth / 2 << midY + halfHeight; - verts << midX - halfWidth - s_lineWidth / 2 << midY + halfHeight; + verts << (midX + halfWidth + s_lineWidth / 2) * scale << (midY + halfHeight) * scale; + verts << (midX - halfWidth - s_lineWidth / 2) * scale << (midY + halfHeight) * scale; // Left edge of the window outline. - verts << midX - halfWidth << midY + halfHeight - s_lineWidth / 2; - verts << midX - halfWidth << midY - halfHeight + s_lineWidth / 2; + verts << (midX - halfWidth) * scale << (midY + halfHeight - s_lineWidth / 2) * scale; + verts << (midX - halfWidth) * scale << (midY - halfHeight + s_lineWidth / 2) * scale; } vbo->setData(verts.count() / 2, 2, verts.data(), nullptr); vbo->render(GL_LINES);