aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2016-10-18 16:33:20 +0200
committerMartin Gräßlin <[email protected]>2016-10-18 16:38:50 +0200
commitbef9c9c8c5893a6785eb86f72243c7ff67577033 (patch)
treee6eb107a8a5b6d26b45602a28e520051dd6990e9
parentf4627e38f18273ad61a30bc83abf95b5bab5b492 (diff)
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
-rw-r--r--effects/backgroundcontrast/contrast.cpp10
-rw-r--r--effects/backgroundcontrast/contrast.h2
-rw-r--r--effects/blur/blur.cpp5
3 files changed, 10 insertions, 7 deletions
diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp
index 657ea63..65528f9 100644
--- a/effects/backgroundcontrast/contrast.cpp
+++ b/effects/backgroundcontrast/contrast.cpp
@@ -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);
diff --git a/effects/backgroundcontrast/contrast.h b/effects/backgroundcontrast/contrast.h
index 688fe22..20bf8bf 100644
--- a/effects/backgroundcontrast/contrast.h
+++ b/effects/backgroundcontrast/contrast.h
@@ -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);
diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp
index 95debe4..ea68fcb 100644
--- a/effects/blur/blur.cpp
+++ b/effects/blur/blur.cpp
@@ -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