kwin/blur: use already existing texture instead of allocating a new one
This commit is contained in:
parent
08835ffd31
commit
c8fbb4ec61
1 changed files with 7 additions and 10 deletions
|
@ -528,12 +528,9 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa
|
||||||
|
|
||||||
if (!updateBackground.isEmpty()) {
|
if (!updateBackground.isEmpty()) {
|
||||||
const QRect updateRect = (expand(updateBackground) & expanded).boundingRect();
|
const QRect updateRect = (expand(updateBackground) & expanded).boundingRect();
|
||||||
// Create a scratch texture and copy the area in the back buffer that we're
|
// First we have to copy the background from the frontbuffer
|
||||||
// going to blur into it
|
// into a scratch texture (in this case "tex").
|
||||||
GLTexture scratch(updateRect.width(), updateRect.height());
|
tex.bind();
|
||||||
scratch.setFilter(GL_LINEAR);
|
|
||||||
scratch.setWrapMode(GL_CLAMP_TO_EDGE);
|
|
||||||
scratch.bind();
|
|
||||||
|
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, updateRect.x(), displayHeight() - updateRect.y() - updateRect.height(),
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, updateRect.x(), displayHeight() - updateRect.y() - updateRect.height(),
|
||||||
updateRect.width(), updateRect.height());
|
updateRect.width(), updateRect.height());
|
||||||
|
@ -543,7 +540,7 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa
|
||||||
GLRenderTarget::pushRenderTarget(target);
|
GLRenderTarget::pushRenderTarget(target);
|
||||||
|
|
||||||
shader->setDirection(Qt::Horizontal);
|
shader->setDirection(Qt::Horizontal);
|
||||||
shader->setPixelDistance(1.0 / updateRect.width());
|
shader->setPixelDistance(1.0 / tex.width());
|
||||||
|
|
||||||
modelViewProjectionMatrix.ortho(0, r.width(), r.height(), 0 , 0, 65535);
|
modelViewProjectionMatrix.ortho(0, r.width(), r.height(), 0 , 0, 65535);
|
||||||
modelViewProjectionMatrix.translate(-r.x(), -r.y(), 0);
|
modelViewProjectionMatrix.translate(-r.x(), -r.y(), 0);
|
||||||
|
@ -552,8 +549,8 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa
|
||||||
|
|
||||||
// Set up the texture matrix to transform from screen coordinates
|
// Set up the texture matrix to transform from screen coordinates
|
||||||
// to texture coordinates.
|
// to texture coordinates.
|
||||||
textureMatrix.scale(1.0 / scratch.width(), -1.0 / scratch.height(), 1);
|
textureMatrix.scale(1.0 / tex.width(), -1.0 / tex.height(), 1);
|
||||||
textureMatrix.translate(-updateRect.x(), -scratch.height() - updateRect.y(), 0);
|
textureMatrix.translate(-updateRect.x(), -updateRect.height() - updateRect.y(), 0);
|
||||||
#ifndef KWIN_HAVE_OPENGLES
|
#ifndef KWIN_HAVE_OPENGLES
|
||||||
glMatrixMode(GL_TEXTURE);
|
glMatrixMode(GL_TEXTURE);
|
||||||
loadMatrix(textureMatrix);
|
loadMatrix(textureMatrix);
|
||||||
|
@ -564,7 +561,7 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa
|
||||||
drawRegion(updateBackground & screen);
|
drawRegion(updateBackground & screen);
|
||||||
|
|
||||||
GLRenderTarget::popRenderTarget();
|
GLRenderTarget::popRenderTarget();
|
||||||
scratch.unbind();
|
tex.unbind();
|
||||||
// mark the updated region as valid
|
// mark the updated region as valid
|
||||||
windows[w].damagedRegion -= updateBackground;
|
windows[w].damagedRegion -= updateBackground;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue