Commit Graph

40 Commits (95ff4a2d49d897739f58e931454edf0272798038)

Author SHA1 Message Date
Vlad Zagorodniy 168109f3bb [effects/blur] Clean up shader code
Summary:
* Drop abstract BlurShader class
* Delete evil "using namespace KWin"
* Fix includes
* Use smart pointers
* Turn BlurShader into a QObject
* Fix coding style
* Add missing default cases
* Use default member initialization
* Delete methods that are used only once
* Use more const
* Use QRect::{top,right,bottom,left} methods in the setBlurRect method

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13110
2018-06-18 15:50:52 +03:00
Alex Nemeth 99532fb95c Fix multimonitor blur
Summary:
On wayland blur on secondary monitor would not render correctly.

BUG: 393723
Depends on D12452

Test Plan:
 - use more than one output
 - log in in a wayland session
 - open a transparent window (for example: Konsole with transparent and blur enabled profile)
 - drag the window to another screen
 - blurs the content under the window corretly

Reviewers: #kwin, graesslin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: apol, zzag, davidedmundson, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12678
2018-05-29 15:32:55 +02:00
Alex Nemeth cc0325af41 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-14 00:13:08 +01:00
Alex Nemeth 977a5ef012 Reverted accidental file permission changes
Summary: In D9848 the file permissions in effects/blur where accidentally changed from 644 to 755.

Test Plan: {F5674656}

Reviewers: #kwin, hein

Reviewed By: hein

Subscribers: kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D10100
2018-01-26 03:32:33 +09:00
Alex Nemeth 0179f741bb 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-26 02:31:45 +09:00
Martin Gräßlin 7983acea88 [effects] Support GLES 3 in Blur and BackgroundContrast
Fix code generation in case OpenGL ES 3 or later is used.

BUG: 324478
FIXED-IN: 5.5
REVIEW: 126003
2015-11-09 16:22:32 +01:00
Martin Gräßlin 78ac6aaf13 [effects] Runtime checks for GLES instead of compile time checks 2015-11-03 09:29:31 +01:00
Martin Gräßlin 8919cd5f54 [effects] Simplify supported check in blur and backgroundcontrast
GLSL is always required nowadays on GL compositor.

REVIEW: 118642
2014-06-11 14:50:01 +02:00
Martin Gräßlin c7d986c7fe [kwin] Remove the legacy OpenGL 1 compositing backend
KWin already has a de facto OpenGL 2 dependency through QML. Combined
with the fact that the OpenGL 1 backend is basically unmaintained and
also unused, it's better to remove it for the new major release.

This change includes:
 * Removal of cmake option KWIN_BUILD_OPENGL_1_COMPOSITING
 * Removal of KWIN_HAVE_OPENGL_1 compile option and all code
   ifdef'ed with it (partially removal of if-else constructs)
 * Removal of CompositingType::OpenGL1Compositing (flags are kept
   as a core flag should get introduced)
 * Driver recommendation for OpenGL1Compositing changed to XRender
   (should be evaluated whether the drivers can provide GL2)
 * Removal of configuration option "GLLegacy"
 * Removal of fooMatrix function in kwinglutils
 * Removal of ARBBlurShader
 * Removal of legacy code path in GLVertexBuffer
 * Removal of GLShaderManager::disable
 * if-blocks with ShaderManager::instance()->isValid() removed

REVIEW: 116042
2014-03-10 08:59:11 +01:00
Martin Gräßlin 3f0ff9b8d5 Migrate effects from displayWidth()/displayHeight() to virtualScreenSize()/virtualScreenGeometry()
Rational behind this change is that displayWidth and displayHeight are
X specific API calls in kwinglobals. For the future it's easier to only
rely on functionality which goes through the EffectsHandler API which
allows easier adjustments in KWin core.

displayWidth() and displayHeight() are only used to get the size or the
complete rect of all screens. This is also provided by:

effects->virtualScreenGeometry() or
effects->virtualScreenSize()

REVIEW: 116021
2014-03-07 08:01:44 +01:00
Jacob Logan ac72e9fb73 Changed debug statements in kwin/effects from qDebug() to qCDebug(KWINEFFECTS)
A new .cpp file is added containing the declaration of the logging
category and compiled into the effects lib.

