From ada87dbc6052796d55a6fbace6cf7358e5e0672e Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 18 Aug 2022 12:16:53 +0200 Subject: [PATCH] Properly scale cursordelegate_opengl to device geometry Rather than converting to logical to then later on convert back to device. --- src/cursordelegate_opengl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cursordelegate_opengl.cpp b/src/cursordelegate_opengl.cpp index 43c2f837de..09e4052d57 100644 --- a/src/cursordelegate_opengl.cpp +++ b/src/cursordelegate_opengl.cpp @@ -59,10 +59,11 @@ void CursorDelegateOpenGL::paint(RenderTarget *renderTarget, const QRegion ®i } const QRect cursorRect = layer()->mapToGlobal(layer()->rect()); + const qreal scale = renderTarget->devicePixelRatio(); QMatrix4x4 mvp; - mvp.ortho(QRect(QPoint(0, 0), renderTarget->size() / renderTarget->devicePixelRatio())); - mvp.translate(cursorRect.x(), cursorRect.y()); + mvp.ortho(QRect(QPoint(0, 0), renderTarget->size())); + mvp.translate(cursorRect.x() * scale, cursorRect.y() * scale); // Don't need to call GLVertexBuffer::beginFrame() and GLVertexBuffer::endOfFrame() because // the GLVertexBuffer::streamingBuffer() is not being used when painting cursor. @@ -72,7 +73,7 @@ void CursorDelegateOpenGL::paint(RenderTarget *renderTarget, const QRegion ®i m_cursorTexture->bind(); ShaderBinder binder(ShaderTrait::MapTexture); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_cursorTexture->render(region, QRect(0, 0, cursorRect.width(), cursorRect.height()), renderTarget->devicePixelRatio()); + m_cursorTexture->render(region, QRect(0, 0, cursorRect.width(), cursorRect.height()), scale); m_cursorTexture->unbind(); glDisable(GL_BLEND); }