Cache window quads since they usually don't change and this gives

few fps.


svn path=/trunk/KDE/kdebase/workspace/; revision=787978
This commit is contained in:
Luboš Luňák 2008-03-20 11:17:50 +00:00
parent 113b9853b3
commit 1927a283b3
3 changed files with 25 additions and 5 deletions

View file

@ -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 + - 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) - 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 ! - 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())

View file

@ -316,11 +316,13 @@ Scene::Window::Window( Toplevel * c )
, filter( ImageFilterFast ) , filter( ImageFilterFast )
, disable_painting( 0 ) , disable_painting( 0 )
, shape_valid( false ) , shape_valid( false )
, cached_quad_list( NULL )
{ {
} }
Scene::Window::~Window() Scene::Window::~Window()
{ {
delete cached_quad_list;
} }
void Scene::Window::discardShape() void Scene::Window::discardShape()
@ -328,6 +330,8 @@ void Scene::Window::discardShape()
// it is created on-demand and cached, simply // it is created on-demand and cached, simply
// reset the flag // reset the flag
shape_valid = false; shape_valid = false;
delete cached_quad_list;
cached_quad_list = NULL;
} }
// Find out the shape of the window using the XShape extension // 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 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()) if( toplevel->clientPos() == QPoint( 0, 0 ) && toplevel->clientSize() == toplevel->size())
return makeQuads( WindowQuadContents, shape()); // has no decoration ret = makeQuads( WindowQuadContents, shape()); // has no decoration
QRegion contents = shape() & QRect( toplevel->clientPos(), toplevel->clientSize()); else
QRegion decoration = shape() - contents; {
WindowQuadList ret = makeQuads( WindowQuadContents, contents ); QRegion contents = shape() & QRect( toplevel->clientPos(), toplevel->clientSize());
ret += makeQuads( WindowQuadDecoration, decoration ); QRegion decoration = shape() - contents;
ret = makeQuads( WindowQuadContents, contents );
ret += makeQuads( WindowQuadDecoration, decoration );
}
cached_quad_list = new WindowQuadList( ret );
return ret; return ret;
} }

View file

@ -190,6 +190,7 @@ class Scene::Window
int disable_painting; int disable_painting;
mutable QRegion shape_region; mutable QRegion shape_region;
mutable bool shape_valid; mutable bool shape_valid;
mutable WindowQuadList* cached_quad_list;
Q_DISABLE_COPY(Window) Q_DISABLE_COPY(Window)
}; };