diff --git a/src/effects/screenshot/screenshot.cpp b/src/effects/screenshot/screenshot.cpp index f724a7d4e9..3d20adce8e 100644 --- a/src/effects/screenshot/screenshot.cpp +++ b/src/effects/screenshot/screenshot.cpp @@ -246,6 +246,7 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot) if (validTarget) { d.setXTranslation(-geometry.x()); d.setYTranslation(-geometry.y()); + d.setRenderTargetScale(devicePixelRatio); // render window into offscreen texture int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT; diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index 50268deca7..cfc01e5134 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -233,6 +233,7 @@ public: qreal crossFadeProgress; QMatrix4x4 pMatrix; QMatrix4x4 screenProjectionMatrix; + std::optional renderTargetScale = std::nullopt; }; WindowPaintData::WindowPaintData() @@ -411,6 +412,16 @@ QMatrix4x4 WindowPaintData::screenProjectionMatrix() const return d->screenProjectionMatrix; } +std::optional WindowPaintData::renderTargetScale() const +{ + return d->renderTargetScale; +} + +void WindowPaintData::setRenderTargetScale(qreal scale) +{ + d->renderTargetScale = scale; +} + class ScreenPaintData::Private { public: diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index 95186af1b8..d99be81f20 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -39,6 +39,7 @@ #include #include +#include class KConfigGroup; class QFont; @@ -3300,6 +3301,15 @@ public: */ QMatrix4x4 screenProjectionMatrix() const; + /** + * An override for the scale the window should be rendered at. + * + * When set, this value will be used instead of the window's output scale + * when rendering. + */ + std::optional renderTargetScale() const; + void setRenderTargetScale(qreal scale); + /** * Shader to be used for rendering, if any. */ diff --git a/src/plugins/screencast/windowscreencastsource.cpp b/src/plugins/screencast/windowscreencastsource.cpp index 5c85b4e911..4ec5d82718 100644 --- a/src/plugins/screencast/windowscreencastsource.cpp +++ b/src/plugins/screencast/windowscreencastsource.cpp @@ -50,15 +50,14 @@ void WindowScreenCastSource::render(QImage *image) void WindowScreenCastSource::render(GLFramebuffer *target) { - auto targetScale = Compositor::self()->scene()->renderTargetScale(); - - const QRectF geometry = scaledRect(m_window->clientGeometry(), targetScale); + const QRectF geometry = m_window->clientGeometry(); QMatrix4x4 projectionMatrix; projectionMatrix.ortho(geometry.x(), geometry.x() + geometry.width(), geometry.y(), geometry.y() + geometry.height(), -1, 1); WindowPaintData data; data.setProjectionMatrix(projectionMatrix); + data.setRenderTargetScale(1.0); GLFramebuffer::pushFramebuffer(target); glClearColor(0.0, 0.0, 0.0, 0.0); diff --git a/src/scenes/opengl/scene_opengl.cpp b/src/scenes/opengl/scene_opengl.cpp index 53932ef741..bef0ce82dd 100644 --- a/src/scenes/opengl/scene_opengl.cpp +++ b/src/scenes/opengl/scene_opengl.cpp @@ -429,7 +429,7 @@ void SceneOpenGL::render(Item *item, int mask, const QRegion ®ion, const Wind RenderContext renderContext{ .clip = region, .hardwareClipping = region != infiniteRegion() && ((mask & Scene::PAINT_WINDOW_TRANSFORMED) || (mask & Scene::PAINT_SCREEN_TRANSFORMED)), - .renderTargetScale = renderTargetScale(), + .renderTargetScale = data.renderTargetScale().value_or(renderTargetScale()), }; renderContext.transformStack.push(QMatrix4x4());