diff --git a/src/blur.cpp b/src/blur.cpp index 8771028e9..fd99265ad 100644 --- a/src/blur.cpp +++ b/src/blur.cpp @@ -839,13 +839,13 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg if (!staticBlurTexture && (renderInfo.framebuffers.size() != (m_iterationCount + 1) - || renderInfo.textures[0]->size() != backgroundRect.size() + || renderInfo.textures[0]->size() != deviceBackgroundRect.size() || renderInfo.textures[0]->internalFormat() != textureFormat)) { renderInfo.framebuffers.clear(); renderInfo.textures.clear(); for (size_t i = 0; i <= m_iterationCount; ++i) { - auto texture = GLTexture::allocate(textureFormat, backgroundRect.size() / (1 << i)); + auto texture = GLTexture::allocate(textureFormat, deviceBackgroundRect.size() / (1 << i)); if (!texture) { qCWarning(KWIN_BLUR) << "Failed to allocate an offscreen texture"; return; @@ -866,8 +866,9 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg // Fetch the pixels behind the shape that is going to be blurred. if (!staticBlurTexture) { const QRegion dirtyRegion = region & backgroundRect; - for (const QRect &dirtyRect: dirtyRegion) { - renderInfo.framebuffers[0]->blitFromRenderTarget(renderTarget, viewport, dirtyRect, dirtyRect.translated(-backgroundRect.topLeft())); + for (const QRect &dirtyRect : dirtyRegion) { + const auto destination = snapToPixelGrid(scaledRect(dirtyRect, viewport.scale())).translated(-deviceBackgroundRect.topLeft()); + renderInfo.framebuffers[0]->blitFromRenderTarget(renderTarget, viewport, dirtyRect, destination); } } @@ -885,17 +886,17 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg // The geometry that will be blurred offscreen, in logical pixels. { - const QRectF localRect = QRectF(0, 0, backgroundRect.width(), backgroundRect.height()); + const QRectF localRect = QRectF(0, 0, deviceBackgroundRect.width(), deviceBackgroundRect.height()); const float x0 = localRect.left(); const float y0 = localRect.top(); const float x1 = localRect.right(); const float y1 = localRect.bottom(); - const float u0 = x0 / backgroundRect.width(); - const float v0 = 1.0f - y0 / backgroundRect.height(); - const float u1 = x1 / backgroundRect.width(); - const float v1 = 1.0f - y1 / backgroundRect.height(); + const float u0 = x0 / deviceBackgroundRect.width(); + const float v0 = 1.0f - y0 / deviceBackgroundRect.height(); + const float u1 = x1 / deviceBackgroundRect.width(); + const float v1 = 1.0f - y1 / deviceBackgroundRect.height(); // first triangle map[vboIndex++] = GLVertex2D{ @@ -1012,7 +1013,7 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg ShaderManager::instance()->pushShader(m_downsamplePass.shader.get()); QMatrix4x4 projectionMatrix; - projectionMatrix.ortho(QRectF(0.0, 0.0, backgroundRect.width(), backgroundRect.height())); + projectionMatrix.ortho(QRectF(0.0, 0.0, deviceBackgroundRect.width(), deviceBackgroundRect.height())); m_downsamplePass.shader->setUniform(m_downsamplePass.mvpMatrixLocation, projectionMatrix); m_downsamplePass.shader->setUniform(m_downsamplePass.offsetLocation, float(m_offset)); @@ -1044,7 +1045,7 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg ShaderManager::instance()->pushShader(m_upsamplePass.shader.get()); QMatrix4x4 projectionMatrix; - projectionMatrix.ortho(QRectF(0.0, 0.0, backgroundRect.width(), backgroundRect.height())); + projectionMatrix.ortho(QRectF(0.0, 0.0, deviceBackgroundRect.width(), deviceBackgroundRect.height())); m_upsamplePass.shader->setUniform(m_upsamplePass.topCornerRadiusLocation, static_cast(0)); m_upsamplePass.shader->setUniform(m_upsamplePass.bottomCornerRadiusLocation, static_cast(0)); @@ -1087,7 +1088,7 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg m_upsamplePass.shader->setUniform(m_upsamplePass.topCornerRadiusLocation, topCornerRadius); m_upsamplePass.shader->setUniform(m_upsamplePass.bottomCornerRadiusLocation, bottomCornerRadius); m_upsamplePass.shader->setUniform(m_upsamplePass.antialiasingLocation, m_settings.roundedCorners.antialiasing); - m_upsamplePass.shader->setUniform(m_upsamplePass.blurSizeLocation, QVector2D(backgroundRect.width(), backgroundRect.height())); + m_upsamplePass.shader->setUniform(m_upsamplePass.blurSizeLocation, QVector2D(deviceBackgroundRect.width(), deviceBackgroundRect.height())); m_upsamplePass.shader->setUniform(m_upsamplePass.opacityLocation, static_cast(opacity)); projectionMatrix = viewport.projectionMatrix();