composite: Only register the block handler when it is required

Even calling block handler that doesn't do much is costly in arm. It
takes a few microseconds each time which adds up to relative high CPU
time because it is done 500+ times per second.

Simple optimization is to register the block handler only when it is
required.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Pauli Nieminen 2010-12-30 19:19:34 +02:00 committed by Daniel Stone
parent 6d0e9e5d6e
commit c038b8b28e
2 changed files with 37 additions and 33 deletions

View File

@ -47,6 +47,36 @@
#include "compint.h"
static void
compScreenUpdate (ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen (pScreen);
compCheckTree (pScreen);
if (cs->damaged)
{
compWindowUpdate (pScreen->root);
cs->damaged = FALSE;
}
}
static void
compBlockHandler (int i,
pointer blockData,
pointer pTimeout,
pointer pReadmask)
{
ScreenPtr pScreen = screenInfo.screens[i];
CompScreenPtr cs = GetCompScreen (pScreen);
pScreen->BlockHandler = cs->BlockHandler;
compScreenUpdate (pScreen);
(*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
/* Next damage will restore the block handler */
cs->BlockHandler = NULL;
}
static void
compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
{
@ -55,7 +85,12 @@ compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
CompScreenPtr cs = GetCompScreen (pScreen);
CompWindowPtr cw = GetCompWindow (pWin);
cs->damaged = TRUE;
if (!cs->damaged) {
cs->BlockHandler = pScreen->BlockHandler;
pScreen->BlockHandler = compBlockHandler;
cs->damaged = TRUE;
}
cw->damaged = TRUE;
}

View File

@ -61,7 +61,6 @@ compCloseScreen (int index, ScreenPtr pScreen)
free(cs->alternateVisuals);
pScreen->CloseScreen = cs->CloseScreen;
pScreen->BlockHandler = cs->BlockHandler;
pScreen->InstallColormap = cs->InstallColormap;
pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
pScreen->ReparentWindow = cs->ReparentWindow;
@ -130,35 +129,6 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
return ret;
}
static void
compScreenUpdate (ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen (pScreen);
compCheckTree (pScreen);
if (cs->damaged)
{
compWindowUpdate (pScreen->root);
cs->damaged = FALSE;
}
}
static void
compBlockHandler (int i,
pointer blockData,
pointer pTimeout,
pointer pReadmask)
{
ScreenPtr pScreen = screenInfo.screens[i];
CompScreenPtr cs = GetCompScreen (pScreen);
pScreen->BlockHandler = cs->BlockHandler;
compScreenUpdate (pScreen);
(*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
cs->BlockHandler = pScreen->BlockHandler;
pScreen->BlockHandler = compBlockHandler;
}
/*
* Add alternate visuals -- always expose an ARGB32 and RGB24 visual
*/
@ -387,8 +357,7 @@ compScreenInit (ScreenPtr pScreen)
cs->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
pScreen->ChangeWindowAttributes = compChangeWindowAttributes;
cs->BlockHandler = pScreen->BlockHandler;
pScreen->BlockHandler = compBlockHandler;
cs->BlockHandler = NULL;
cs->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = compCloseScreen;