Commit c038b8b2 authored by Pauli Nieminen's avatar Pauli Nieminen Committed by Daniel Stone
Browse files

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: default avatarPauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Daniel Stone's avatarDaniel Stone <daniel@fooishbar.org>
parent 6d0e9e5d
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment