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 <victoria.fischer@mbition.io>
This commit is contained in:
Kai Uwe Broulik 2022-09-05 09:22:07 +02:00 committed by Victoria Fischer
parent 8b4ffd5cc9
commit a0a472391e

View file

@ -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());