diff --git a/src/backends/drm/drm_output.cpp b/src/backends/drm/drm_output.cpp index b95146fe9e..114c05290c 100644 --- a/src/backends/drm/drm_output.cpp +++ b/src/backends/drm/drm_output.cpp @@ -517,7 +517,7 @@ void DrmOutput::renderCursorOpengl(const RenderTarget &renderTarget, const QSize m_cursorTexture->bind(); ShaderBinder binder(ShaderTrait::MapTexture); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_cursorTexture->render(QRect(0, 0, cursorSize.width(), cursorSize.height())); + m_cursorTexture->render(QRect(0, 0, cursorSize.width(), cursorSize.height()), renderTarget.devicePixelRatio()); m_cursorTexture->unbind(); glDisable(GL_BLEND); } diff --git a/src/cursordelegate_opengl.cpp b/src/cursordelegate_opengl.cpp index 4c4742a252..43c2f837de 100644 --- a/src/cursordelegate_opengl.cpp +++ b/src/cursordelegate_opengl.cpp @@ -72,7 +72,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())); + m_cursorTexture->render(region, QRect(0, 0, cursorRect.width(), cursorRect.height()), renderTarget->devicePixelRatio()); m_cursorTexture->unbind(); glDisable(GL_BLEND); } diff --git a/src/effects/magnifier/magnifier.cpp b/src/effects/magnifier/magnifier.cpp index a6b346222c..6b89797483 100644 --- a/src/effects/magnifier/magnifier.cpp +++ b/src/effects/magnifier/magnifier.cpp @@ -119,6 +119,7 @@ void MagnifierEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintDa // get the right area from the current rendered screen const QRect area = magnifierArea(); const QPoint cursor = cursorPos(); + const auto scale = effects->renderTargetScale(); QRect srcArea(cursor.x() - (double)area.width() / (m_zoom * 2), cursor.y() - (double)area.height() / (m_zoom * 2), @@ -133,7 +134,7 @@ void MagnifierEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintDa mvp.ortho(0, size.width(), size.height(), 0, 0, 65535); mvp.translate(area.x(), area.y()); s->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_texture->render(area); + m_texture->render(area, scale); ShaderManager::instance()->popShader(); m_texture->unbind(); QVector verts; diff --git a/src/effects/screenedge/screenedgeeffect.cpp b/src/effects/screenedge/screenedgeeffect.cpp index fcddd67bd6..b0d16fca31 100644 --- a/src/effects/screenedge/screenedgeeffect.cpp +++ b/src/effects/screenedge/screenedgeeffect.cpp @@ -83,10 +83,11 @@ void ScreenEdgeEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD ShaderBinder binder(ShaderTrait::MapTexture | ShaderTrait::Modulate); const QVector4D constant(opacity, opacity, opacity, opacity); binder.shader()->setUniform(GLShader::ModulationConstant, constant); + const auto scale = effects->renderTargetScale(); QMatrix4x4 mvp = data.projectionMatrix(); mvp.translate(glow->geometry.x(), glow->geometry.y()); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - texture->render(glow->geometry); + texture->render(glow->geometry, scale); texture->unbind(); glDisable(GL_BLEND); } else if (effects->compositingType() == QPainterCompositing) { diff --git a/src/effects/startupfeedback/startupfeedback.cpp b/src/effects/startupfeedback/startupfeedback.cpp index 30e48507a5..33b1d2e536 100644 --- a/src/effects/startupfeedback/startupfeedback.cpp +++ b/src/effects/startupfeedback/startupfeedback.cpp @@ -222,10 +222,11 @@ void StartupFeedbackEffect::paintScreen(int mask, const QRegion ®ion, ScreenP } else { ShaderManager::instance()->pushShader(ShaderTrait::MapTexture); } + const auto scale = effects->renderTargetScale(); QMatrix4x4 mvp = data.projectionMatrix(); - mvp.translate(m_currentGeometry.x(), m_currentGeometry.y()); + mvp.translate(m_currentGeometry.x() * scale, m_currentGeometry.y() * scale); ShaderManager::instance()->getBoundShader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - texture->render(m_currentGeometry); + texture->render(m_currentGeometry, scale); ShaderManager::instance()->popShader(); texture->unbind(); glDisable(GL_BLEND); diff --git a/src/effects/trackmouse/trackmouse.cpp b/src/effects/trackmouse/trackmouse.cpp index 7464609ef9..7bf83e9025 100644 --- a/src/effects/trackmouse/trackmouse.cpp +++ b/src/effects/trackmouse/trackmouse.cpp @@ -114,6 +114,7 @@ void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD const QPointF p = m_lastRect[0].topLeft() + QPoint(m_lastRect[0].width() / 2.0, m_lastRect[0].height() / 2.0); const float x = p.x(); const float y = p.y(); + const auto scale = effects->renderTargetScale(); for (int i = 0; i < 2; ++i) { matrix.translate(x, y, 0.0); matrix.rotate(i ? -2 * m_angle : m_angle, 0, 0, 1.0); @@ -122,7 +123,7 @@ void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD mvp.translate(m_lastRect[i].x(), m_lastRect[i].y()); shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); m_texture[i]->bind(); - m_texture[i]->render(m_lastRect[i]); + m_texture[i]->render(m_lastRect[i], scale); m_texture[i]->unbind(); } glDisable(GL_BLEND); diff --git a/src/effects/zoom/zoom.cpp b/src/effects/zoom/zoom.cpp index bc99def18c..6b2fed663d 100644 --- a/src/effects/zoom/zoom.cpp +++ b/src/effects/zoom/zoom.cpp @@ -414,7 +414,7 @@ void ZoomEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &d QMatrix4x4 mvp = data.projectionMatrix(); mvp.translate(rect.x(), rect.y()); s->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - cursorTexture->render(rect); + cursorTexture->render(rect, effects->renderTargetScale()); ShaderManager::instance()->popShader(); cursorTexture->unbind(); glDisable(GL_BLEND); diff --git a/src/libkwineffects/kwingltexture.cpp b/src/libkwineffects/kwingltexture.cpp index 2f669351a2..aa678ca89d 100644 --- a/src/libkwineffects/kwingltexture.cpp +++ b/src/libkwineffects/kwingltexture.cpp @@ -506,20 +506,22 @@ void GLTexture::unbind() glBindTexture(d->m_target, 0); } -void GLTexture::render(const QRect &rect) +void GLTexture::render(const QRect &rect, qreal scale) { - render(infiniteRegion(), rect, false); + render(infiniteRegion(), rect, scale, false); } -void GLTexture::render(const QRegion ®ion, const QRect &rect, bool hardwareClipping) +void GLTexture::render(const QRegion ®ion, const QRect &rect, qreal scale, bool hardwareClipping) { Q_D(GLTexture); if (rect.isEmpty()) { return; // nothing to paint and m_vbo is likely nullptr and d->m_cachedSize empty as well, #337090 } - if (rect.size() != d->m_cachedSize) { - d->m_cachedSize = rect.size(); - QRect r(rect); + + QRect destinationRect = scaledRect(rect, scale).toRect(); + if (destinationRect.size() != d->m_cachedSize) { + d->m_cachedSize = destinationRect.size(); + QRect r(destinationRect); r.moveTo(0, 0); if (!d->m_vbo) { d->m_vbo = std::make_unique(KWin::GLVertexBuffer::Static); @@ -528,9 +530,9 @@ void GLTexture::render(const QRegion ®ion, const QRect &rect, bool hardwareCl const float verts[4 * 2] = { // NOTICE: r.x/y could be replaced by "0", but that would make it unreadable... static_cast(r.x()), static_cast(r.y()), - static_cast(r.x()), static_cast(r.y() + rect.height()), - static_cast(r.x() + rect.width()), static_cast(r.y()), - static_cast(r.x() + rect.width()), static_cast(r.y() + rect.height())}; + static_cast(r.x()), static_cast(r.y() + destinationRect.height()), + static_cast(r.x() + destinationRect.width()), static_cast(r.y()), + static_cast(r.x() + destinationRect.width()), static_cast(r.y() + destinationRect.height())}; const float texWidth = (target() == GL_TEXTURE_RECTANGLE_ARB) ? width() : 1.0f; const float texHeight = (target() == GL_TEXTURE_RECTANGLE_ARB) ? height() : 1.0f; diff --git a/src/libkwineffects/kwingltexture.h b/src/libkwineffects/kwingltexture.h index 8d5ad026ad..8945070eed 100644 --- a/src/libkwineffects/kwingltexture.h +++ b/src/libkwineffects/kwingltexture.h @@ -102,8 +102,8 @@ public: virtual void discard(); void bind(); void unbind(); - void render(const QRect &rect); - void render(const QRegion ®ion, const QRect &rect, bool hardwareClipping = false); + void render(const QRect &rect, qreal scale); + void render(const QRegion ®ion, const QRect &rect, qreal scale, bool hardwareClipping = false); GLuint texture() const; GLenum target() const; diff --git a/src/plugins/screencast/outputscreencastsource.cpp b/src/plugins/screencast/outputscreencastsource.cpp index e2f41e3271..c0a56b7524 100644 --- a/src/plugins/screencast/outputscreencastsource.cpp +++ b/src/plugins/screencast/outputscreencastsource.cpp @@ -58,7 +58,7 @@ void OutputScreenCastSource::render(GLFramebuffer *target) GLFramebuffer::pushFramebuffer(target); outputTexture->bind(); - outputTexture->render(geometry); + outputTexture->render(geometry, m_output->scale()); outputTexture->unbind(); GLFramebuffer::popFramebuffer(); } diff --git a/src/plugins/screencast/regionscreencastsource.cpp b/src/plugins/screencast/regionscreencastsource.cpp index 71b67bb0aa..fc5fe34461 100644 --- a/src/plugins/screencast/regionscreencastsource.cpp +++ b/src/plugins/screencast/regionscreencastsource.cpp @@ -45,6 +45,7 @@ void RegionScreenCastSource::updateOutput(Output *output) if (m_renderedTexture) { const std::shared_ptr outputTexture = Compositor::self()->scene()->textureForOutput(output); const auto outputGeometry = output->geometry(); + const auto outputScale = output->scale(); if (!outputTexture || !m_region.intersects(output->geometry())) { return; } @@ -62,7 +63,7 @@ void RegionScreenCastSource::updateOutput(Output *output) shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix); outputTexture->bind(); - outputTexture->render(output->geometry()); + outputTexture->render(output->geometry(), outputScale); outputTexture->unbind(); GLFramebuffer::popFramebuffer(); } @@ -95,7 +96,7 @@ void RegionScreenCastSource::render(GLFramebuffer *target) shader->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix); m_renderedTexture->bind(); - m_renderedTexture->render(r); + m_renderedTexture->render(r, m_scale); m_renderedTexture->unbind(); ShaderManager::instance()->popShader(); diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index 04c55c25a4..a19244af85 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -484,7 +484,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - m_cursor.texture->render(cursorRect); + m_cursor.texture->render(cursorRect, m_cursor.scale); glDisable(GL_BLEND); m_cursor.texture->unbind(); diff --git a/src/scenes/opengl/scene_opengl.cpp b/src/scenes/opengl/scene_opengl.cpp index 31429c4c3e..73e4d0019e 100644 --- a/src/scenes/opengl/scene_opengl.cpp +++ b/src/scenes/opengl/scene_opengl.cpp @@ -141,7 +141,7 @@ void SceneOpenGL::paintOffscreenQuickView(OffscreenQuickView *w) glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); t->bind(); - t->render(rect.toRect()); + t->render(w->geometry(), renderTargetScale()); t->unbind(); glDisable(GL_BLEND);