xserver/composite compinit.c, 1.12, 1.13 compint.h, 1.8,
1.9 compwindow.c, 1.11, 1.12
Keith Packard
xserver-commit at pdx.freedesktop.org
Thu May 20 20:32:29 PDT 2004
Committed by: keithp
Update of /cvs/xserver/xserver/composite
In directory pdx:/tmp/cvs-serv18211/composite
Modified Files:
compinit.c compint.h compwindow.c
Log Message:
2004-05-20 Keith Packard <keithp at keithp.com>
* composite/compinit.c: (compFindVisuallessDepth),
(compAddAlternateVisuals), (compScreenInit):
* composite/compint.h:
* composite/compwindow.c: (compIsAlternateVisual),
(compImplicitRedirect):
Allow for multiple composite-based visuals, then
add an RGB24 visual in addition to the ARGB32 one. This
allows 'glitz' to run on top of any X server using mesa.
* hw/kdrive/src/kdrive.c: (KdSetPixmapFormats):
Switch to using 32bpp for depth 24 pixmaps (even when
the frame buffer is not depth 24).
Index: compinit.c
===================================================================
RCS file: /cvs/xserver/xserver/composite/compinit.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- a/compinit.c 13 May 2004 21:25:51 -0000 1.12
+++ b/compinit.c 21 May 2004 03:32:27 -0000 1.13
@@ -89,63 +89,99 @@
}
/*
- * Add depth 32 ARGB visual type
+ * Add alternate visuals -- always expose an ARGB32 and RGB24 visual
*/
+static DepthPtr
+compFindVisuallessDepth (ScreenPtr pScreen, int d)
+{
+ int i;
+
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ DepthPtr depth = &pScreen->allowedDepths[i];
+ if (depth->depth == d)
+ {
+ /*
+ * Make sure it doesn't have visuals already
+ */
+ if (depth->numVids)
+ return 0;
+ /*
+ * looks fine
+ */
+ return depth;
+ }
+ }
+ /*
+ * If there isn't one, then it's gonna be hard to have
+ * an associated visual
+ */
+ return 0;
+}
+
+typedef struct _alternateVisual {
+ int depth;
+ CARD32 format;
+} CompAlternateVisual;
+
+static CompAlternateVisual altVisuals[NUM_COMP_ALTERNATE_VISUALS] = {
+ { 24, PICT_r8g8b8 },
+ { 32, PICT_a8r8g8b8 },
+};
+
static Bool
-compAddArgbVisual (ScreenPtr pScreen, CompScreenPtr cs)
+compAddAlternateVisuals (ScreenPtr pScreen, CompScreenPtr cs)
{
VisualPtr visuals;
- VisualPtr visual;
- DepthPtr depth;
+ DepthPtr depths[NUM_COMP_ALTERNATE_VISUALS];
+ PictFormatPtr pPictFormats[NUM_COMP_ALTERNATE_VISUALS];
int i;
int numVisuals;
- VisualID *vids;
- PictFormatPtr pPictFormat;
+ VisualID *vids[NUM_COMP_ALTERNATE_VISUALS];
XID *installedCmaps;
ColormapPtr installedCmap;
int numInstalledCmaps;
+ int numAlternate = 0;
+ int alt;
- /*
- * Find depth 32
- */
- for (i = 0; i < pScreen->numDepths; i++)
+ memset (cs->alternateVisuals, '\0', sizeof (cs->alternateVisuals));
+
+ for (alt = 0; alt < NUM_COMP_ALTERNATE_VISUALS; alt++)
{
- depth = &pScreen->allowedDepths[i];
- if (depth->depth == 32)
- break;
+ DepthPtr depth;
+ PictFormatPtr pPictFormat;
+
+ depth = compFindVisuallessDepth (pScreen, altVisuals[alt].depth);
+ if (!depth)
+ continue;
+ /*
+ * Find the right picture format
+ */
+ pPictFormat = PictureMatchFormat (pScreen, altVisuals[alt].depth,
+ altVisuals[alt].format);
+ if (!pPictFormat)
+ continue;
+
+ /*
+ * Ok, create a visual id for this format
+ */
+ cs->alternateVisuals[numAlternate] = FakeClientID (0);
+ /*
+ * Allocate vid list for this depth
+ */
+ vids[numAlternate] = xalloc (sizeof (VisualID));
+ if (!vids)
+ continue;
+ depths[numAlternate] = depth;
+ pPictFormats[numAlternate] = pPictFormat;
+ numAlternate++;
}
- /*
- * If there isn't one, then it's gonna be hard to have a depth 32 visual
- */
- if (i == pScreen->numDepths)
- return TRUE;
- depth = &pScreen->allowedDepths[i];
- /*
- * Make sure it doesn't have visuals already
- */
- if (depth->numVids)
- return TRUE;
- /*
- * Find the right picture format
- */
- pPictFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
- if (!pPictFormat)
+ if (!numAlternate)
return TRUE;
/*
- * Ok, create a visual for depth 32
- */
- cs->argbVid = FakeClientID (0);
- numVisuals = pScreen->numVisuals;
- /*
- * Allocate vid list for depth 32
- */
- vids = xalloc (1 * sizeof (VisualID));
- if (!vids)
- return FALSE;
- /*
* Find the installed colormaps
*/
installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID));
@@ -160,18 +196,17 @@
/*
* realloc the visual array to fit the new one in place
*/
+ numVisuals = pScreen->numVisuals;
visuals = xrealloc (pScreen->visuals,
- (numVisuals + 1) * sizeof (VisualRec));
+ (numVisuals + numAlternate) * sizeof (VisualRec));
if (!visuals)
{
- xfree (vids);
+ for (i = 0; i < numAlternate; i++)
+ xfree (vids[i]);
xfree (installedCmaps);
return FALSE;
}
- visual = &visuals[numVisuals];
- numVisuals++;
-
/*
* Fix up the default colormaps
*/
@@ -189,37 +224,50 @@
xfree (installedCmaps);
pScreen->visuals = visuals;
- pScreen->numVisuals = numVisuals;
+ pScreen->numVisuals = numVisuals + numAlternate;
- /*
- * Initialize the visual
- */
- visual->class = TrueColor;
- visual->bitsPerRGBValue = 8;
- visual->ColormapEntries = (1 << 8);
- visual->nplanes = 24; /* follow GLX and set this to just the bits
- * used for the RGB value, not A
- */
- visual->vid = cs->argbVid = FakeClientID (0);
- visual->redMask = (((unsigned long) pPictFormat->direct.redMask) <<
- pPictFormat->direct.red);
- visual->greenMask = (((unsigned long) pPictFormat->direct.greenMask) <<
- pPictFormat->direct.green);
- visual->blueMask = (((unsigned long) pPictFormat->direct.blueMask) <<
- pPictFormat->direct.blue);
- visual->offsetRed = pPictFormat->direct.red;
- visual->offsetGreen = pPictFormat->direct.green;
- visual->offsetBlue = pPictFormat->direct.blue;
- visual->alphaMask = (((unsigned long) pPictFormat->direct.alphaMask) <<
- pPictFormat->direct.alpha);
- visual->offsetAlpha = pPictFormat->direct.alpha;
+ for (i = 0; i < numAlternate; i++)
+ {
+ DepthPtr depth = depths[i];
+ PictFormatPtr pPictFormat = pPictFormats[i];
+ VisualPtr visual = &visuals[numVisuals + i];
- /*
- * Fix up the depth
- */
- vids[0] = cs->argbVid;
- depth->numVids = 1;
- depth->vids = vids;
+ /*
+ * Initialize the visual
+ */
+ visual->class = TrueColor;
+ visual->bitsPerRGBValue = 8;
+ visual->ColormapEntries = (1 << 8);
+ visual->nplanes = 24; /* follow GLX and set this to just the bits
+ * used for the RGB value, not A
+ */
+
+ visual->vid = FakeClientID (0);
+ visual->redMask = (((unsigned long) pPictFormat->direct.redMask) <<
+ pPictFormat->direct.red);
+ visual->greenMask = (((unsigned long) pPictFormat->direct.greenMask) <<
+ pPictFormat->direct.green);
+ visual->blueMask = (((unsigned long) pPictFormat->direct.blueMask) <<
+ pPictFormat->direct.blue);
+ visual->offsetRed = pPictFormat->direct.red;
+ visual->offsetGreen = pPictFormat->direct.green;
+ visual->offsetBlue = pPictFormat->direct.blue;
+ visual->alphaMask = (((unsigned long) pPictFormat->direct.alphaMask) <<
+ pPictFormat->direct.alpha);
+ visual->offsetAlpha = pPictFormat->direct.alpha;
+
+ /*
+ * remember the visual ID to detect auto-update windows
+ */
+ cs->alternateVisuals[i] = visual->vid;
+
+ /*
+ * Fix up the depth
+ */
+ vids[i][0] = visual->vid;
+ depth->numVids = 1;
+ depth->vids = vids[i];
+ }
return TRUE;
}
@@ -255,7 +303,7 @@
cs->damaged = FALSE;
- if (!compAddArgbVisual (pScreen, cs))
+ if (!compAddAlternateVisuals (pScreen, cs))
{
xfree (cs);
return FALSE;
Index: compint.h
===================================================================
RCS file: /cvs/xserver/xserver/composite/compint.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/compint.h 2 Dec 2003 01:59:38 -0000 1.8
+++ b/compint.h 21 May 2004 03:32:27 -0000 1.9
@@ -77,6 +77,8 @@
extern int CompPixmapPrivateIndex;
+#define NUM_COMP_ALTERNATE_VISUALS 2
+
typedef struct _CompScreen {
PositionWindowProcPtr PositionWindow;
CopyWindowProcPtr CopyWindow;
@@ -102,7 +104,7 @@
ScreenBlockHandlerProcPtr BlockHandler;
CloseScreenProcPtr CloseScreen;
Bool damaged;
- XID argbVid;
+ XID alternateVisuals[NUM_COMP_ALTERNATE_VISUALS];
} CompScreenRec, *CompScreenPtr;
#define HasCompRedirect(w) (wPixmap(w) != wPixmap(w->parent))
Index: compwindow.c
===================================================================
RCS file: /cvs/xserver/xserver/composite/compwindow.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- a/compwindow.c 2 Dec 2003 01:59:38 -0000 1.11
+++ b/compwindow.c 21 May 2004 03:32:27 -0000 1.12
@@ -241,14 +241,33 @@
*/
static Bool
-compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+compIsAlternateVisual (ScreenPtr pScreen,
+ XID visual)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
CompScreenPtr cs = GetCompScreen (pScreen);
+ int i;
+
+ for (i = 0; i < NUM_COMP_ALTERNATE_VISUALS; i++)
+ if (cs->alternateVisuals[i] == visual)
+ return TRUE;
+ return FALSE;
+}
+
+static Bool
+compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+{
+ if (pParent)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XID winVisual = wVisual (pWin);
+ XID parentVisual = wVisual (pParent);
- if (!pParent)
- return FALSE;
- return (wVisual(pWin) == cs->argbVid) != (wVisual (pParent) == cs->argbVid);
+ if (winVisual != parentVisual &&
+ (compIsAlternateVisual (pScreen, winVisual) ||
+ compIsAlternateVisual (pScreen, parentVisual)))
+ return TRUE;
+ }
+ return FALSE;
}
void
More information about the xserver-commit
mailing list