GLTexture::render(), to render to a given QRect

svn path=/branches/work/kwin_composite/; revision=656521
This commit is contained in:
Luboš Luňák 2007-04-21 16:12:03 +00:00
parent cd98bc12d5
commit ffc75a2214
5 changed files with 30 additions and 53 deletions

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();

View file

@ -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

View file

@ -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();