Here comes the ported Magnifier

This commit is contained in:
Martin Gräßlin 2011-01-06 14:29:13 +01:00
parent 5d74f9ece7
commit 75e926a6d7
3 changed files with 44 additions and 37 deletions

View file

@ -93,6 +93,7 @@ if( KWIN_HAVE_OPENGL_COMPOSITING )
include( cube/CMakeLists.txt ) include( cube/CMakeLists.txt )
include( flipswitch/CMakeLists.txt ) include( flipswitch/CMakeLists.txt )
include( glide/CMakeLists.txt ) include( glide/CMakeLists.txt )
include( magnifier/CMakeLists.txt )
include( mousemark/CMakeLists.txt ) include( mousemark/CMakeLists.txt )
include( screenshot/CMakeLists.txt ) include( screenshot/CMakeLists.txt )
include( sheet/CMakeLists.txt ) include( sheet/CMakeLists.txt )
@ -106,7 +107,6 @@ if( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING )
include( explosion/CMakeLists.txt ) include( explosion/CMakeLists.txt )
include( invert/CMakeLists.txt ) include( invert/CMakeLists.txt )
include( lookingglass/CMakeLists.txt ) include( lookingglass/CMakeLists.txt )
include( magnifier/CMakeLists.txt )
include( sharpen/CMakeLists.txt ) include( sharpen/CMakeLists.txt )
include( snow/CMakeLists.txt ) include( snow/CMakeLists.txt )
endif( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING ) endif( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING )

View file

@ -44,6 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "cube/cubeslide_config.h" #include "cube/cubeslide_config.h"
#include "flipswitch/flipswitch_config.h" #include "flipswitch/flipswitch_config.h"
#include "glide/glide_config.h" #include "glide/glide_config.h"
#include "magnifier/magnifier_config.h"
#include "mousemark/mousemark_config.h" #include "mousemark/mousemark_config.h"
#include "trackmouse/trackmouse_config.h" #include "trackmouse/trackmouse_config.h"
#include "wobblywindows/wobblywindows_config.h" #include "wobblywindows/wobblywindows_config.h"
@ -51,7 +52,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "blur/blur_config.h" #include "blur/blur_config.h"
#include "invert/invert_config.h" #include "invert/invert_config.h"
#include "lookingglass/lookingglass_config.h" #include "lookingglass/lookingglass_config.h"
#include "magnifier/magnifier_config.h"
#include "sharpen/sharpen_config.h" #include "sharpen/sharpen_config.h"
#include "snow/snow_config.h" #include "snow/snow_config.h"
#endif #endif
@ -86,6 +86,7 @@ KWIN_EFFECT_CONFIG_MULTIPLE( builtins,
KWIN_EFFECT_CONFIG_SINGLE( cubeslide, CubeSlideEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( cubeslide, CubeSlideEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( flipswitch, FlipSwitchEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( flipswitch, FlipSwitchEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( glide, GlideEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( glide, GlideEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( magnifier, MagnifierEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( mousemark, MouseMarkEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( mousemark, MouseMarkEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( trackmouse, TrackMouseEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( trackmouse, TrackMouseEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( wobblywindows, WobblyWindowsEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( wobblywindows, WobblyWindowsEffectConfig )
@ -93,7 +94,6 @@ KWIN_EFFECT_CONFIG_MULTIPLE( builtins,
KWIN_EFFECT_CONFIG_SINGLE( blur, BlurEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( blur, BlurEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( invert, InvertEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( invert, InvertEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( lookingglass, LookingGlassEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( lookingglass, LookingGlassEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( magnifier, MagnifierEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( sharpen, SharpenEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( sharpen, SharpenEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( snow, SnowEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( snow, SnowEffectConfig )
#endif #endif

View file

@ -28,9 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <kstandardaction.h> #include <kstandardaction.h>
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #include <kwinglutils.h>
#include <GL/gl.h>
#endif
namespace KWin namespace KWin
{ {
@ -96,37 +94,46 @@ void MagnifierEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
data2.yTranslate = - int( cursor.y() * ( zoom - 1 )); data2.yTranslate = - int( cursor.y() * ( zoom - 1 ));
effects->paintScreen( mask, region, data2 ); effects->paintScreen( mask, region, data2 );
PaintClipper::pop( area ); PaintClipper::pop( area );
#ifdef KWIN_HAVE_OPENGL_COMPOSITING QVector<float> verts;
if( effects->compositingType() == KWin::OpenGLCompositing ) GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
{ vbo->reset();
glPushAttrib( GL_CURRENT_BIT ); vbo->setColor(QColor(0, 0, 0));
glColor4f( 0, 0, 0, 1 ); // black // top frame
for( PaintClipper::Iterator iterator; verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
!iterator.isDone(); verts << area.left() - FRAME_WIDTH << area.top() - FRAME_WIDTH;
iterator.next()) verts << area.left() - FRAME_WIDTH << area.top() - 1;
{ verts << area.left() - FRAME_WIDTH << area.top() - 1;
glBegin( GL_QUADS ); verts << area.right() + FRAME_WIDTH << area.top() - 1;
glVertex2i( area.left() - FRAME_WIDTH, area.top() - FRAME_WIDTH ); // top frame verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
glVertex2i( area.right() + FRAME_WIDTH, area.top() - FRAME_WIDTH ); // left frame
glVertex2i( area.right() + FRAME_WIDTH, area.top() - 1 ); verts << area.left() - 1 << area.top() - FRAME_WIDTH;
glVertex2i( area.left() - FRAME_WIDTH, area.top() - 1 ); verts << area.left() - FRAME_WIDTH << area.top() - FRAME_WIDTH;
glVertex2i( area.left() - FRAME_WIDTH, area.top() - FRAME_WIDTH ); // left frame verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
glVertex2i( area.left() - 1, area.top() - FRAME_WIDTH ); verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
glVertex2i( area.left() - 1, area.bottom() + FRAME_WIDTH ); verts << area.left() - 1 << area.bottom() + FRAME_WIDTH;
glVertex2i( area.left() - FRAME_WIDTH, area.bottom() + FRAME_WIDTH ); verts << area.left() - 1 << area.top() - FRAME_WIDTH;
glVertex2i( area.right() + 1, area.top() - FRAME_WIDTH ); // right frame // right frame
glVertex2i( area.right() + FRAME_WIDTH, area.top() - FRAME_WIDTH ); verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
glVertex2i( area.right() + FRAME_WIDTH, area.bottom() + FRAME_WIDTH ); verts << area.right() + 1 << area.top() - FRAME_WIDTH;
glVertex2i( area.right() + 1, area.bottom() + FRAME_WIDTH ); verts << area.right() + 1 << area.bottom() + FRAME_WIDTH;
glVertex2i( area.left() - FRAME_WIDTH, area.bottom() + 1 ); // bottom frame verts << area.right() + 1 << area.bottom() + FRAME_WIDTH;
glVertex2i( area.right() + FRAME_WIDTH, area.bottom() + 1 ); verts << area.right() + FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
glVertex2i( area.right() + FRAME_WIDTH, area.bottom() + FRAME_WIDTH ); verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
glVertex2i( area.left() - FRAME_WIDTH, area.bottom() + FRAME_WIDTH ); // bottom frame
glEnd(); verts << area.right() + FRAME_WIDTH << area.bottom() + 1;
} verts << area.left() - FRAME_WIDTH << area.bottom() + 1;
glPopAttrib(); verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
} verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
#endif verts << area.right() + FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
verts << area.right() + FRAME_WIDTH << area.bottom() + 1;
vbo->setData(verts.size()/2, 2, verts.constData(), NULL);
if (ShaderManager::instance()->isValid()) {
ShaderManager::instance()->pushShader(ShaderManager::ColorShader);
}
vbo->render(GL_TRIANGLES);
if (ShaderManager::instance()->isValid()) {
ShaderManager::instance()->popShader();
}
} }
} }