From 64e42bbd04e10e8b0c32bec444864ce7c64bbfc5 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 28 Jul 2022 14:09:33 +0200 Subject: [PATCH] Round window and geometry positions in OpenGL scene This rounds the position of geometry in the OpenGL scene, which means things that are fractionally scaled and end up between pixel boundaries are instead aligned to pixels. This doesn't fully solve the fractional scaling blurriness, as we still need the application to provide a buffer with the correct size. If we do have a buffer with the correct size, we will now render properly aligned. For example, internal clients should now be correct. --- src/libkwineffects/kwineffects.cpp | 4 ++-- src/scenes/opengl/scene_opengl.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index cfc01e5134..d010955bfa 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -1087,7 +1087,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic for (int j = 0; j < 4; j++) { const WindowVertex &wv = quad[j]; - auto vertexPos = QVector2D(wv.x(), wv.y()) * scale; + auto vertexPos = roundVector(QVector2D(wv.x(), wv.y()) * scale); GLVertex2D v; v.position = vertexPos; v.texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; @@ -1104,7 +1104,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic for (int j = 0; j < 4; j++) { const WindowVertex &wv = quad[j]; - auto vertexPos = QVector2D(wv.x(), wv.y()) * scale; + auto vertexPos = roundVector(QVector2D(wv.x(), wv.y()) * scale); v[j].position = vertexPos; v[j].texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; } diff --git a/src/scenes/opengl/scene_opengl.cpp b/src/scenes/opengl/scene_opengl.cpp index c117329fef..306efd98db 100644 --- a/src/scenes/opengl/scene_opengl.cpp +++ b/src/scenes/opengl/scene_opengl.cpp @@ -326,9 +326,9 @@ void SceneOpenGL::createRenderNode(Item *item, RenderContext *context) const QList sortedChildItems = item->sortedChildItems(); QMatrix4x4 matrix; - const auto logicalPosition = QVector3D(item->position().x(), item->position().y(), 0.0); + const auto logicalPosition = QVector2D(item->position().x(), item->position().y()); const auto scale = context->renderTargetScale; - matrix.translate(logicalPosition * scale); + matrix.translate(roundVector(logicalPosition * scale).toVector3D()); matrix *= item->transform(); context->transformStack.push(context->transformStack.top() * matrix);