aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2017-03-06 14:34:36 +0000
committerDavid Edmundson <[email protected]>2017-04-28 10:23:14 +0100
commit44a6050e839dc6311132010056ec5218680aea50 (patch)
tree8e6cc14fa7e4eaee94c1ad78b53fc1c5edf7b449
parent9cb666f469ce41747ae5b433ad998ad0c57c7687 (diff)
Add scaling support into BlurEffect::doBlur
Summary: This patch caputres from the framebuffer using the framebuffer's geometry, factoring in scale. We then keep the current normal DPI framebuffer causing it to downsample there. This is good because: - it keeps the code very simple - it's a performance optimisation. Blurring on 4k is naturally more expensive than at regular DPI. Downsampling keeps it the same - and you can't see a difference given it's high DPI and you're going to blur it anwyay. - it keeps kernel sizes somewhat resolution independent so it will look just as blurry across multiple screens. ::doCachedBlur still needs doing. Test Plan: Ran an app Ran the kwindowsystem blur test Observed the right part of the window being blurred Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4963
-rw-r--r--effects/blur/blur.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp
index ea68fcb..0ed1535 100644
--- a/effects/blur/blur.cpp
+++ b/effects/blur/blur.cpp
@@ -522,16 +522,20 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o
uploadGeometry(vbo, expanded, shape);
vbo->bindArrays();
+ const qreal scale = GLRenderTarget::virtualScreenScale();
+
// 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());
+ // for HIGH DPI scratch is captured in native resolution, it is then implicitly downsampled
+ // when rendering into tex
+ 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
target->attachTexture(tex);
@@ -548,8 +552,8 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o
// 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);
vbo->draw(GL_TRIANGLES, 0, expanded.rectCount() * 6);