aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2017-03-06 00:39:12 +0000
committerDavid Edmundson <[email protected]>2017-04-28 10:23:13 +0100
commitf445a99a746bf0d5a14924b0ab34c92ec8a6942d (patch)
treed6da6ae6a11e3348a97a934932fac5088f1ede07
parent9ce5832e11bcecd125c2ef2cc200a586bdacb12e (diff)
Support scaling in BackgroundContrast effect
Summary: Background contrast reads pixels from the framebuffer we need to convert from compositor to framebuffer co-ordinates when an output is scaled Test Plan: Ran the manual test in kwindowsystem. Moved window over dolphin. Visually checked output Reviewers: #plasma Subscribers: plasma-devel, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D4949
-rw-r--r--effects/backgroundcontrast/contrast.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp
index 5130816..9f371c4 100644
--- a/effects/backgroundcontrast/contrast.cpp
+++ b/effects/backgroundcontrast/contrast.cpp
@@ -417,6 +417,8 @@ void ContrastEffect::doContrast(EffectWindow *w, const QRegion& shape, const QRe
const QRegion actualShape = shape & screen;
const QRect r = actualShape.boundingRect();
+ qreal scale = GLRenderTarget::virtualScreenScale();
+
// Upload geometry for the horizontal and vertical passes
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
uploadGeometry(vbo, actualShape);
@@ -424,14 +426,14 @@ void ContrastEffect::doContrast(EffectWindow *w, const QRegion& shape, const QRe
// Create a scratch texture and copy the area in the back buffer that we're
// going to blur into it
- GLTexture scratch(GL_RGBA8, r.width(), r.height());
+ GLTexture scratch(GL_RGBA8, r.width() * scale, r.height() * scale);
scratch.setFilter(GL_LINEAR);
scratch.setWrapMode(GL_CLAMP_TO_EDGE);
scratch.bind();
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());
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (r.x() - sg.x()) * scale, (sg.height() - sg.y() - r.y() - r.height()) * scale,
+ scratch.width(), scratch.height());
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally
@@ -443,8 +445,8 @@ void ContrastEffect::doContrast(EffectWindow *w, const QRegion& shape, const QRe
// Set up the texture matrix to transform from screen coordinates
// to texture coordinates.
QMatrix4x4 textureMatrix;
- textureMatrix.scale(1.0 / scratch.width(), -1.0 / scratch.height(), 1);
- textureMatrix.translate(-r.x(), -scratch.height() - r.y(), 0);
+ textureMatrix.scale(1.0 / r.width(), -1.0 / r.height(), 1);
+ textureMatrix.translate(-r.x(), -r.height() - r.y(), 0);
shader->setTextureMatrix(textureMatrix);
shader->setModelViewProjectionMatrix(screenProjection);