[PATCH xserver 1/2] dix: Call screen block/wakeup handlers closest to blocking

Keith Packard keithp at keithp.com
Fri Nov 13 08:37:43 PST 2015


The screen block and wakeup handlers are the only ones which provide a
well known ordering between the wrapping layers; placing these as
close as possible to the server blocking provides a way for the driver
to control the flow of execution correctly.

Switch the shadow code to run in the screen block handler so that it
now occurrs just before the server goes to sleep.

Switch glamor to call down to the driver after it has executed its own
block handler piece, in case the driver needs to perform additional
flushing work after glamor has called glFlush.

These changes ensure that the following modules update the screen in
the correct order:

animated cursors        (uses RegisterBlockAndWakeupHandlers dynamically)
composite               (dynamic wrapping)
misprite                (dynamic wrapping)
shadow                  (static wrapping)
glamor                  (static wrapping)
driver                  (static wrapping)

It looks like there's still a bit of confusion between composite and
misprite; if composite updates after misprite, then it's possible
you'd exit the block handler chain with the cursor left hidden. To fix
that, misprite should be wrapping during ScreenInit time and not
unwrapping. And composite might as well join in that fun, just to make
things consistent.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 dix/dixutils.c        | 16 ++++++++--------
 glamor/glamor.c       |  6 +++---
 miext/shadow/shadow.c | 19 ++++++-------------
 miext/shadow/shadow.h |  1 +
 4 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/dix/dixutils.c b/dix/dixutils.c
index 214b9a8..1829459 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -383,15 +383,15 @@ BlockHandler(void *timeout)
     int i, j;
 
     ++inHandler;
-    for (i = 0; i < screenInfo.numScreens; i++)
-        (*screenInfo.screens[i]->BlockHandler) (screenInfo.screens[i], timeout);
+    for (i = 0; i < numHandlers; i++)
+        if (!handlers[i].deleted)
+            (*handlers[i].BlockHandler) (handlers[i].blockData, timeout);
 
     for (i = 0; i < screenInfo.numGPUScreens; i++)
         (*screenInfo.gpuscreens[i]->BlockHandler) (screenInfo.gpuscreens[i], timeout);
 
-    for (i = 0; i < numHandlers; i++)
-        if (!handlers[i].deleted)
-            (*handlers[i].BlockHandler) (handlers[i].blockData, timeout);
+    for (i = 0; i < screenInfo.numScreens; i++)
+        (*screenInfo.screens[i]->BlockHandler) (screenInfo.screens[i], timeout);
 
     if (handlerDeleted) {
         for (i = 0; i < numHandlers;)
@@ -418,13 +418,13 @@ WakeupHandler(int result)
     int i, j;
 
     ++inHandler;
-    for (i = numHandlers - 1; i >= 0; i--)
-        if (!handlers[i].deleted)
-            (*handlers[i].WakeupHandler) (handlers[i].blockData, result);
     for (i = 0; i < screenInfo.numScreens; i++)
         (*screenInfo.screens[i]->WakeupHandler) (screenInfo.screens[i], result);
     for (i = 0; i < screenInfo.numGPUScreens; i++)
         (*screenInfo.gpuscreens[i]->WakeupHandler) (screenInfo.gpuscreens[i], result);
+    for (i = numHandlers - 1; i >= 0; i--)
+        if (!handlers[i].deleted)
+            (*handlers[i].WakeupHandler) (handlers[i].blockData, result);
     if (handlerDeleted) {
         for (i = 0; i < numHandlers;)
             if (handlers[i].deleted) {
diff --git a/glamor/glamor.c b/glamor/glamor.c
index ce64d76..5e9f823 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -236,13 +236,13 @@ _glamor_block_handler(ScreenPtr screen, void *timeout)
 {
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 
+    glamor_make_current(glamor_priv);
+    glFlush();
+
     screen->BlockHandler = glamor_priv->saved_procs.block_handler;
     screen->BlockHandler(screen, timeout);
     glamor_priv->saved_procs.block_handler = screen->BlockHandler;
     screen->BlockHandler = _glamor_block_handler;
-
-    glamor_make_current(glamor_priv);
-    glFlush();
 }
 
 static void
diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c
index 0759298..e4a3236 100644
--- a/miext/shadow/shadow.c
+++ b/miext/shadow/shadow.c
@@ -65,16 +65,15 @@ shadowRedisplay(ScreenPtr pScreen)
 }
 
 static void
-shadowBlockHandler(void *data, void *timeout)
+shadowBlockHandler(ScreenPtr pScreen, void *timeout)
 {
-    ScreenPtr pScreen = (ScreenPtr) data;
+    shadowBuf(pScreen);
 
     shadowRedisplay(pScreen);
-}
 
-static void
-shadowWakeupHandler(void *data, int result)
-{
+    unwrap(pBuf, pScreen, BlockHandler);
+    pScreen->BlockHandler(pScreen, timeout);
+    wrap(pBuf, pScreen, BlockHandler);
 }
 
 static void
@@ -132,6 +131,7 @@ shadowSetup(ScreenPtr pScreen)
 
     wrap(pBuf, pScreen, CloseScreen);
     wrap(pBuf, pScreen, GetImage);
+    wrap(pBuf, pScreen, BlockHandler);
     pBuf->update = 0;
     pBuf->window = 0;
     pBuf->pPixmap = 0;
@@ -148,10 +148,6 @@ shadowAdd(ScreenPtr pScreen, PixmapPtr pPixmap, ShadowUpdateProc update,
 {
     shadowBuf(pScreen);
 
-    if (!RegisterBlockAndWakeupHandlers(shadowBlockHandler, shadowWakeupHandler,
-                                        (void *) pScreen))
-        return FALSE;
-
     /*
      * Map simple rotation values to bitmasks; fortunately,
      * these are all unique
@@ -192,7 +188,4 @@ shadowRemove(ScreenPtr pScreen, PixmapPtr pPixmap)
         pBuf->closure = 0;
         pBuf->pPixmap = 0;
     }
-
-    RemoveBlockAndWakeupHandlers(shadowBlockHandler, shadowWakeupHandler,
-                                 (void *) pScreen);
 }
diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h
index 86fa944..7f22169 100644
--- a/miext/shadow/shadow.h
+++ b/miext/shadow/shadow.h
@@ -54,6 +54,7 @@ typedef struct _shadowBuf {
     /* screen wrappers */
     GetImageProcPtr GetImage;
     CloseScreenProcPtr CloseScreen;
+    ScreenBlockHandlerProcPtr BlockHandler;
 } shadowBufRec;
 
 /* Match defines from randr extension */
-- 
2.6.1



More information about the xorg-devel mailing list