From 8d196da880fe183e327878788a3f47d6b1b0e3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 1 Jan 2011 17:49:51 +0100 Subject: [PATCH] Render empty areas in multiscreen with VBO. --- effects/cube/cube.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index cd0f16f92f..03a3fe83f7 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -1712,7 +1712,6 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP } paint = paint.subtracted( QRegion( w->geometry())); // in case of free area in multiscreen setup fill it with cap color -#ifndef KWIN_HAVE_OPENGLES if( !paint.isEmpty() ) { if( mode == Cylinder ) @@ -1726,11 +1725,12 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP sphereShader->setUniform( "xCoord", 0.0f ); sphereShader->setUniform( "yCoord", 0.0f ); } - glColor4f( capColor.redF(), capColor.greenF(), capColor.blueF(), cubeOpacity ); +#ifndef KWIN_HAVE_OPENGLES glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT ); +#endif glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glBegin( GL_QUADS ); + QVector verts; float quadSize = 0.0f; int leftDesktop = frontDesktop -1; int rightDesktop = frontDesktop + 1; @@ -1750,21 +1750,27 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP { for( int j=0; j<=(paintRect.width()/quadSize); j++ ) { - glVertex2f( paintRect.x()+j*quadSize, paintRect.y()+i*quadSize ); - glVertex2f( qMin( paintRect.x()+(j+1)*quadSize, (float)paintRect.x() + paintRect.width() ), - paintRect.y()+i*quadSize ); - glVertex2f( qMin( paintRect.x()+(j+1)*quadSize, (float)paintRect.x() + paintRect.width() ), - qMin( paintRect.y() + (i+1)*quadSize, (float)paintRect.y() + paintRect.height() ) ); - glVertex2f( paintRect.x()+j*quadSize, - qMin( paintRect.y() + (i+1)*quadSize, (float)paintRect.y() + paintRect.height() ) ); + verts << qMin( paintRect.x()+(j+1)*quadSize, (float)paintRect.x() + paintRect.width() ) << paintRect.y()+i*quadSize; + verts << paintRect.x()+j*quadSize << paintRect.y()+i*quadSize; + verts << paintRect.x()+j*quadSize << qMin( paintRect.y() + (i+1)*quadSize, (float)paintRect.y() + paintRect.height() ); + verts << paintRect.x()+j*quadSize << qMin( paintRect.y() + (i+1)*quadSize, (float)paintRect.y() + paintRect.height() ); + verts << qMin( paintRect.x()+(j+1)*quadSize, (float)paintRect.x() + paintRect.width() ) << qMin( paintRect.y() + (i+1)*quadSize, (float)paintRect.y() + paintRect.height() ); + verts << qMin( paintRect.x()+(j+1)*quadSize, (float)paintRect.x() + paintRect.width() ) << paintRect.y()+i*quadSize; } } } - glEnd(); + GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); + vbo->reset(); + QColor color = capColor; + capColor.setAlphaF(cubeOpacity); + vbo->setColor(color); + vbo->setData(verts.size()/2, 2, verts.constData(), NULL); + vbo->render(GL_TRIANGLES); glDisable( GL_BLEND ); +#ifndef KWIN_HAVE_OPENGLES glPopAttrib(); - } #endif + } } #ifndef KWIN_HAVE_OPENGLES glPopMatrix();