diff --git a/effects/demo_showpicture.cpp b/effects/demo_showpicture.cpp index b630e75767..64796e4d09 100644 --- a/effects/demo_showpicture.cpp +++ b/effects/demo_showpicture.cpp @@ -44,25 +44,7 @@ void ShowPictureEffect::paintScreen( int mask, QRegion region, ScreenPaintData& picture->bind(); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - int x = pictureRect.x(); - int y = pictureRect.y(); - int width = pictureRect.width(); - int height = pictureRect.height(); - const float verts[ 4 * 2 ] = - { - x, y, - x, y + height, - x + width, y + height, - x + width, y - }; - const float texcoords[ 4 * 2 ] = - { - 0, 1, - 0, 0, - 1, 0, - 1, 1 - }; - renderGLGeometry( mask, region, verts, texcoords, 4 ); + picture->render( mask, region, pictureRect ); picture->unbind(); glPopAttrib(); } diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 29dd361279..dbbe0bf28e 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -127,25 +127,7 @@ void PresentWindowsEffect::paintScreen( int mask, QRegion region, ScreenPaintDat filterTexture->bind(); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - int x = filterTextureRect.x(); - int y = filterTextureRect.y(); - int width = filterTextureRect.width(); - int height = filterTextureRect.height(); - const float verts[ 4 * 2 ] = - { - x, y, - x, y + height, - x + width, y + height, - x + width, y - }; - const float texcoords[ 4 * 2 ] = - { - 0, 1, - 0, 0, - 1, 0, - 1, 1 - }; - renderGLGeometry( mask, region, verts, texcoords, 4 ); + filterTexture->render( mask, region, filterTextureRect ); filterTexture->unbind(); glPopAttrib(); } diff --git a/effects/trackmouse.cpp b/effects/trackmouse.cpp index 7a8cada15d..c2cf2250b2 100644 --- a/effects/trackmouse.cpp +++ b/effects/trackmouse.cpp @@ -67,21 +67,7 @@ void TrackMouseEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d ++i ) { QRect r = starRect( i ); - const float verts[ 4 * 2 ] = - { - r.x(), r.y(), - r.x(), r.y() + r.height(), - r.x() + r.width(), r.y() + r.height(), - r.x() + r.width(), r.y() - }; - const float texcoords[ 4 * 2 ] = - { - 0, 1, - 0, 0, - 1, 0, - 1, 1 - }; - renderGLGeometry( mask, region, verts, texcoords, 4 ); + texture->render( mask, region, r ); } texture->unbind(); glPopAttrib(); diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index bbdabc70f0..e1d41b27e5 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -315,6 +315,31 @@ void GLTexture::unbind() glDisable( mTarget ); } +void GLTexture::render( int mask, QRegion region, const QRect& rect ) + { + return render( !( mask & ( Effect::PAINT_WINDOW_TRANSFORMED | Effect::PAINT_SCREEN_TRANSFORMED )), + region, rect ); + } + +void GLTexture::render( bool clip, QRegion region, const QRect& rect ) + { + const float verts[ 4 * 2 ] = + { + rect.x(), rect.y(), + rect.x(), rect.y() + rect.height(), + rect.x() + rect.width(), rect.y() + rect.height(), + rect.x() + rect.width(), rect.y() + }; + const float texcoords[ 4 * 2 ] = + { + 0, 1, + 0, 0, + 1, 0, + 1, 1 + }; + renderGLGeometry( clip, region, verts, texcoords, 4 ); + } + void GLTexture::enableUnnormalizedTexCoords() { // update texture matrix to handle GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE diff --git a/lib/kwinglutils.h b/lib/kwinglutils.h index 8531b2f621..8f0216ac11 100644 --- a/lib/kwinglutils.h +++ b/lib/kwinglutils.h @@ -87,6 +87,8 @@ class KWIN_EXPORT GLTexture virtual void discard(); virtual void bind(); virtual void unbind(); + void render( bool clip, QRegion region, const QRect& rect ); + void render( int mask, QRegion region, const QRect& rect ); void enableUnnormalizedTexCoords(); void disableUnnormalizedTexCoords();