Properly scale cursordelegate_opengl to device geometry

Rather than converting to logical to then later on convert back to
device.
This commit is contained in:
Arjen Hiemstra 2022-08-18 12:16:53 +02:00
parent 642bd06cef
commit ada87dbc60

View file

@ -59,10 +59,11 @@ void CursorDelegateOpenGL::paint(RenderTarget *renderTarget, const QRegion &regi
}
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 &regi
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);
}