xserver: Branch 'master'

Aaron Plattner aplattner at kemper.freedesktop.org
Wed Aug 9 04:42:58 EEST 2006


 composite/compinit.c   |   46 ++++++++++++++++++++++++++++++++++++++++++----
 composite/compint.h    |   13 ++++++-------
 composite/compwindow.c |    2 +-
 3 files changed, 49 insertions(+), 12 deletions(-)

New commits:
diff-tree 462bb61b0fe968fae1b99cf98ec6f7de09105dcd (from 12dbd8a02f797ad57a1be683a02a1fcb1ca35438)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Aug 8 18:07:22 2006 -0700

    Add CompositeRegisterAlternateVisuals.
    
    This provides drivers the ability to add their own alternate visuals and then
    register them with Composite for implicit redirection.

diff --git a/composite/compinit.c b/composite/compinit.c
index 5a13612..1d5cc7b 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -60,6 +60,8 @@ compCloseScreen (int index, ScreenPtr pS
     CompScreenPtr   cs = GetCompScreen (pScreen);
     Bool	    ret;
 
+    xfree (cs->alternateVisuals);
+
     pScreen->CloseScreen = cs->CloseScreen;
     pScreen->BlockHandler = cs->BlockHandler;
     pScreen->InstallColormap = cs->InstallColormap;
@@ -100,7 +102,7 @@ compInstallColormap (ColormapPtr pColorm
     CompScreenPtr   cs = GetCompScreen (pScreen);
     int		    a;
 
-    for (a = 0; a < NUM_COMP_ALTERNATE_VISUALS; a++)
+    for (a = 0; a < cs->numAlternateVisuals; a++)
 	if (pVisual->vid == cs->alternateVisuals[a])
 	    return;
     pScreen->InstallColormap = cs->InstallColormap;
@@ -170,6 +172,41 @@ compFindVisuallessDepth (ScreenPtr pScre
     return 0;
 }
 
+/*
+ * Add a list of visual IDs to the list of visuals to implicitly redirect.
+ */
+static Bool
+compRegisterAlternateVisuals (CompScreenPtr cs, VisualID *vids, int nVisuals)
+{
+    VisualID *p;
+
+    p = xrealloc(cs->alternateVisuals,
+		 sizeof(VisualID) * (cs->numAlternateVisuals + nVisuals));
+    if(p == NULL)
+	return FALSE;
+
+    memcpy(&p[cs->numAlternateVisuals], vids, sizeof(VisualID) * nVisuals);
+
+    cs->alternateVisuals = p;
+    cs->numAlternateVisuals += nVisuals;
+
+    return TRUE;
+}
+
+_X_EXPORT
+Bool CompositeRegisterAlternateVisuals (ScreenPtr pScreen, VisualID *vids,
+					int nVisuals)
+{
+    CompScreenPtr cs = GetCompScreen (pScreen);
+    return compRegisterAlternateVisuals(cs, vids, nVisuals);
+}
+
+#if COMP_INCLUDE_RGB24_VISUAL
+#define NUM_COMP_ALTERNATE_VISUALS 2
+#else
+#define NUM_COMP_ALTERNATE_VISUALS 1
+#endif
+
 typedef struct _alternateVisual {
     int		depth;
     CARD32	format;
@@ -197,8 +234,6 @@ compAddAlternateVisuals (ScreenPtr pScre
     int		    numAlternate = 0;
     int		    alt;
     
-    memset (cs->alternateVisuals, '\0', sizeof (cs->alternateVisuals));
-
     for (alt = 0; alt < NUM_COMP_ALTERNATE_VISUALS; alt++)
     {
 	DepthPtr	depth;
@@ -321,7 +356,7 @@ compAddAlternateVisuals (ScreenPtr pScre
 	/*
 	 * remember the visual ID to detect auto-update windows
 	 */
-	cs->alternateVisuals[alt] = visual->vid;
+	compRegisterAlternateVisuals(cs, &visual->vid, 1);
 	
 	/*
 	 * Fix up the depth
@@ -367,6 +402,9 @@ compScreenInit (ScreenPtr pScreen)
     cs->pOverlayWin = NULL;
     cs->pOverlayClients = NULL;
 
+    cs->numAlternateVisuals = 0;
+    cs->alternateVisuals = NULL;
+
     if (!compAddAlternateVisuals (pScreen, cs))
     {
 	xfree (cs);
diff --git a/composite/compint.h b/composite/compint.h
index 9395512..3958b3b 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -109,12 +109,6 @@ typedef struct _CompSubwindows {
 #define COMP_INCLUDE_RGB24_VISUAL 0
 #endif
 
-#if COMP_INCLUDE_RGB24_VISUAL
-#define NUM_COMP_ALTERNATE_VISUALS  2
-#else
-#define NUM_COMP_ALTERNATE_VISUALS  1
-#endif
-
 typedef struct _CompOverlayClientRec *CompOverlayClientPtr;
 
 typedef struct _CompOverlayClientRec {
@@ -154,7 +148,8 @@ typedef struct _CompScreen {
     ScreenBlockHandlerProcPtr	BlockHandler;
     CloseScreenProcPtr		CloseScreen;
     Bool			damaged;
-    XID				alternateVisuals[NUM_COMP_ALTERNATE_VISUALS];
+    int				numAlternateVisuals;
+    VisualID			*alternateVisuals;
 
     WindowPtr                   pOverlayWin;
     CompOverlayClientPtr        pOverlayClients;
@@ -225,6 +220,10 @@ CompositeExtensionInit (void);
  */
 
 Bool
+CompositeRegisterAlternateVisuals (ScreenPtr pScreen,
+				   VisualID *vids, int nVisuals);
+
+Bool
 compScreenInit (ScreenPtr pScreen);
 
 /*
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 87055b7..2c86cdd 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -301,7 +301,7 @@ compIsAlternateVisual (ScreenPtr    pScr
     CompScreenPtr	cs = GetCompScreen (pScreen);
     int			i;
 
-    for (i = 0; i < NUM_COMP_ALTERNATE_VISUALS; i++)
+    for (i = 0; i < cs->numAlternateVisuals; i++)
 	if (cs->alternateVisuals[i] == visual)
 	    return TRUE;
     return FALSE;



More information about the xorg-commit mailing list