Add sharpen effect which does some basic sharpening.
Also requires shaders and shortcut is Ctrl+F7 for now. svn path=/trunk/KDE/kdebase/workspace/; revision=683165
This commit is contained in:
parent
f69139e825
commit
5af2cb8dda
6 changed files with 125 additions and 0 deletions
|
@ -64,6 +64,7 @@ if(OPENGL_FOUND)
|
|||
magnifier.cpp
|
||||
mousemark.cpp
|
||||
shadow.cpp
|
||||
sharpen.cpp
|
||||
trackmouse.cpp
|
||||
)
|
||||
install( FILES
|
||||
|
@ -73,6 +74,7 @@ if(OPENGL_FOUND)
|
|||
magnifier.desktop
|
||||
mousemark.desktop
|
||||
shadow.desktop
|
||||
sharpen.desktop
|
||||
trackmouse.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
install( FILES
|
||||
|
@ -87,6 +89,8 @@ if(OPENGL_FOUND)
|
|||
data/blur-render.vert
|
||||
data/invert.frag
|
||||
data/invert.vert
|
||||
data/sharpen.frag
|
||||
data/sharpen.vert
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin )
|
||||
|
||||
# config modules
|
||||
|
|
24
effects/data/sharpen.frag
Normal file
24
effects/data/sharpen.frag
Normal file
|
@ -0,0 +1,24 @@
|
|||
uniform sampler2D sceneTex;
|
||||
uniform float textureWidth;
|
||||
uniform float textureHeight;
|
||||
|
||||
|
||||
// Converts pixel coordinates to texture coordinates
|
||||
vec2 pix2tex(vec2 pix)
|
||||
{
|
||||
return vec2(pix.x / textureWidth, 1.0 - pix.y / textureHeight);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float amount = 0.4;
|
||||
vec3 tex = texture2D(sceneTex, pix2tex(gl_TexCoord[0].xy)).rgb * (1.0 + 4.0 * amount);
|
||||
|
||||
tex -= texture2D(sceneTex, pix2tex(gl_TexCoord[0].xy + vec2(0.0, 1.0))).rgb * amount;
|
||||
tex -= texture2D(sceneTex, pix2tex(gl_TexCoord[0].xy + vec2(0.0, -1.0))).rgb * amount;
|
||||
tex -= texture2D(sceneTex, pix2tex(gl_TexCoord[0].xy + vec2(1.0, 0.0))).rgb * amount;
|
||||
tex -= texture2D(sceneTex, pix2tex(gl_TexCoord[0].xy + vec2(-1.0, 0.0))).rgb * amount;
|
||||
|
||||
gl_FragColor = vec4(tex, 1.0);
|
||||
}
|
||||
|
6
effects/data/sharpen.vert
Normal file
6
effects/data/sharpen.vert
Normal file
|
@ -0,0 +1,6 @@
|
|||
void main()
|
||||
{
|
||||
gl_TexCoord[0].xy = gl_Vertex.xy;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
42
effects/sharpen.cpp
Normal file
42
effects/sharpen.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*****************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
||||
|
||||
You can Freely distribute this program under the GNU General Public
|
||||
License. See the file "COPYING" for the exact licensing terms.
|
||||
******************************************************************/
|
||||
|
||||
|
||||
#include "sharpen.h"
|
||||
|
||||
#include <kactioncollection.h>
|
||||
#include <kaction.h>
|
||||
#include <klocale.h>
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( sharpen, SharpenEffect )
|
||||
KWIN_EFFECT_SUPPORTED( sharpen, ShaderEffect::supported() )
|
||||
|
||||
|
||||
SharpenEffect::SharpenEffect() : QObject(), ShaderEffect("sharpen")
|
||||
{
|
||||
KActionCollection* actionCollection = new KActionCollection( this );
|
||||
KAction* a = (KAction*)actionCollection->addAction( "Sharpen" );
|
||||
a->setText( i18n("Toggle Sharpen effect" ));
|
||||
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F7));
|
||||
connect(a, SIGNAL(triggered(bool)), this, SLOT(toggle()));
|
||||
}
|
||||
|
||||
void SharpenEffect::toggle()
|
||||
{
|
||||
setEnabled( !isEnabled());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "sharpen.moc"
|
15
effects/sharpen.desktop
Normal file
15
effects/sharpen.desktop
Normal file
|
@ -0,0 +1,15 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Sharpen
|
||||
|
||||
Type=Service
|
||||
ServiceTypes=KWin/Effect
|
||||
X-KDE-PluginInfo-Author=Rivo Laks
|
||||
X-KDE-PluginInfo-Email=rivolaks@hot.ee
|
||||
X-KDE-PluginInfo-Name=kwin4_effect_sharpen
|
||||
X-KDE-PluginInfo-Version=0.1.0
|
||||
X-KDE-PluginInfo-Category=Appearance
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-KDE-Library=kwin4_effect_builtins
|
34
effects/sharpen.h
Normal file
34
effects/sharpen.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*****************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
||||
|
||||
You can Freely distribute this program under the GNU General Public
|
||||
License. See the file "COPYING" for the exact licensing terms.
|
||||
******************************************************************/
|
||||
|
||||
#ifndef KWIN_SHARPEN_H
|
||||
#define KWIN_SHARPEN_H
|
||||
|
||||
#include <kwinshadereffect.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
/**
|
||||
* Sharpens the whole desktop
|
||||
**/
|
||||
class SharpenEffect : public QObject, public ShaderEffect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SharpenEffect();
|
||||
|
||||
public slots:
|
||||
void toggle();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue