From f77561ce65f154219a3046dbf27390ccc269c234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 20 Mar 2008 10:05:41 +0000 Subject: [PATCH] Don't discard window texture when only the shape changes but the window geometry actually stays the same. Avoids large number of rebinds (with no strict binding) with the launch feedback icon. svn path=/trunk/KDE/kdebase/workspace/; revision=787948 --- lib/kwinglutils.cpp | 5 +++++ lib/kwinglutils.h | 1 + scene_opengl.cpp | 14 +++++++++++++- scene_opengl.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index 0d047ce4fb..4b70830b3f 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -394,6 +394,11 @@ bool GLTexture::isNull() const return mTexture == None; } +QSize GLTexture::size() const + { + return mSize; + } + bool GLTexture::load( const QImage& image, GLenum target ) { if( image.isNull()) diff --git a/lib/kwinglutils.h b/lib/kwinglutils.h index 96ed9037c7..6c43d08cc4 100644 --- a/lib/kwinglutils.h +++ b/lib/kwinglutils.h @@ -113,6 +113,7 @@ class KWIN_EXPORT GLTexture virtual ~GLTexture(); bool isNull() const; + QSize size() const; virtual bool load( const QImage& image, GLenum target = GL_TEXTURE_2D ); virtual bool load( const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D ); diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 821b36071e..f13c9f091e 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -781,7 +781,7 @@ void SceneOpenGL::windowGeometryShapeChanged( Toplevel* c ) return; // by default Window* w = windows[ c ]; w->discardShape(); - w->discardTexture(); + w->checkTextureSize(); } void SceneOpenGL::windowOpacityChanged( Toplevel* ) @@ -1159,6 +1159,18 @@ void SceneOpenGL::Window::discardTexture() texture.discard(); } +// This call is used in SceneOpenGL::windowGeometryShapeChanged(), +// which originally called discardTexture(), however this was causing performance +// problems with the launch feedback icon - large number of texture rebinds. +// Since the launch feedback icon does not resize, only changes shape, it +// is not necessary to rebind the texture (with no strict binding), therefore +// discard the texture only if size changes. +void SceneOpenGL::Window::checkTextureSize() + { + if( texture.size() != size()) + discardTexture(); + } + // when the window's composite pixmap is discarded, undo binding it to the texture void SceneOpenGL::Window::pixmapDiscarded() { diff --git a/scene_opengl.h b/scene_opengl.h index 92afe0f7c2..401ff4aca5 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -132,6 +132,7 @@ class SceneOpenGL::Window virtual void pixmapDiscarded(); bool bindTexture(); void discardTexture(); + void checkTextureSize(); protected: void renderQuads( int mask, const QRegion& region, const WindowQuadList& quads );