Fix the darkening of the bottom-most pixels behind the plasma panel.

The texture needs to be drawn on screen coordinates on the offscreen
framebuffer in the horizontal pass, otherwise pixels that fall below
the screen won't be clamped to the screen edge in the subsequent
vertical pass. This is because the offscreen buffer is the same size
as the screen.

This change also gets rid of the need to clear the offscreen buffer
before blurring the screen contents behind each window, and reduces
the CPU computations done on the blur region.

svn path=/trunk/KDE/kdebase/workspace/; revision=1137134
This commit is contained in:
Fredrik Höglund 2010-06-11 18:38:54 +00:00
parent fd0a31c3bf
commit 66125caac3

View file

@ -227,8 +227,6 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
{
const QRegion expanded = expand(shape) & screen;
const QRect r = expanded.boundingRect();
const QPoint offset = -shape.boundingRect().topLeft() +
(shape.boundingRect().topLeft() - r.topLeft());
// Create a scratch texture and copy the area in the back buffer that we're
// going to blur into it
@ -242,20 +240,20 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally
effects->pushRenderTarget(target);
glClear(GL_COLOR_BUFFER_BIT);
shader->bind();
shader->setDirection(Qt::Horizontal);
shader->setPixelDistance(1.0 / r.width());
// Set up the texture matrix to normalize the coordinates
// Set up the texture matrix to transform from screen coordinates
// to texture coordinates.
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glScalef(1.0 / scratch.width(), -1.0 / scratch.height(), 1);
glTranslatef(0, -scratch.height(), 0);
glTranslatef(-r.x(), -scratch.height() - r.y(), 0);
drawRegion(expanded.translated(-r.topLeft()));
drawRegion(expanded);
effects->popRenderTarget();
scratch.unbind();
@ -281,7 +279,7 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
// to texture coordinates.
glLoadIdentity();
glScalef(1.0 / tex->width(), -1.0 / tex->height(), 1);
glTranslatef(offset.x(), -tex->height() + offset.y(), 0);
glTranslatef(0, -tex->height(), 0);
drawRegion(shape);