summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Nieminen <ext-pauli.nieminen@nokia.com>2010-12-30 19:19:34 +0200
committerDaniel Stone <daniel@fooishbar.org>2010-12-31 12:52:51 +0000
commitc038b8b28e5c436cd31bea7a3bef2c8c9d818b58 (patch)
treeb7cb940c880b4b39453dab9a9fda7f26f07980e3
parent6d0e9e5d6e1b847961ab52a11aae96981a1cf1c0 (diff)
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>
-rw-r--r--composite/compalloc.c37
-rw-r--r--composite/compinit.c33
2 files changed, 37 insertions, 33 deletions
diff --git a/composite/compalloc.c b/composite/compalloc.c
index 93571eef9..e628c45bd 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -48,6 +48,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)
{
WindowPtr pWin = (WindowPtr) 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;
}
diff --git a/composite/compinit.c b/composite/compinit.c
index 159f7c2cc..885cc73a6 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -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;