From 1927a283b3a8a0549560675e5b1628a6c891b979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 20 Mar 2008 11:17:50 +0000 Subject: [PATCH] Cache window quads since they usually don't change and this gives few fps. svn path=/trunk/KDE/kdebase/workspace/; revision=787978 --- COMPOSITE_TODO | 8 ++++++++ scene.cpp | 21 ++++++++++++++++----- scene.h | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/COMPOSITE_TODO b/COMPOSITE_TODO index 5e80a5b749..a318cdfdbd 100644 --- a/COMPOSITE_TODO +++ b/COMPOSITE_TODO @@ -232,3 +232,11 @@ Effects TODO + - there's a bug that causes overlapping windows be shown also on desktops painted sooner than the window's desktop - needs clipping (and that probably needs support for cumulating clipping) ! - make desktop borders distinctive (i.e. paint a grid), to make it more visible that desktops are still separate + + +Performance +================== + ++ various caching - there are many things that usually don't change and could gain few fps (is it worth it?) + - Workspace::performCompositing() + - WindowQuadList could perhaps cache quads split by contents/decoration (for select()) diff --git a/scene.cpp b/scene.cpp index 056223a87a..a67a7efb11 100644 --- a/scene.cpp +++ b/scene.cpp @@ -316,11 +316,13 @@ Scene::Window::Window( Toplevel * c ) , filter( ImageFilterFast ) , disable_painting( 0 ) , shape_valid( false ) + , cached_quad_list( NULL ) { } Scene::Window::~Window() { + delete cached_quad_list; } void Scene::Window::discardShape() @@ -328,6 +330,8 @@ void Scene::Window::discardShape() // it is created on-demand and cached, simply // reset the flag shape_valid = false; + delete cached_quad_list; + cached_quad_list = NULL; } // Find out the shape of the window using the XShape extension @@ -415,12 +419,19 @@ void Scene::Window::disablePainting( int reason ) WindowQuadList Scene::Window::buildQuads() const { + if( cached_quad_list != NULL ) + return *cached_quad_list; + WindowQuadList ret; if( toplevel->clientPos() == QPoint( 0, 0 ) && toplevel->clientSize() == toplevel->size()) - return makeQuads( WindowQuadContents, shape()); // has no decoration - QRegion contents = shape() & QRect( toplevel->clientPos(), toplevel->clientSize()); - QRegion decoration = shape() - contents; - WindowQuadList ret = makeQuads( WindowQuadContents, contents ); - ret += makeQuads( WindowQuadDecoration, decoration ); + ret = makeQuads( WindowQuadContents, shape()); // has no decoration + else + { + QRegion contents = shape() & QRect( toplevel->clientPos(), toplevel->clientSize()); + QRegion decoration = shape() - contents; + ret = makeQuads( WindowQuadContents, contents ); + ret += makeQuads( WindowQuadDecoration, decoration ); + } + cached_quad_list = new WindowQuadList( ret ); return ret; } diff --git a/scene.h b/scene.h index 870ec32a67..084bcbee96 100644 --- a/scene.h +++ b/scene.h @@ -190,6 +190,7 @@ class Scene::Window int disable_painting; mutable QRegion shape_region; mutable bool shape_valid; + mutable WindowQuadList* cached_quad_list; Q_DISABLE_COPY(Window) };