[xserver-commit] xserver/render picture.c,1.34,1.35

Keith Packard xserver-commit@pdx.freedesktop.org
Mon, 17 Nov 2003 23:10:16 -0800


Committed by: keithp

Update of /cvs/xserver/xserver/render
In directory pdx:/tmp/cvs-serv14580/render

Modified Files:
	picture.c 
Log Message:
	* include/picturestr.h:
	* render/picture.c: (PictureCreateDefaultFormats),
	(PictureFindVisual), (PictureInitIndexedFormats),
	(PictureMatchVisual), (PictureInit):
	Switch from having a VisualPtr in an indexed picture format
	to a Visual ID.  Necessary because Composite reallocates the
	visual array which scrambles our pointers.  Only used during
	server startup, so there's no performance impact at all.


Index: picture.c
===================================================================
RCS file: /cvs/xserver/xserver/render/picture.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- picture.c	11 Nov 2003 09:02:22 -0000	1.34
+++ picture.c	18 Nov 2003 07:10:14 -0000	1.35
@@ -370,7 +370,7 @@
 	case PICT_TYPE_COLOR:
 	case PICT_TYPE_GRAY:
 	    pFormats[f].type = PictTypeIndexed;
-	    pFormats[f].index.pVisual = &pScreen->visuals[PICT_FORMAT_VIS(format)];
+	    pFormats[f].index.vid = pScreen->visuals[PICT_FORMAT_VIS(format)].vid;
 	    break;
 	}
     }
@@ -378,6 +378,21 @@
     return pFormats;
 }
 
+static VisualPtr
+PictureFindVisual (ScreenPtr pScreen, VisualID visual)
+{
+    int		i;
+    VisualPtr	pVisual;
+    for (i = 0, pVisual = pScreen->visuals;
+	 i < pScreen->numVisuals;
+	 i++, pVisual++)
+    {
+	if (pVisual->vid == visual)
+	    return pVisual;
+    }
+    return 0;
+}
+
 Bool
 PictureInitIndexedFormats (ScreenPtr pScreen)
 {
@@ -393,13 +408,16 @@
     {
 	if (format->type == PictTypeIndexed && !format->index.pColormap)
 	{
-	    if (format->index.pVisual->vid == pScreen->rootVisual)
+	    if (format->index.vid == pScreen->rootVisual)
 		format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap,
 								       RT_COLORMAP);
 	    else
 	    {
+		VisualPtr   pVisual;
+
+		pVisual = PictureFindVisual (pScreen, format->index.vid);
 		if (CreateColormap (FakeClientID (0), pScreen,
-				    format->index.pVisual,
+				    pVisual,
 				    &format->index.pColormap, AllocNone,
 				    0) != Success)
 		{
@@ -483,7 +501,7 @@
 	{
 	    if (type == PictTypeIndexed)
 	    {
-		if (format->index.pVisual == pVisual)
+		if (format->index.vid == pVisual->vid)
 		    return format;
 	    }
 	    else
@@ -588,7 +606,8 @@
 	}
 	if (formats[n].type == PictTypeIndexed)
 	{
-	    if ((formats[n].index.pVisual->class | DynamicClass) == PseudoColor)
+	    VisualPtr	pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
+	    if ((pVisual->class | DynamicClass) == PseudoColor)
 		type = PICT_TYPE_COLOR;
 	    else
 		type = PICT_TYPE_GRAY;