From 17032c66f8dfb53d2352b6364dabb32b21e7d166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 11 Dec 2010 15:56:21 +0100 Subject: [PATCH] SnapHelper uses shared VBO --- effects/snaphelper/snaphelper.cpp | 25 +++++++------------------ effects/snaphelper/snaphelper.h | 5 ----- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/effects/snaphelper/snaphelper.cpp b/effects/snaphelper/snaphelper.cpp index 932d519edb..044bf96f53 100644 --- a/effects/snaphelper/snaphelper.cpp +++ b/effects/snaphelper/snaphelper.cpp @@ -32,21 +32,9 @@ KWIN_EFFECT_SUPPORTED( snaphelper, SnapHelperEffect::supported() ) SnapHelperEffect::SnapHelperEffect() : m_active( false ) , m_window( NULL ) -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - , m_vbo( 0 ) -#endif { m_timeline.setCurveShape( TimeLine::LinearCurve ); reconfigure( ReconfigureAll ); -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - if (effects->compositingType() == OpenGLCompositing) { - m_vbo = new GLVertexBuffer(GLVertexBuffer::Stream); - m_vbo->setUseColor(true); - if (ShaderManager::instance()->isValid()) { - m_vbo->setUseShader(true); - } - } -#endif /*if( effects->compositingType() == XRenderCompositing ) { @@ -61,9 +49,6 @@ SnapHelperEffect::~SnapHelperEffect() { //if( effects->compositingType() == XRenderCompositing ) // XFreeGC( display(), m_gc ); -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - delete m_vbo; -#endif } void SnapHelperEffect::reconfigure( ReconfigureFlags ) @@ -98,8 +83,12 @@ void SnapHelperEffect::postPaintScreen() #ifndef KWIN_HAVE_OPENGLES glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT ); #endif + GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); + vbo->reset(); + vbo->setUseColor(true); if (ShaderManager::instance()->isValid()) { ShaderManager::instance()->pushShader(ShaderManager::ColorShader); + vbo->setUseShader(true); } glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); @@ -109,7 +98,7 @@ void SnapHelperEffect::postPaintScreen() color.setGreenF(0.5); color.setBlueF(0.5); color.setAlphaF(m_timeline.value() * 0.5); - m_vbo->setColor(color); + vbo->setColor(color); glLineWidth( 4.0 ); QVector verts; verts.reserve(effects->numScreens()*24); @@ -137,8 +126,8 @@ void SnapHelperEffect::postPaintScreen() verts << midX - halfWidth << midY + halfHeight - 2; verts << midX - halfWidth << midY - halfHeight - 2; } - m_vbo->setData(verts.count()/2, 2, verts.data(), NULL); - m_vbo->render(GL_LINES); + vbo->setData(verts.count()/2, 2, verts.data(), NULL); + vbo->render(GL_LINES); if (ShaderManager::instance()->isValid()) { ShaderManager::instance()->popShader(); } diff --git a/effects/snaphelper/snaphelper.h b/effects/snaphelper/snaphelper.h index 347baf8262..c5ed6e8ca2 100644 --- a/effects/snaphelper/snaphelper.h +++ b/effects/snaphelper/snaphelper.h @@ -25,8 +25,6 @@ along with this program. If not, see . namespace KWin { -class GLShader; -class GLVertexBuffer; class SnapHelperEffect : public Effect @@ -49,9 +47,6 @@ class SnapHelperEffect EffectWindow* m_window; TimeLine m_timeline; //GC m_gc; -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - GLVertexBuffer *m_vbo; -#endif }; } // namespace