REVIEW: 114194
2013-11-29 08:47:56 +01:00
Martin Gräßlin 987fd41d24 Port KWin/Effects from KDebug to QDebug
Still using KDE4Support as it's used in other areas.
2013-09-02 11:03:29 +02:00
Martin Gräßlin 330d40f425 Fix no cast to/from ASCII intrduced issues
* "" needs to be wrapped in QStringLiteral
* QString::fromUtf8 needed for const char* and QByteArray
* QByteArray::constData() needed to get to the const char*
2013-07-24 09:58:33 +02:00
Fredrik Höglund 25125f8982 kwin/blur: Remove the texcoord attribute
The vertex and texcoord attributes are always bound to the same
vertex array, so remove the texcoord attribute from the GLSL shader.
2013-06-11 05:12:58 +02:00
Fredrik Höglund b0582571d6 kwin/blur: Save the uniform locations
Store the uniform locations in the GLSLBlurShader object instead of
looking them up each time the uniforms are set.
2013-06-11 05:12:58 +02:00
Fredrik Höglund c652c8e1a8 kwin/blur: Add support for GLSL 1.40 2013-05-08 18:33:03 +02:00
Fredrik Höglund eff09c2b6f kwin/blur: Refactor the gaussian kernel code 2013-05-08 18:33:03 +02:00
Martin Gräßlin 99db844912 Bind ARBBlurShader to OpenGL1
The logic has already ensured that the ARBBlurShader can only be used
when using the OpenGL1 compositor, the OpenGL 2 compositor needs to use
the GLSLBlurShader.

This change moves the complete ARBBlurShader into a KWIN_HAVE_OPENGL_1
ifdef section.

As a side-effect the ::create method can now return a NULL pointer which
makes more sense then returning an ARBBlurShader in case that the
GLSLShader is not supported.

REVIEW: 106738
2012-10-25 11:34:30 +02:00
Martin Gräßlin cf5de22586 Introduce a build option KWIN_BUILD_OPENGL_1_COMPOSITING
If the build option is enabled KWIN_HAVE_OPENGL_1 is passed as a compile
flag when build against OpenGL.

This compile flag is meant to replace the KWIN_HAVE_OPENGLES. So far code
has been ifdefed for special behavior of OpenGL ES 2.0 and to remove
fixed functionality calls which are not available in OpenGL ES 2.0.

With this build flag the fixed functionality calls which are only used in
the OpenGL1 Compositor can be removed and keeping the KWIN_HAVE_OPENGLES
for the real differences between OpenGL 2.x and OpenGL ES 2.0.

E.g. a call like glColor4f should be in an
glColor4f(1.0, 1.0, 1.0, 1.0);

while a call like glPolygonMode should be in an
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

Building for OpenGL ES 2.0 of course implies that KWIN_HAVE_OPENGL_1 is
not defined.
2012-10-25 11:34:12 +02:00
Martin Gräßlin f9a2ecbf33 Do not use ShaderManager::isValid to check for OpenGL2 compositing
The main usage of ShaderManager::isValid was to have OpenGL2 specific
code pathes. Now we have an actual OpenGL2Compositing type and we know
that the ShaderManager is valid if we have this compositing type and we
know that it is not valid on OpenGL1Compositing. This gives us a much
better check and allows us to use the isValid method just for where we
want to check whether the shaders compiled successfully.

In addition some effects require OpenGL2, so we do not need to check
again that the ShaderManager is valid. Such usages are removed.
2012-09-29 15:33:57 +02:00
Martin Gräßlin d0d274b855 Don't compare uint with int
Explicitly cast uint to int to fix a warning.
2012-05-27 16:35:04 +02:00
Philipp Knechtges ef9aeafe0d kwin: Optimizing Blur Part II
This patch adds an optional texture cache to the blur effect such that damaged windows in
front of the blurred region dont trigger a repaint of the whole blurred region which pretty
often results in a avalanche repaint of nearly the whole screen.

REVIEW: 101977
2011-09-18 02:01:31 +02:00
Jaime Torres 26a492eb4a reduce the scope of two variables
reduce the scope of two variables

