From 6cb3b95cc19b6e6d4b94be4bd6171cb516d66a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 11 Dec 2010 15:58:52 +0100 Subject: [PATCH] ResizeEffect uses shared VBO --- effects/resize/resize.cpp | 25 +++++++------------------ effects/resize/resize.h | 4 ---- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/effects/resize/resize.cpp b/effects/resize/resize.cpp index 775246d42b..c195d0a945 100644 --- a/effects/resize/resize.cpp +++ b/effects/resize/resize.cpp @@ -38,27 +38,12 @@ KWIN_EFFECT( resize, ResizeEffect ) ResizeEffect::ResizeEffect() : m_active( false ) , m_resizeWindow( 0 ) -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - , m_vbo( 0 ) -#endif { 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 } ResizeEffect::~ResizeEffect() { -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - delete m_vbo; -#endif } void ResizeEffect::prePaintScreen( ScreenPrePaintData& data, int time ) @@ -104,13 +89,17 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo #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 ); color.setAlphaF(alpha); - m_vbo->setColor(color); + vbo->setColor(color); QVector verts; verts.reserve(paintRegion.rects().count()*12); foreach( const QRect &r, paintRegion.rects() ) { @@ -121,8 +110,8 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo verts << r.x() + r.width() << r.y() + r.height(); verts << r.x() + r.width() << r.y(); } - m_vbo->setData(verts.count()/2, 2, verts.data(), NULL); - m_vbo->render(GL_TRIANGLES); + vbo->setData(verts.count()/2, 2, verts.data(), NULL); + vbo->render(GL_TRIANGLES); if (ShaderManager::instance()->isValid()) { ShaderManager::instance()->popShader(); } diff --git a/effects/resize/resize.h b/effects/resize/resize.h index b44c5627d1..9575fbcd20 100644 --- a/effects/resize/resize.h +++ b/effects/resize/resize.h @@ -25,7 +25,6 @@ along with this program. If not, see . namespace KWin { -class GLVertexBuffer; class ResizeEffect : public Effect @@ -47,9 +46,6 @@ class ResizeEffect int m_features; EffectWindow* m_resizeWindow; QRect m_currentGeometry, m_originalGeometry; -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - GLVertexBuffer *m_vbo; -#endif }; }