2010-03-05 20:42:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Fredrik Höglund <fredrik@kde.org>
|
2011-12-10 10:28:38 +00:00
|
|
|
* Copyright © 2011 Philipp Knechtges <philipp-dev@knechtges.com>
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
* Copyright © 2018 Alex Nemeth <alex.nemeth329@gmail.com>
|
2010-03-05 20:42:10 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. if not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "blur.h"
|
2015-08-31 13:47:01 +00:00
|
|
|
#include "effects.h"
|
2010-03-05 20:42:10 +00:00
|
|
|
#include "blurshader.h"
|
2012-09-14 12:28:30 +00:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "blurconfig.h"
|
2010-03-05 20:42:10 +00:00
|
|
|
|
2011-01-08 18:56:22 +00:00
|
|
|
#include <QMatrix4x4>
|
2011-05-01 21:17:28 +00:00
|
|
|
#include <QLinkedList>
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
#include <QScreen> // for QGuiApplication
|
|
|
|
#include <QTime>
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
#include <cmath> // for ceil()
|
2010-03-05 20:42:10 +00:00
|
|
|
|
2015-08-31 13:47:01 +00:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
#include <KWayland/Server/blur_interface.h>
|
|
|
|
#include <KWayland/Server/shadow_interface.h>
|
|
|
|
#include <KWayland/Server/display.h>
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
#include <KSharedConfig>
|
|
|
|
#include <KConfigGroup>
|
2015-08-31 13:47:01 +00:00
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2011-05-01 20:52:43 +00:00
|
|
|
|
2014-03-16 09:16:52 +00:00
|
|
|
static const QByteArray s_blurAtomName = QByteArrayLiteral("_KDE_NET_WM_BLUR_BEHIND_REGION");
|
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
BlurEffect::BlurEffect()
|
|
|
|
{
|
2016-12-02 19:27:43 +00:00
|
|
|
initConfig<BlurConfig>();
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader = BlurShader::create();
|
2010-03-05 20:42:10 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
initBlurStrengthValues();
|
2010-09-25 00:11:06 +00:00
|
|
|
reconfigure(ReconfigureAll);
|
|
|
|
|
2010-03-06 16:14:25 +00:00
|
|
|
// ### Hackish way to announce support.
|
|
|
|
// Should be included in _NET_SUPPORTED instead.
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
if (m_shader && m_shader->isValid() && m_renderTargetsValid) {
|
2014-03-16 09:16:52 +00:00
|
|
|
net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this);
|
2015-09-29 08:21:24 +00:00
|
|
|
KWayland::Server::Display *display = effects->waylandDisplay();
|
|
|
|
if (display) {
|
|
|
|
m_blurManager = display->createBlurManager(this);
|
|
|
|
m_blurManager->create();
|
|
|
|
}
|
2010-09-25 00:11:06 +00:00
|
|
|
} else {
|
2012-12-13 23:09:47 +00:00
|
|
|
net_wm_blur_region = 0;
|
2010-09-25 00:11:06 +00:00
|
|
|
}
|
2013-03-16 10:34:14 +00:00
|
|
|
|
2012-01-29 11:29:24 +00:00
|
|
|
connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*)));
|
|
|
|
connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*)));
|
|
|
|
connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long)));
|
2011-11-26 15:15:46 +00:00
|
|
|
connect(effects, SIGNAL(screenGeometryChanged(QSize)), this, SLOT(slotScreenGeometryChanged()));
|
2017-09-10 14:51:18 +00:00
|
|
|
connect(effects, &EffectsHandler::xcbConnectionChanged, this,
|
|
|
|
[this] {
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
if (m_shader && m_shader->isValid() && m_renderTargetsValid) {
|
2017-09-10 14:51:18 +00:00
|
|
|
net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2013-03-16 10:34:14 +00:00
|
|
|
|
|
|
|
// Fetch the blur regions for all windows
|
|
|
|
foreach (EffectWindow *window, effects->stackingOrder())
|
|
|
|
updateBlurRegion(window);
|
2010-03-05 20:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BlurEffect::~BlurEffect()
|
|
|
|
{
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
deleteFBOs();
|
|
|
|
|
|
|
|
delete m_shader;
|
|
|
|
m_shader = nullptr;
|
2010-03-05 20:42:10 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 15:15:46 +00:00
|
|
|
void BlurEffect::slotScreenGeometryChanged()
|
|
|
|
{
|
2017-09-29 12:30:54 +00:00
|
|
|
effects->makeOpenGLContextCurrent();
|
|
|
|
updateTexture();
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
|
2017-09-29 12:30:54 +00:00
|
|
|
// Fetch the blur regions for all windows
|
|
|
|
foreach (EffectWindow *window, effects->stackingOrder())
|
|
|
|
updateBlurRegion(window);
|
|
|
|
effects->doneOpenGLContextCurrent();
|
|
|
|
}
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
bool BlurEffect::renderTargetsValid() const
|
|
|
|
{
|
|
|
|
return !m_renderTargets.isEmpty() && std::find_if(m_renderTargets.cbegin(), m_renderTargets.cend(),
|
|
|
|
[](const GLRenderTarget *target) {
|
|
|
|
return !target->valid();
|
|
|
|
}) == m_renderTargets.cend();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlurEffect::deleteFBOs()
|
|
|
|
{
|
|
|
|
qDeleteAll(m_renderTargets);
|
|
|
|
|
|
|
|
m_renderTargets.clear();
|
|
|
|
m_renderTextures.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlurEffect::updateTexture()
|
|
|
|
{
|
|
|
|
deleteFBOs();
|
|
|
|
|
|
|
|
/* Reserve memory for:
|
|
|
|
* - The original sized texture (1)
|
|
|
|
* - The downsized textures (m_downSampleIterations)
|
|
|
|
* - The helper texture (1)
|
|
|
|
*/
|
|
|
|
m_renderTargets.reserve(m_downSampleIterations + 2);
|
|
|
|
m_renderTextures.reserve(m_downSampleIterations + 2);
|
|
|
|
|
|
|
|
for (int i = 0; i <= m_downSampleIterations; i++) {
|
|
|
|
m_renderTextures.append(GLTexture(GL_RGBA8, effects->virtualScreenSize() / (1 << i)));
|
|
|
|
m_renderTextures.last().setFilter(GL_LINEAR);
|
|
|
|
m_renderTextures.last().setWrapMode(GL_CLAMP_TO_EDGE);
|
|
|
|
|
|
|
|
m_renderTargets.append(new GLRenderTarget(m_renderTextures.last()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// This last set is used as a temporary helper texture
|
|
|
|
m_renderTextures.append(GLTexture(GL_RGBA8, effects->virtualScreenSize()));
|
|
|
|
m_renderTextures.last().setFilter(GL_LINEAR);
|
|
|
|
m_renderTextures.last().setWrapMode(GL_CLAMP_TO_EDGE);
|
|
|
|
|
|
|
|
m_renderTargets.append(new GLRenderTarget(m_renderTextures.last()));
|
|
|
|
|
|
|
|
m_renderTargetsValid = renderTargetsValid();
|
|
|
|
|
|
|
|
// Prepare the stack for the rendering
|
|
|
|
m_renderTargetStack.clear();
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
m_renderTargetStack.reserve(m_downSampleIterations * 2);
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
|
|
|
|
// Upsample
|
|
|
|
for (int i = 1; i < m_downSampleIterations; i++) {
|
|
|
|
m_renderTargetStack.push(m_renderTargets[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Downsample
|
|
|
|
for (int i = m_downSampleIterations; i > 0; i--) {
|
|
|
|
m_renderTargetStack.push(m_renderTargets[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copysample
|
|
|
|
m_renderTargetStack.push(m_renderTargets[0]);
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
|
|
|
|
// Generate the noise helper texture
|
|
|
|
generateNoiseTexture();
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BlurEffect::initBlurStrengthValues()
|
|
|
|
{
|
|
|
|
// This function creates an array of blur strength values that are evenly distributed
|
|
|
|
|
|
|
|
// The range of the slider on the blur settings UI
|
|
|
|
int numOfBlurSteps = 15;
|
|
|
|
int remainingSteps = numOfBlurSteps;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Explanation for these numbers:
|
|
|
|
*
|
|
|
|
* The texture blur amount depends on the downsampling iterations and the offset value.
|
|
|
|
* By changing the offset we can alter the blur amount without relying on further downsampling.
|
|
|
|
* But there is a minimum and maximum value of offset per downsample iteration before we
|
|
|
|
* get artifacts.
|
|
|
|
*
|
|
|
|
* The minOffset variable is the minimum offset value for an iteration before we
|
|
|
|
* get blocky artifacts because of the downsampling.
|
|
|
|
*
|
|
|
|
* The maxOffset value is the maximum offset value for an iteration before we
|
|
|
|
* get diagonal line artifacts because of the nature of the dual kawase blur algorithm.
|
|
|
|
*
|
|
|
|
* The expandSize value is the minimum value for an iteration before we reach the end
|
|
|
|
* of a texture in the shader and sample outside of the area that was copied into the
|
|
|
|
* texture from the screen.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// {minOffset, maxOffset, expandSize}
|
|
|
|
blurOffsets.append({1.0, 2.0, 10}); // Down sample size / 2
|
|
|
|
blurOffsets.append({2.0, 3.0, 20}); // Down sample size / 4
|
|
|
|
blurOffsets.append({2.0, 5.0, 50}); // Down sample size / 8
|
|
|
|
blurOffsets.append({3.0, 8.0, 150}); // Down sample size / 16
|
|
|
|
//blurOffsets.append({5.0, 10.0, 400}); // Down sample size / 32
|
|
|
|
//blurOffsets.append({7.0, ?.0}); // Down sample size / 64
|
|
|
|
|
|
|
|
float offsetSum = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < blurOffsets.size(); i++) {
|
|
|
|
offsetSum += blurOffsets[i].maxOffset - blurOffsets[i].minOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < blurOffsets.size(); i++) {
|
|
|
|
int iterationNumber = std::ceil((blurOffsets[i].maxOffset - blurOffsets[i].minOffset) / offsetSum * numOfBlurSteps);
|
|
|
|
remainingSteps -= iterationNumber;
|
|
|
|
|
|
|
|
if (remainingSteps < 0) {
|
|
|
|
iterationNumber += remainingSteps;
|
|
|
|
}
|
|
|
|
|
|
|
|
float offsetDifference = blurOffsets[i].maxOffset - blurOffsets[i].minOffset;
|
2017-09-29 12:30:54 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
for (int j = 1; j <= iterationNumber; j++) {
|
|
|
|
// {iteration, offset}
|
|
|
|
blurStrengthValues.append({i + 1, blurOffsets[i].minOffset + (offsetDifference / iterationNumber) * j});
|
|
|
|
}
|
|
|
|
}
|
2011-11-26 15:15:46 +00:00
|
|
|
}
|
|
|
|
|
2010-03-13 15:03:29 +00:00
|
|
|
void BlurEffect::reconfigure(ReconfigureFlags flags)
|
|
|
|
{
|
|
|
|
Q_UNUSED(flags)
|
|
|
|
|
2014-03-25 15:29:03 +00:00
|
|
|
BlurConfig::self()->read();
|
2010-09-25 00:11:06 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
int blurStrength = BlurConfig::blurStrength() - 1;
|
|
|
|
m_downSampleIterations = blurStrengthValues[blurStrength].iteration;
|
|
|
|
m_offset = blurStrengthValues[blurStrength].offset;
|
|
|
|
m_expandSize = blurOffsets[m_downSampleIterations - 1].expandSize;
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
m_noiseStrength = BlurConfig::noiseStrength();
|
|
|
|
|
2018-04-25 15:07:50 +00:00
|
|
|
m_scalingFactor = qMax(1.0, QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96.0);
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
updateTexture();
|
|
|
|
|
|
|
|
if (!m_shader || !m_shader->isValid()) {
|
2014-03-16 09:16:52 +00:00
|
|
|
effects->removeSupportProperty(s_blurAtomName, this);
|
2015-09-29 08:21:24 +00:00
|
|
|
delete m_blurManager;
|
|
|
|
m_blurManager = nullptr;
|
|
|
|
}
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
|
|
|
|
// Update all windows for the blur to take effect
|
|
|
|
effects->addRepaintFull();
|
2010-03-13 15:03:29 +00:00
|
|
|
}
|
|
|
|
|
2010-03-06 16:14:25 +00:00
|
|
|
void BlurEffect::updateBlurRegion(EffectWindow *w) const
|
|
|
|
{
|
|
|
|
QRegion region;
|
2017-09-10 14:51:18 +00:00
|
|
|
QByteArray value;
|
|
|
|
|
|
|
|
if (net_wm_blur_region != XCB_ATOM_NONE) {
|
|
|
|
value = w->readProperty(net_wm_blur_region, XCB_ATOM_CARDINAL, 32);
|
|
|
|
if (value.size() > 0 && !(value.size() % (4 * sizeof(uint32_t)))) {
|
|
|
|
const uint32_t *cardinals = reinterpret_cast<const uint32_t*>(value.constData());
|
|
|
|
for (unsigned int i = 0; i < value.size() / sizeof(uint32_t);) {
|
|
|
|
int x = cardinals[i++];
|
|
|
|
int y = cardinals[i++];
|
|
|
|
int w = cardinals[i++];
|
|
|
|
int h = cardinals[i++];
|
|
|
|
region += QRect(x, y, w, h);
|
|
|
|
}
|
2010-03-06 16:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-31 13:47:01 +00:00
|
|
|
KWayland::Server::SurfaceInterface *surf = w->surface();
|
|
|
|
|
|
|
|
if (surf && surf->blur()) {
|
|
|
|
region = surf->blur()->region();
|
|
|
|
}
|
|
|
|
|
|
|
|
//!value.isNull() full window in X11 case, surf->blur()
|
|
|
|
//valid, full window in wayland case
|
|
|
|
if (region.isEmpty() && (!value.isNull() || (surf && surf->blur()))) {
|
2010-03-12 16:47:45 +00:00
|
|
|
// Set the data to a dummy value.
|
|
|
|
// This is needed to be able to distinguish between the value not
|
|
|
|
// being set, and being set to an empty region.
|
2010-07-23 19:52:20 +00:00
|
|
|
w->setData(WindowBlurBehindRole, 1);
|
2010-03-12 16:47:45 +00:00
|
|
|
} else
|
2010-07-23 19:52:20 +00:00
|
|
|
w->setData(WindowBlurBehindRole, region);
|
2010-03-06 16:14:25 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 21:06:02 +00:00
|
|
|
void BlurEffect::slotWindowAdded(EffectWindow *w)
|
2010-03-06 16:14:25 +00:00
|
|
|
{
|
2015-08-31 13:47:01 +00:00
|
|
|
KWayland::Server::SurfaceInterface *surf = w->surface();
|
|
|
|
|
|
|
|
if (surf) {
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
windowBlurChangedConnections[w] = connect(surf, &KWayland::Server::SurfaceInterface::blurChanged, this, [this, w] () {
|
2015-08-31 13:47:01 +00:00
|
|
|
if (w) {
|
|
|
|
updateBlurRegion(w);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
|
2010-03-06 16:14:25 +00:00
|
|
|
updateBlurRegion(w);
|
|
|
|
}
|
|
|
|
|
2011-07-17 15:57:30 +00:00
|
|
|
void BlurEffect::slotWindowDeleted(EffectWindow *w)
|
|
|
|
{
|
2018-05-25 16:49:44 +00:00
|
|
|
auto it = windowBlurChangedConnections.find(w);
|
|
|
|
if (it == windowBlurChangedConnections.end()) {
|
|
|
|
return;
|
2011-07-17 15:57:30 +00:00
|
|
|
}
|
2018-05-25 16:49:44 +00:00
|
|
|
disconnect(*it);
|
|
|
|
windowBlurChangedConnections.erase(it);
|
2011-07-17 15:57:30 +00:00
|
|
|
}
|
|
|
|
|
2011-03-12 18:18:19 +00:00
|
|
|
void BlurEffect::slotPropertyNotify(EffectWindow *w, long atom)
|
2010-03-06 16:14:25 +00:00
|
|
|
{
|
2017-09-10 14:51:18 +00:00
|
|
|
if (w && atom == net_wm_blur_region && net_wm_blur_region != XCB_ATOM_NONE) {
|
2010-03-06 16:14:25 +00:00
|
|
|
updateBlurRegion(w);
|
2011-10-12 13:16:46 +00:00
|
|
|
}
|
2010-03-06 16:14:25 +00:00
|
|
|
}
|
|
|
|
|
2011-05-01 20:52:43 +00:00
|
|
|
bool BlurEffect::enabledByDefault()
|
|
|
|
{
|
|
|
|
GLPlatform *gl = GLPlatform::instance();
|
|
|
|
|
2012-02-04 10:23:04 +00:00
|
|
|
if (gl->isIntel() && gl->chipClass() < SandyBridge)
|
2011-05-01 20:52:43 +00:00
|
|
|
return false;
|
2016-08-09 12:52:14 +00:00
|
|
|
if (gl->isSoftwareEmulation()) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-01 20:52:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
bool BlurEffect::supported()
|
|
|
|
{
|
2018-05-31 19:02:05 +00:00
|
|
|
bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported() && GLRenderTarget::blitSupported();
|
2010-09-25 00:11:06 +00:00
|
|
|
|
|
|
|
if (supported) {
|
|
|
|
int maxTexSize;
|
|
|
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
|
|
|
|
|
2014-02-24 15:13:30 +00:00
|
|
|
const QSize screenSize = effects->virtualScreenSize();
|
|
|
|
if (screenSize.width() > maxTexSize || screenSize.height() > maxTexSize)
|
2010-09-25 00:11:06 +00:00
|
|
|
supported = false;
|
|
|
|
}
|
2010-07-05 13:42:34 +00:00
|
|
|
return supported;
|
2010-03-05 20:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QRect BlurEffect::expand(const QRect &rect) const
|
|
|
|
{
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
return rect.adjusted(-m_expandSize, -m_expandSize, m_expandSize, m_expandSize);
|
2010-03-05 20:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QRegion BlurEffect::expand(const QRegion ®ion) const
|
|
|
|
{
|
|
|
|
QRegion expanded;
|
|
|
|
|
2017-12-02 16:38:14 +00:00
|
|
|
for (const QRect &rect : region) {
|
2011-01-30 14:34:42 +00:00
|
|
|
expanded += expand(rect);
|
2011-07-09 10:43:32 +00:00
|
|
|
}
|
2010-03-05 20:42:10 +00:00
|
|
|
|
|
|
|
return expanded;
|
|
|
|
}
|
|
|
|
|
2010-03-06 16:14:25 +00:00
|
|
|
QRegion BlurEffect::blurRegion(const EffectWindow *w) const
|
|
|
|
{
|
|
|
|
QRegion region;
|
|
|
|
|
2010-07-23 19:52:20 +00:00
|
|
|
const QVariant value = w->data(WindowBlurBehindRole);
|
2010-03-06 16:14:25 +00:00
|
|
|
if (value.isValid()) {
|
|
|
|
const QRegion appRegion = qvariant_cast<QRegion>(value);
|
|
|
|
if (!appRegion.isEmpty()) {
|
2012-10-12 09:34:05 +00:00
|
|
|
if (w->decorationHasAlpha() && effects->decorationSupportsBlurBehind()) {
|
2010-03-06 16:14:25 +00:00
|
|
|
region = w->shape();
|
2010-03-12 16:47:45 +00:00
|
|
|
region -= w->decorationInnerRect();
|
2011-10-15 14:19:19 +00:00
|
|
|
}
|
|
|
|
region |= appRegion.translated(w->contentsRect().topLeft()) &
|
|
|
|
w->decorationInnerRect();
|
2010-03-12 16:47:45 +00:00
|
|
|
} else {
|
|
|
|
// An empty region means that the blur effect should be enabled
|
|
|
|
// for the whole window.
|
2010-03-06 16:14:25 +00:00
|
|
|
region = w->shape();
|
2010-03-12 16:47:45 +00:00
|
|
|
}
|
2012-10-12 09:34:05 +00:00
|
|
|
} else if (w->decorationHasAlpha() && effects->decorationSupportsBlurBehind()) {
|
2010-03-12 16:47:45 +00:00
|
|
|
// If the client hasn't specified a blur region, we'll only enable
|
|
|
|
// the effect behind the decoration.
|
2010-03-06 16:14:25 +00:00
|
|
|
region = w->shape();
|
2010-03-12 16:47:45 +00:00
|
|
|
region -= w->decorationInnerRect();
|
|
|
|
}
|
2010-03-06 16:14:25 +00:00
|
|
|
|
|
|
|
return region;
|
|
|
|
}
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
void BlurEffect::uploadRegion(QVector2D *&map, const QRegion ®ion, const int downSampleIterations)
|
2010-03-12 18:29:16 +00:00
|
|
|
{
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
for (int i = 0; i <= downSampleIterations; i++) {
|
|
|
|
const int divisionRatio = (1 << i);
|
|
|
|
|
|
|
|
for (const QRect &r : region) {
|
|
|
|
const QVector2D topLeft( r.x() / divisionRatio, r.y() / divisionRatio);
|
|
|
|
const QVector2D topRight( (r.x() + r.width()) / divisionRatio, r.y() / divisionRatio);
|
|
|
|
const QVector2D bottomLeft( r.x() / divisionRatio, (r.y() + r.height()) / divisionRatio);
|
|
|
|
const QVector2D bottomRight((r.x() + r.width()) / divisionRatio, (r.y() + r.height()) / divisionRatio);
|
|
|
|
|
|
|
|
// First triangle
|
|
|
|
*(map++) = topRight;
|
|
|
|
*(map++) = topLeft;
|
|
|
|
*(map++) = bottomLeft;
|
|
|
|
|
|
|
|
// Second triangle
|
|
|
|
*(map++) = bottomLeft;
|
|
|
|
*(map++) = bottomRight;
|
|
|
|
*(map++) = topRight;
|
|
|
|
}
|
2013-03-24 15:44:40 +00:00
|
|
|
}
|
2013-03-24 16:00:11 +00:00
|
|
|
}
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
void BlurEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &blurRegion, const QRegion &windowRegion)
|
2013-03-24 16:00:11 +00:00
|
|
|
{
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
const int vertexCount = ((blurRegion.rectCount() * (m_downSampleIterations + 1)) + windowRegion.rectCount()) * 6;
|
|
|
|
|
2015-05-19 12:35:12 +00:00
|
|
|
if (!vertexCount)
|
|
|
|
return;
|
2013-03-24 15:44:40 +00:00
|
|
|
|
2013-03-24 16:00:11 +00:00
|
|
|
QVector2D *map = (QVector2D *) vbo->map(vertexCount * sizeof(QVector2D));
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
|
|
|
|
uploadRegion(map, blurRegion, m_downSampleIterations);
|
|
|
|
uploadRegion(map, windowRegion, 0);
|
|
|
|
|
2013-03-24 15:44:40 +00:00
|
|
|
vbo->unmap();
|
|
|
|
|
|
|
|
const GLVertexAttrib layout[] = {
|
|
|
|
{ VA_Position, 2, GL_FLOAT, 0 },
|
|
|
|
{ VA_TexCoord, 2, GL_FLOAT, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
vbo->setAttribLayout(layout, 2, sizeof(QVector2D));
|
2010-03-12 18:29:16 +00:00
|
|
|
}
|
|
|
|
|
2011-05-01 21:17:28 +00:00
|
|
|
void BlurEffect::prePaintScreen(ScreenPrePaintData &data, int time)
|
2010-03-05 20:42:10 +00:00
|
|
|
{
|
2011-07-09 10:43:32 +00:00
|
|
|
m_damagedArea = QRegion();
|
2011-07-17 15:57:30 +00:00
|
|
|
m_paintedArea = QRegion();
|
2011-07-09 10:43:32 +00:00
|
|
|
m_currentBlur = QRegion();
|
2011-05-01 21:17:28 +00:00
|
|
|
|
|
|
|
effects->prePaintScreen(data, time);
|
2011-07-09 10:43:32 +00:00
|
|
|
}
|
2011-05-01 21:17:28 +00:00
|
|
|
|
2011-07-09 10:43:32 +00:00
|
|
|
void BlurEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
// this effect relies on prePaintWindow being called in the bottom to top order
|
2011-05-01 21:17:28 +00:00
|
|
|
|
2011-07-09 10:43:32 +00:00
|
|
|
effects->prePaintWindow(w, data, time);
|
2011-05-01 21:17:28 +00:00
|
|
|
|
2011-07-09 10:43:32 +00:00
|
|
|
if (!w->isPaintingEnabled()) {
|
2011-05-01 21:17:28 +00:00
|
|
|
return;
|
|
|
|
}
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
if (!m_shader || !m_shader->isValid()) {
|
2012-10-05 09:46:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-05-01 21:17:28 +00:00
|
|
|
|
2011-07-09 10:43:32 +00:00
|
|
|
// to blur an area partially we have to shrink the opaque area of a window
|
|
|
|
QRegion newClip;
|
|
|
|
const QRegion oldClip = data.clip;
|
2017-12-02 16:38:14 +00:00
|
|
|
for (const QRect &rect : data.clip) {
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
newClip |= rect.adjusted(m_expandSize, m_expandSize, -m_expandSize, -m_expandSize);
|
2011-07-09 10:43:32 +00:00
|
|
|
}
|
|
|
|
data.clip = newClip;
|
|
|
|
|
2011-07-17 15:57:30 +00:00
|
|
|
const QRegion oldPaint = data.paint;
|
|
|
|
|
2011-08-03 06:16:12 +00:00
|
|
|
// we don't have to blur a region we don't see
|
2011-07-09 10:43:32 +00:00
|
|
|
m_currentBlur -= newClip;
|
|
|
|
// if we have to paint a non-opaque part of this window that intersects with the
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
// currently blurred region we have to redraw the whole region
|
|
|
|
if ((data.paint - oldClip).intersects(m_currentBlur)) {
|
2011-07-09 10:43:32 +00:00
|
|
|
data.paint |= m_currentBlur;
|
|
|
|
}
|
|
|
|
|
|
|
|
// in case this window has regions to be blurred
|
2014-02-24 15:13:30 +00:00
|
|
|
const QRect screen = effects->virtualScreenGeometry();
|
2012-02-16 20:11:51 +00:00
|
|
|
const QRegion blurArea = blurRegion(w).translated(w->pos()) & screen;
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
const QRegion expandedBlur = (w->isDock() ? blurArea : expand(blurArea)) & screen;
|
|
|
|
|
|
|
|
// if this window or a window underneath the blurred area is painted again we have to
|
|
|
|
// blur everything
|
|
|
|
if (m_paintedArea.intersects(expandedBlur) || data.paint.intersects(blurArea)) {
|
|
|
|
data.paint |= expandedBlur;
|
|
|
|
// we keep track of the "damage propagation"
|
|
|
|
m_damagedArea |= (w->isDock() ? (expandedBlur & m_damagedArea) : expand(expandedBlur & m_damagedArea)) & blurArea;
|
|
|
|
// we have to check again whether we do not damage a blurred area
|
|
|
|
// of a window
|
|
|
|
if (expandedBlur.intersects(m_currentBlur)) {
|
|
|
|
data.paint |= m_currentBlur;
|
2011-05-01 21:17:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_currentBlur |= expandedBlur;
|
|
|
|
|
2011-08-03 06:16:12 +00:00
|
|
|
// we don't consider damaged areas which are occluded and are not
|
2011-07-09 10:43:32 +00:00
|
|
|
// explicitly damaged by this window
|
|
|
|
m_damagedArea -= data.clip;
|
2011-07-17 15:57:30 +00:00
|
|
|
m_damagedArea |= oldPaint;
|
|
|
|
|
|
|
|
// in contrast to m_damagedArea does m_paintedArea keep track of all repainted areas
|
|
|
|
m_paintedArea -= data.clip;
|
|
|
|
m_paintedArea |= data.paint;
|
2010-03-05 20:42:10 +00:00
|
|
|
}
|
|
|
|
|
2011-05-14 16:22:38 +00:00
|
|
|
bool BlurEffect::shouldBlur(const EffectWindow *w, int mask, const WindowPaintData &data) const
|
2010-03-05 20:42:10 +00:00
|
|
|
{
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
if (!m_renderTargetsValid || !m_shader || !m_shader->isValid())
|
2011-05-14 16:22:38 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (effects->activeFullScreenEffect() && !w->data(WindowForceBlurRole).toBool())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (w->isDesktop())
|
|
|
|
return false;
|
|
|
|
|
2012-05-28 10:00:31 +00:00
|
|
|
bool scaled = !qFuzzyCompare(data.xScale(), 1.0) && !qFuzzyCompare(data.yScale(), 1.0);
|
2012-05-28 12:45:46 +00:00
|
|
|
bool translated = data.xTranslation() || data.yTranslation();
|
2011-05-14 16:22:38 +00:00
|
|
|
|
2016-02-25 11:45:19 +00:00
|
|
|
if ((scaled || (translated || (mask & PAINT_WINDOW_TRANSFORMED))) && !w->data(WindowForceBlurRole).toBool())
|
2011-05-14 16:22:38 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
bool blurBehindDecos = effects->decorationsHaveAlpha() &&
|
|
|
|
effects->decorationSupportsBlurBehind();
|
|
|
|
|
2015-06-22 13:48:48 +00:00
|
|
|
if (!w->hasAlpha() && w->opacity() >= 1.0 && !(blurBehindDecos && w->hasDecoration()))
|
2011-05-14 16:22:38 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
|
|
|
{
|
2016-10-18 14:33:20 +00:00
|
|
|
const QRect screen = GLRenderTarget::virtualScreenGeometry();
|
2011-05-14 16:22:38 +00:00
|
|
|
if (shouldBlur(w, mask, data)) {
|
2011-12-10 21:32:47 +00:00
|
|
|
QRegion shape = region & blurRegion(w).translated(w->pos()) & screen;
|
|
|
|
|
|
|
|
// let's do the evil parts - someone wants to blur behind a transformed window
|
2016-02-09 11:09:01 +00:00
|
|
|
const bool translated = data.xTranslation() || data.yTranslation();
|
|
|
|
const bool scaled = data.xScale() != 1 || data.yScale() != 1;
|
|
|
|
if (scaled) {
|
|
|
|
QPoint pt = shape.boundingRect().topLeft();
|
|
|
|
QVector<QRect> shapeRects = shape.rects();
|
|
|
|
shape = QRegion(); // clear
|
|
|
|
foreach (QRect r, shapeRects) {
|
|
|
|
r.moveTo(pt.x() + (r.x() - pt.x()) * data.xScale() + data.xTranslation(),
|
|
|
|
pt.y() + (r.y() - pt.y()) * data.yScale() + data.yTranslation());
|
|
|
|
r.setWidth(r.width() * data.xScale());
|
|
|
|
r.setHeight(r.height() * data.yScale());
|
|
|
|
shape |= r;
|
|
|
|
}
|
|
|
|
shape = shape & region;
|
|
|
|
|
|
|
|
//Only translated, not scaled
|
|
|
|
} else if (translated) {
|
2012-05-28 12:45:46 +00:00
|
|
|
shape = shape.translated(data.xTranslation(), data.yTranslation());
|
2011-12-10 21:32:47 +00:00
|
|
|
shape = shape & region;
|
|
|
|
}
|
2011-05-14 16:22:38 +00:00
|
|
|
|
2011-07-17 15:57:30 +00:00
|
|
|
if (!shape.isEmpty()) {
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
doBlur(shape, screen, data.opacity(), data.screenProjectionMatrix(), w->isDock(), w->geometry());
|
2011-07-17 15:57:30 +00:00
|
|
|
}
|
2010-03-05 20:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the window over the blurred area
|
|
|
|
effects->drawWindow(w, mask, region, data);
|
|
|
|
}
|
|
|
|
|
2010-07-24 20:48:19 +00:00
|
|
|
void BlurEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity)
|
|
|
|
{
|
2014-02-24 15:13:30 +00:00
|
|
|
const QRect screen = effects->virtualScreenGeometry();
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
bool valid = m_renderTargetsValid && m_shader && m_shader->isValid();
|
|
|
|
|
|
|
|
QRegion shape = frame->geometry().adjusted(-borderSize, -borderSize, borderSize, borderSize) & screen;
|
|
|
|
|
2011-04-27 12:48:34 +00:00
|
|
|
if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect()) && frame->style() != EffectFrameNone) {
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
doBlur(shape, screen, opacity * frameOpacity, frame->screenProjectionMatrix(), false, frame->geometry());
|
2010-07-24 20:48:19 +00:00
|
|
|
}
|
|
|
|
effects->paintEffectFrame(frame, region, opacity, frameOpacity);
|
|
|
|
}
|
|
|
|
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
void BlurEffect::generateNoiseTexture()
|
|
|
|
{
|
|
|
|
if (m_noiseStrength == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init randomness based on time
|
|
|
|
qsrand((uint)QTime::currentTime().msec());
|
|
|
|
|
|
|
|
QImage noiseImage(QSize(256, 256), QImage::Format_Grayscale8);
|
|
|
|
|
|
|
|
for (int y = 0; y < noiseImage.height(); y++) {
|
|
|
|
uint8_t *noiseImageLine = (uint8_t *) noiseImage.scanLine(y);
|
|
|
|
|
|
|
|
for (int x = 0; x < noiseImage.width(); x++) {
|
|
|
|
noiseImageLine[x] = qrand() % m_noiseStrength + (128 - m_noiseStrength / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The noise texture looks distorted when not scaled with integer
|
|
|
|
noiseImage = noiseImage.scaled(noiseImage.size() * m_scalingFactor);
|
|
|
|
|
|
|
|
m_noiseTexture = GLTexture(noiseImage);
|
|
|
|
m_noiseTexture.setFilter(GL_NEAREST);
|
|
|
|
m_noiseTexture.setWrapMode(GL_REPEAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection, bool isDock, QRect windowRect)
|
2010-07-24 20:48:19 +00:00
|
|
|
{
|
2018-05-29 13:28:27 +00:00
|
|
|
// Blur would not render correctly on a secondary monitor because of wrong coordinates
|
|
|
|
// BUG: 393723
|
|
|
|
const int xTranslate = -screen.x();
|
|
|
|
const int yTranslate = effects->virtualScreenSize().height() - screen.height() - screen.y();
|
|
|
|
|
|
|
|
const QRegion expandedBlurRegion = expand(shape) & expand(screen);
|
2010-07-24 20:48:19 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
// Upload geometry for the down and upsample iterations
|
2013-03-24 16:00:11 +00:00
|
|
|
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
|
2018-05-29 13:28:27 +00:00
|
|
|
|
|
|
|
uploadGeometry(vbo, expandedBlurRegion.translated(xTranslate, yTranslate), shape);
|
2013-03-24 16:00:11 +00:00
|
|
|
vbo->bindArrays();
|
|
|
|
|
2018-05-29 13:28:27 +00:00
|
|
|
const QRect sourceRect = expandedBlurRegion.boundingRect() & screen;
|
|
|
|
const QRect destRect = sourceRect.translated(xTranslate, yTranslate);
|
|
|
|
|
|
|
|
GLRenderTarget::pushRenderTargets(m_renderTargetStack);
|
|
|
|
int blurRectCount = expandedBlurRegion.rectCount() * 6;
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
/*
|
|
|
|
* If the window is a dock or panel we avoid the "extended blur" effect.
|
|
|
|
* Extended blur is when windows that are not under the blurred area affect
|
|
|
|
* the final blur result.
|
|
|
|
* We want to avoid this on panels, because it looks really weird and ugly
|
|
|
|
* when maximized windows or windows near the panel affect the dock blur.
|
|
|
|
*/
|
|
|
|
if (isDock) {
|
2018-05-29 13:28:27 +00:00
|
|
|
m_renderTargets.last()->blitFromFramebuffer(sourceRect, destRect);
|
|
|
|
copyScreenSampleTexture(vbo, blurRectCount, shape.translated(xTranslate, yTranslate), screenProjection);
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
} else {
|
2018-05-29 13:28:27 +00:00
|
|
|
m_renderTargets.first()->blitFromFramebuffer(sourceRect, destRect);
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
// Remove the m_renderTargets[0] from the top of the stack that we will not use
|
|
|
|
GLRenderTarget::popRenderTarget();
|
|
|
|
}
|
2010-07-24 20:48:19 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
downSampleTexture(vbo, blurRectCount);
|
|
|
|
upSampleTexture(vbo, blurRectCount);
|
2010-07-24 20:48:19 +00:00
|
|
|
|
|
|
|
// Modulate the blurred texture with the window opacity if the window isn't opaque
|
|
|
|
if (opacity < 1.0) {
|
|
|
|
glEnable(GL_BLEND);
|
2015-06-22 13:48:48 +00:00
|
|
|
#if 1 // bow shape, always above y = x
|
|
|
|
float o = 1.0f-opacity;
|
|
|
|
o = 1.0f - o*o;
|
|
|
|
#else // sigmoid shape, above y = x for x > 0.5, below y = x for x < 0.5
|
|
|
|
float o = 2.0f*opacity - 1.0f;
|
|
|
|
o = 0.5f + o / (1.0f + qAbs(o));
|
|
|
|
#endif
|
|
|
|
glBlendColor(0, 0, 0, o);
|
2010-07-24 20:48:19 +00:00
|
|
|
glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
|
|
|
|
}
|
|
|
|
|
Fix unused param warnings
Summary:
Compiler: GCC 7.3.1
Distro: Arch Linux
Compiler warnings:
```
/home/vlad/KDE/src/kde/workspace/kwin/effects/blur/blur.cpp: In member function ‘void KWin::BlurEffect::upscaleRenderToScreen(KWin::GLVertexBuffer*, int, int, QMatrix4x4, QRect, QPoint)’:
/home/vlad/KDE/src/kde/workspace/kwin/effects/blur/blur.cpp:677:129: warning: unused parameter ‘windowShape’ [-Wunused-parameter]
void BlurEffect::upscaleRenderToScreen(GLVertexBuffer *vbo, int vboStart, int blurRectCount, QMatrix4x4 screenProjection, QRect windowShape, QPoint windowPosition)
^~~~~~~~~~~
```
```
/home/vlad/KDE/src/kde/workspace/kwin/main_wayland.cpp: In function ‘void KWin::{anonymous}::gainRealTime(KWin::RealTimeFlags)’:
/home/vlad/KDE/src/kde/workspace/kwin/main_wayland.cpp:95:56: warning: unused parameter ‘flags’ [-Wunused-parameter]
void gainRealTime(RealTimeFlags flags = RealTimeFlags::DontReset)
```
Reviewers: #kwin, davidedmundson
Reviewed By: davidedmundson
Subscribers: anemeth, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D12208
2018-04-20 18:06:59 +00:00
|
|
|
upscaleRenderToScreen(vbo, blurRectCount * (m_downSampleIterations + 1), shape.rectCount() * 6, screenProjection, windowRect.topLeft());
|
2010-07-24 20:48:19 +00:00
|
|
|
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
if (opacity < 1.0) {
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
vbo->unbindArrays();
|
|
|
|
}
|
|
|
|
|
Fix unused param warnings
Summary:
Compiler: GCC 7.3.1
Distro: Arch Linux
Compiler warnings:
```
/home/vlad/KDE/src/kde/workspace/kwin/effects/blur/blur.cpp: In member function ‘void KWin::BlurEffect::upscaleRenderToScreen(KWin::GLVertexBuffer*, int, int, QMatrix4x4, QRect, QPoint)’:
/home/vlad/KDE/src/kde/workspace/kwin/effects/blur/blur.cpp:677:129: warning: unused parameter ‘windowShape’ [-Wunused-parameter]
void BlurEffect::upscaleRenderToScreen(GLVertexBuffer *vbo, int vboStart, int blurRectCount, QMatrix4x4 screenProjection, QRect windowShape, QPoint windowPosition)
^~~~~~~~~~~
```
```
/home/vlad/KDE/src/kde/workspace/kwin/main_wayland.cpp: In function ‘void KWin::{anonymous}::gainRealTime(KWin::RealTimeFlags)’:
/home/vlad/KDE/src/kde/workspace/kwin/main_wayland.cpp:95:56: warning: unused parameter ‘flags’ [-Wunused-parameter]
void gainRealTime(RealTimeFlags flags = RealTimeFlags::DontReset)
```
Reviewers: #kwin, davidedmundson
Reviewed By: davidedmundson
Subscribers: anemeth, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D12208
2018-04-20 18:06:59 +00:00
|
|
|
void BlurEffect::upscaleRenderToScreen(GLVertexBuffer *vbo, int vboStart, int blurRectCount, QMatrix4x4 screenProjection, QPoint windowPosition)
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
{
|
|
|
|
glActiveTexture(GL_TEXTURE0);
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_renderTextures[1].bind();
|
|
|
|
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
if (m_noiseStrength > 0) {
|
|
|
|
m_shader->bind(BlurShader::NoiseSampleType);
|
2018-05-31 12:33:52 +00:00
|
|
|
m_shader->setTargetTextureSize(m_renderTextures[0].size() * GLRenderTarget::virtualScreenScale());
|
|
|
|
m_shader->setNoiseTextureSize(m_noiseTexture.size() * GLRenderTarget::virtualScreenScale());
|
|
|
|
m_shader->setTexturePosition(windowPosition * GLRenderTarget::virtualScreenScale());
|
2010-07-24 20:48:19 +00:00
|
|
|
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
glActiveTexture(GL_TEXTURE1);
|
|
|
|
m_noiseTexture.bind();
|
|
|
|
} else {
|
|
|
|
m_shader->bind(BlurShader::UpSampleType);
|
2018-05-31 12:33:52 +00:00
|
|
|
m_shader->setTargetTextureSize(m_renderTextures[0].size() * GLRenderTarget::virtualScreenScale());
|
2011-01-08 18:56:22 +00:00
|
|
|
}
|
2010-07-24 20:48:19 +00:00
|
|
|
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
m_shader->setOffset(m_offset);
|
|
|
|
m_shader->setModelViewProjectionMatrix(screenProjection);
|
|
|
|
|
|
|
|
//Render to the screen
|
|
|
|
vbo->draw(GL_TRIANGLES, vboStart, blurRectCount);
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0);
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->unbind();
|
2011-07-17 15:57:30 +00:00
|
|
|
}
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
void BlurEffect::downSampleTexture(GLVertexBuffer *vbo, int blurRectCount)
|
2011-07-17 15:57:30 +00:00
|
|
|
{
|
|
|
|
QMatrix4x4 modelViewProjectionMatrix;
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->bind(BlurShader::DownSampleType);
|
|
|
|
m_shader->setOffset(m_offset);
|
2012-02-16 20:11:51 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
for (int i = 1; i <= m_downSampleIterations; i++) {
|
|
|
|
modelViewProjectionMatrix.setToIdentity();
|
|
|
|
modelViewProjectionMatrix.ortho(0, m_renderTextures[i].width(), m_renderTextures[i].height(), 0 , 0, 65535);
|
2013-03-24 16:00:11 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->setModelViewProjectionMatrix(modelViewProjectionMatrix);
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
m_shader->setTargetTextureSize(m_renderTextures[i].size());
|
2013-03-24 16:00:11 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
//Copy the image from this texture
|
|
|
|
m_renderTextures[i - 1].bind();
|
2013-03-24 16:00:11 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount);
|
|
|
|
GLRenderTarget::popRenderTarget();
|
|
|
|
}
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->unbind();
|
|
|
|
}
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
void BlurEffect::upSampleTexture(GLVertexBuffer *vbo, int blurRectCount)
|
|
|
|
{
|
|
|
|
QMatrix4x4 modelViewProjectionMatrix;
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->bind(BlurShader::UpSampleType);
|
|
|
|
m_shader->setOffset(m_offset);
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
for (int i = m_downSampleIterations - 1; i >= 1; i--) {
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
modelViewProjectionMatrix.setToIdentity();
|
|
|
|
modelViewProjectionMatrix.ortho(0, m_renderTextures[i].width(), m_renderTextures[i].height(), 0 , 0, 65535);
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->setModelViewProjectionMatrix(modelViewProjectionMatrix);
|
Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.
Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences
{F5694024}
{F5694031}
{F5694025}
{F5694028}
Reviewers: #kwin, #vdg, fredrik
Reviewed By: #vdg, fredrik
Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10281
2018-02-13 23:12:39 +00:00
|
|
|
m_shader->setTargetTextureSize(m_renderTextures[i].size());
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
//Copy the image from this texture
|
|
|
|
m_renderTextures[i + 1].bind();
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount);
|
2011-07-17 15:57:30 +00:00
|
|
|
GLRenderTarget::popRenderTarget();
|
|
|
|
}
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->unbind();
|
|
|
|
}
|
2011-07-17 15:57:30 +00:00
|
|
|
|
2018-05-29 13:28:27 +00:00
|
|
|
void BlurEffect::copyScreenSampleTexture(GLVertexBuffer *vbo, int blurRectCount, QRegion blurShape, QMatrix4x4 screenProjection)
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
{
|
|
|
|
m_shader->bind(BlurShader::CopySampleType);
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->setModelViewProjectionMatrix(screenProjection);
|
2018-05-29 13:28:27 +00:00
|
|
|
m_shader->setTargetTextureSize(effects->virtualScreenSize());
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
/*
|
|
|
|
* This '1' sized adjustment is necessary do avoid windows affecting the blur that are
|
|
|
|
* right next to this window.
|
|
|
|
*/
|
2018-05-29 13:28:27 +00:00
|
|
|
m_shader->setBlurRect(blurShape.boundingRect().adjusted(1, 1, -1, -1), effects->virtualScreenSize());
|
|
|
|
m_renderTextures.last().bind();
|
2011-07-17 15:57:30 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
vbo->draw(GL_TRIANGLES, 0, blurRectCount);
|
|
|
|
GLRenderTarget::popRenderTarget();
|
2010-07-24 20:48:19 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
m_shader->unbind();
|
2012-08-11 09:24:37 +00:00
|
|
|
}
|
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
} // namespace KWin
|
|
|
|
|