From a0a472391e912c2a52cfe47bebb0ac920400a677 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 5 Sep 2022 09:22:07 +0200 Subject: [PATCH] effects/blur: Generate noise texture on demand It is relatively expensive and there is no need to do it unless there are actually windows that make use of the blur effect. Signed-off-by: Victoria Fischer --- src/effects/blur/blur.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/effects/blur/blur.cpp b/src/effects/blur/blur.cpp index b472d2743b..53e54950cf 100644 --- a/src/effects/blur/blur.cpp +++ b/src/effects/blur/blur.cpp @@ -195,8 +195,8 @@ void BlurEffect::updateTexture() // Copysample m_renderTargetStack.push(m_renderTargets[0]); - // Generate the noise helper texture - generateNoiseTexture(); + // Invalidate noise texture + m_noiseTexture.reset(); } void BlurEffect::initBlurStrengthValues() @@ -799,6 +799,10 @@ void BlurEffect::upscaleRenderToScreen(GLVertexBuffer *vbo, int vboStart, int bl void BlurEffect::applyNoise(GLVertexBuffer *vbo, int vboStart, int blurRectCount, const QMatrix4x4 &screenProjection, QPoint windowPosition) { + if (!m_noiseTexture) { + generateNoiseTexture(); + } + m_shader->bind(BlurShader::NoiseSampleType); m_shader->setTargetTextureSize(m_renderTextures[0]->size() * effects->renderTargetScale()); m_shader->setNoiseTextureSize(m_noiseTexture->size() * effects->renderTargetScale());