REVIEW: 102057
2011-08-02 17:26:21 +02:00
Fredrik Höglund 6bc8cb93da kwin/blur: Pack varyings in the GLSL shader
Pack two vec2 coordinates in each vec4 varying. This gives
a ~60% improvement in shader performance with R600G.
2011-05-15 21:25:34 +02:00
Martin Gräßlin 818a936e99 Only use GLSL blur shader if ShaderManager is valid 2011-04-29 16:44:48 +02:00
Martin Gräßlin a728823fbe Fix passing matrixes to the shaders
QMatrix4x4 accepts data in row-major order, but returns them in
column-major order, which is not documented and because of that
I expected them to be in row-major order.
This commit fixes it and rewrites the shaders to apply the matrix
multiplications in the right order.
REVIEW: 100759
2011-03-06 09:13:31 +01:00
Martin Gräßlin 0827c2903b Use GLPlatform to decide whether shaders are supported
Dropping the static methods from GLShader and use supports()
where it was used before.
2011-02-19 11:08:43 +01:00
Martin Gräßlin 0a7e48f7aa KWin uses kdelibs coding style. 2011-01-31 20:07:03 +01:00
Martin Gräßlin 8c4fc28e1a Blur ported to GLES.
It now uses a GLShader for GLSL shaders and pushes it using the
ShaderManager.

It does not work with the nouveau driver plus GLES, but it works
with fglrx + desktop GL 2.x, so I assume it is a driver problem here.
2011-01-30 14:12:06 +01:00
Martin Gräßlin 6270b502ba ARB Shader fallback to Lanczos filter.
This allows using Lanczos filter also on systems not supporting GLSL.
See http://svn.reviewboard.kde.org/r/5777/

svn path=/trunk/KDE/kdebase/workspace/; revision=1195273
2010-11-10 18:25:40 +00:00
Fredrik Höglund 08f51821b7 Don't set gl_TextCoord[0] in the vertex shader when the fragment
shader doesn't use it.

svn path=/trunk/KDE/kdebase/workspace/; revision=1178357
2010-09-22 20:13:01 +00:00
Fredrik Höglund 62b9c59da6 Rewrite the fragment program to avoid exceeding the texture indirection
limit on some GPU's.

Thanks to Mikael Gerdin, Christoph Feck and Iori Yagami for testing.

svn path=/trunk/KDE/kdebase/workspace/; revision=1138004
2010-06-14 22:13:48 +00:00
Fredrik Höglund 253647ec1e Sanity check the shader limitations to protect against implementations
returning bogus values.

FIXED-IN: 4.5
BUG: 241449

svn path=/trunk/KDE/kdebase/workspace/; revision=1137677
2010-06-14 00:18:04 +00:00
Fredrik Höglund b13174e785 Tweak the code in the fragment shader to get the Mesa GLSL compiler to emit
MAD's instead of MUL + ADD.

svn path=/trunk/KDE/kdebase/workspace/; revision=1136438
2010-06-09 20:59:24 +00:00
Fredrik Höglund 69ab6ec3b7 Use GL_CONSTANT_ALPHA instead of reducing the opacity in the fragment shader.
This makes the blending work correctly when the alpha bits are zero,
which is apparently the case with NVidia.

svn path=/trunk/KDE/kdebase/workspace/; revision=1102471
2010-03-12 16:10:57 +00:00
Fredrik Höglund c82351488e Make sure that both the render target and the shader are valid
before using them.

svn path=/trunk/KDE/kdebase/workspace/; revision=1102465
2010-03-12 15:56:19 +00:00
Fredrik Höglund 728e3ed6f6 Use the texture matrix to do the screen to texture coordinate transformations.
svn path=/trunk/KDE/kdebase/workspace/; revision=1101728
2010-03-10 18:31:59 +00:00
Fredrik Höglund 67e0e91168 Check some HW limits and make sure we don't exceed them.
svn path=/trunk/KDE/kdebase/workspace/; revision=1101724
2010-03-10 18:16:18 +00:00
Fredrik Höglund 3de8c53f21 Refactor the blur shader code a bit, and add a GLSL version.
svn path=/trunk/KDE/kdebase/workspace/; revision=1100848
2010-03-08 20:45:58 +00:00
Fredrik Höglund 53391ba944 Initial commit of the blur effect rewrite.
svn path=/trunk/KDE/kdebase/workspace/; revision=1099619
2010-03-05 20:42:10 +00:00