Adjust blur and contrast for multi-output rendering on Wayland

Summary:
The glCopyTex(Sub)Image calls are adjusted to take the per output
rendering into account. In addition contrast effect sets the model view
projection matrix in each call to ensure it's on the correct screen.

Blur probably needs more changes for the cached texture to work, but
it's a start.

Test Plan: Blur and Background contrast work on multi-screen wayland

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3101
This commit is contained in:
Martin Gräßlin 2016-10-18 16:33:20 +02:00
parent f4627e38f1
commit bef9c9c8c5
3 changed files with 10 additions and 7 deletions

View file

@ -370,7 +370,7 @@ bool ContrastEffect::shouldContrast(const EffectWindow *w, int mask, const Windo
void ContrastEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{
const QRect screen = effects->virtualScreenGeometry();
const QRect screen = GLRenderTarget::virtualScreenGeometry();
if (shouldContrast(w, mask, data)) {
QRegion shape = region & contrastRegion(w).translated(w->pos()) & screen;
@ -397,7 +397,7 @@ void ContrastEffect::drawWindow(EffectWindow *w, int mask, QRegion region, Windo
}
if (!shape.isEmpty()) {
doContrast(shape, screen, data.opacity());
doContrast(shape, screen, data.opacity(), data.screenProjectionMatrix());
}
}
@ -411,7 +411,7 @@ void ContrastEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double
effects->paintEffectFrame(frame, region, opacity, frameOpacity);
}
void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const float opacity)
void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection)
{
const QRegion actualShape = shape & screen;
const QRect r = actualShape.boundingRect();
@ -428,7 +428,8 @@ void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const
scratch.setWrapMode(GL_CLAMP_TO_EDGE);
scratch.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r.x(), effects->virtualScreenSize().height() - r.y() - r.height(),
const QRect sg = GLRenderTarget::virtualScreenGeometry();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r.x() - sg.x(), sg.height() - sg.y() - r.y() - r.height(),
r.width(), r.height());
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally
@ -443,6 +444,7 @@ void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const
textureMatrix.scale(1.0 / scratch.width(), -1.0 / scratch.height(), 1);
textureMatrix.translate(-r.x(), -scratch.height() - r.y(), 0);
shader->setTextureMatrix(textureMatrix);
shader->setModelViewProjectionMatrix(screenProjection);
vbo->draw(GL_TRIANGLES, 0, actualShape.rectCount() * 6);

View file

@ -74,7 +74,7 @@ private:
QRegion contrastRegion(const EffectWindow *w) const;
bool shouldContrast(const EffectWindow *w, int mask, const WindowPaintData &data) const;
void updateContrastRegion(EffectWindow *w) const;
void doContrast(const QRegion &shape, const QRect &screen, const float opacity);
void doContrast(const QRegion &shape, const QRect &screen, const float opacity, const QMatrix4x4 &screenProjection);
void uploadRegion(QVector2D *&map, const QRegion &region);
void uploadGeometry(GLVertexBuffer *vbo, const QRegion &region);

View file

@ -434,7 +434,7 @@ bool BlurEffect::shouldBlur(const EffectWindow *w, int mask, const WindowPaintDa
void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{
const QRect screen = effects->virtualScreenGeometry();
const QRect screen = GLRenderTarget::virtualScreenGeometry();
if (shouldBlur(w, mask, data)) {
QRegion shape = region & blurRegion(w).translated(w->pos()) & screen;
@ -529,7 +529,8 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o
scratch.setWrapMode(GL_CLAMP_TO_EDGE);
scratch.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r.x(), effects->virtualScreenSize().height() - r.y() - r.height(),
const QRect sg = GLRenderTarget::virtualScreenGeometry();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r.x() - sg.x(), sg.height() - sg.y() - r.y() - r.height(),
r.width(), r.height());
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally