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( flipswitch/CMakeLists.txt )
include( glide/CMakeLists.txt )
include( magnifier/CMakeLists.txt )
include( mousemark/CMakeLists.txt )
include( screenshot/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( invert/CMakeLists.txt )
include( lookingglass/CMakeLists.txt )
include( magnifier/CMakeLists.txt )
include( sharpen/CMakeLists.txt )
include( snow/CMakeLists.txt )
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 "flipswitch/flipswitch_config.h"
#include "glide/glide_config.h"
#include "magnifier/magnifier_config.h"
#include "mousemark/mousemark_config.h"
#include "trackmouse/trackmouse_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 "invert/invert_config.h"
#include "lookingglass/lookingglass_config.h"
#include "magnifier/magnifier_config.h"
#include "sharpen/sharpen_config.h"
#include "snow/snow_config.h"
#endif
@ -86,6 +86,7 @@ KWIN_EFFECT_CONFIG_MULTIPLE( builtins,
KWIN_EFFECT_CONFIG_SINGLE( cubeslide, CubeSlideEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( flipswitch, FlipSwitchEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( glide, GlideEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( magnifier, MagnifierEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( mousemark, MouseMarkEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( trackmouse, TrackMouseEffectConfig )
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( invert, InvertEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( lookingglass, LookingGlassEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( magnifier, MagnifierEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( sharpen, SharpenEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( snow, SnowEffectConfig )
#endif

View file

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