From aba3335ea6ff2c9a912eea0464987e33763d0c20 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sat, 29 May 2021 04:35:52 +0200 Subject: [PATCH] Fix weird decoration glitch when using a scaled display We used to get a weird line around the window decoration because the clamping would hit the outside of the rendered decoration. To make sure we fall inside take the displayPixelRatio into account. Also on non-integer scales, make sure we are actually falling inside. --- src/plugins/scenes/opengl/scene_opengl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/scenes/opengl/scene_opengl.cpp b/src/plugins/scenes/opengl/scene_opengl.cpp index 600002e88e..e6a82bd185 100644 --- a/src/plugins/scenes/opengl/scene_opengl.cpp +++ b/src/plugins/scenes/opengl/scene_opengl.cpp @@ -2588,7 +2588,9 @@ void SceneOpenGLDecorationRenderer::render(const QRegion ®ion) renderToPainter(&painter, geo); painter.end(); - clamp(image, QRect(viewport.topLeft(), viewport.size() * devicePixelRatio)); + const QRect viewportScaled(viewport.topLeft() * devicePixelRatio, viewport.size() * devicePixelRatio); + const bool isIntegerScaling = qFuzzyCompare(devicePixelRatio, std::ceil(devicePixelRatio)); + clamp(image, isIntegerScaling ? viewportScaled : viewportScaled.marginsRemoved({1, 1, 1, 1})); if (rotated) { // TODO: get this done directly when rendering to the image