xserver: Branch 'server-1.7-branch' - 5 commits

Peter Hutterer whot at kemper.freedesktop.org
Tue Sep 29 17:52:50 PDT 2009


 Xext/shm.c                       |   43 ++++++++++++++++++++------
 composite/compinit.c             |   59 ++---------------------------------
 dix/colormap.c                   |   64 +++++++++++++++++++++++++++++++++++++++
 glx/glxscreens.c                 |   58 +----------------------------------
 hw/kdrive/ephyr/Xephyr.man.pre   |    5 +++
 hw/kdrive/ephyr/ephyrinit.c      |   16 +++++++++
 hw/xfree86/modes/xf86EdidModes.c |    2 -
 include/colormap.h               |    5 +++
 render/glyph.c                   |   42 ++++++++++++-------------
 9 files changed, 152 insertions(+), 142 deletions(-)

New commits:
commit 369b5d526b699cd1c5cd38bb5a823ec66c5286ef
Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Sep 29 11:49:09 2009 +1000

    dix/glx/composite: consolidate visual resize in one place.
    
    The previous code was copied and in both cases incorrectly fixed
    up the colormaps after resizing the visuals, this patch consolidates
    the visual resize + colormaps fixups in one place. This version
    also consolidates the vid allocation for the DepthPtr inside the
    function.
    
    I'm not 100% sure colormap.[ch] is the correct place for this but
    visuals are mostly created in fb and I know thats not the place to
    be resizing them.
    
    Fixes fd.o bug #19470.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 6ffda5aae75272fabdc27d6f693ae827be119e95)

diff --git a/composite/compinit.c b/composite/compinit.c
index 6159e4e..96ac70f 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -248,15 +248,9 @@ static Bool
 compAddAlternateVisual(ScreenPtr pScreen, CompScreenPtr cs,
 		       CompAlternateVisual *alt)
 {
-    VisualPtr	    visual, visuals;
-    int		    i;
-    int		    numVisuals;
-    XID		    *installedCmaps;
-    ColormapPtr	    installedCmap;
-    int		    numInstalledCmaps;
+    VisualPtr	    visual;
     DepthPtr	    depth;
     PictFormatPtr   pPictFormat;
-    VisualID	    *vid;
     unsigned long   alphaMask;
 
     /*
@@ -277,54 +271,13 @@ compAddAlternateVisual(ScreenPtr pScreen, CompScreenPtr cs,
 	pPictFormat->direct.red != pScreen->visuals[0].offsetRed)
 	return FALSE;
 
-    vid = xalloc(sizeof(VisualID));
-    if (!vid)
-	return FALSE;
-
-    /* Find the installed colormaps */
-    installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID));
-    if (!installedCmaps) {
-	xfree(vid);
-	return FALSE;
-    }
-    numInstalledCmaps = pScreen->ListInstalledColormaps(pScreen, 
-	    installedCmaps);
-
-    /* realloc the visual array to fit the new one in place */
-    numVisuals = pScreen->numVisuals;
-    visuals = xrealloc(pScreen->visuals, (numVisuals + 1) * sizeof(VisualRec));
-    if (!visuals) {
-	xfree(vid);
-	xfree(installedCmaps);
-	return FALSE;
+    if (ResizeVisualArray(pScreen, 1, depth) == FALSE) {
+        return FALSE;
     }
 
-    /*
-     * Fix up any existing installed colormaps -- we'll assume that
-     * the only ones created so far have been installed.  If this
-     * isn't true, we'll have to walk the resource database looking
-     * for all colormaps.
-     */
-    for (i = 0; i < numInstalledCmaps; i++) {
-	int j, rc;
-
-	rc = dixLookupResourceByType((pointer *)&installedCmap,
-				     installedCmaps[i], RT_COLORMAP,
-				     serverClient, DixReadAccess);
-	if (rc != Success)
-	    continue;
-	j = installedCmap->pVisual - pScreen->visuals;
-	installedCmap->pVisual = &visuals[j];
-    }
-
-    xfree(installedCmaps);
-
-    pScreen->visuals = visuals;
-    visual = visuals + pScreen->numVisuals; /* the new one */
-    pScreen->numVisuals++;
+    visual = pScreen->visuals + (pScreen->numVisuals - 1); /* the new one */
 
     /* Initialize the visual */
-    visual->vid = FakeClientID (0);
     visual->bitsPerRGBValue = 8;
     if (PICT_FORMAT_TYPE(alt->format) == PICT_TYPE_COLOR) {
 	visual->class = PseudoColor;
@@ -357,10 +310,6 @@ compAddAlternateVisual(ScreenPtr pScreen, CompScreenPtr cs,
     /* remember the visual ID to detect auto-update windows */
     compRegisterAlternateVisuals(cs, &visual->vid, 1);
 
-    /* Fix up the depth */
-    *vid = visual->vid;
-    depth->numVids = 1;
-    depth->vids = vid;
     return TRUE;
 }
 
diff --git a/dix/colormap.c b/dix/colormap.c
index a5a006e..d702b02 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -2690,3 +2690,67 @@ IsMapInstalled(Colormap map, WindowPtr pWin)
     xfree(pmaps);
     return (found);
 }
+
+struct colormap_lookup_data {
+    ScreenPtr pScreen;
+    VisualPtr visuals;
+};
+
+static void _colormap_find_resource(pointer value, XID id,
+				    pointer cdata)
+{
+    struct colormap_lookup_data *cmap_data = cdata;
+    VisualPtr visuals = cmap_data->visuals;
+    ScreenPtr pScreen = cmap_data->pScreen;
+    ColormapPtr cmap = value;
+    int j;
+
+    j = cmap->pVisual - pScreen->visuals;
+    cmap->pVisual = &visuals[j];
+}
+
+/* something has realloced the visuals, instead of breaking
+   ABI fix it up here - glx and compsite did this wrong */
+Bool
+ResizeVisualArray(ScreenPtr pScreen, int new_visual_count,
+		  DepthPtr depth)
+{
+    struct colormap_lookup_data cdata;
+    int numVisuals;
+    VisualPtr visuals;
+    XID *vids, vid;
+    int first_new_vid, first_new_visual, i;
+
+    first_new_vid = depth->numVids;
+    first_new_visual = pScreen->numVisuals;
+
+    vids = xrealloc(depth->vids, (depth->numVids + new_visual_count) * sizeof(XID));
+    if (!vids)
+        return FALSE;
+
+    /* its realloced now no going back if we fail the next one */
+    depth->vids = vids;
+
+    numVisuals = pScreen->numVisuals + new_visual_count;
+    visuals = xrealloc(pScreen->visuals, numVisuals * sizeof(VisualRec));
+    if (!visuals) {
+	return FALSE;
+    }
+
+    cdata.visuals = visuals;
+    cdata.pScreen = pScreen;
+    FindClientResourcesByType(serverClient, RT_COLORMAP, _colormap_find_resource, &cdata);
+
+    pScreen->visuals = visuals;
+
+    for (i = 0; i < new_visual_count; i++) {
+	vid = FakeClientID(0);
+	pScreen->visuals[first_new_visual + i].vid = vid;
+	vids[first_new_vid + i] = vid;
+    }
+
+    depth->numVids += new_visual_count;
+    pScreen->numVisuals += new_visual_count;
+
+    return TRUE;
+}
diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index 81faddd..7d29d31 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -250,12 +250,8 @@ GLint glxConvertToXVisualType(int visualType)
 static VisualPtr
 AddScreenVisuals(ScreenPtr pScreen, int count, int d)
 {
-    XID		*installedCmaps, *vids, vid;
-    int		 numInstalledCmaps, numVisuals, i, j;
-    VisualPtr	 visuals;
-    ColormapPtr	 installedCmap;
+    int		 i;
     DepthPtr	 depth;
-    int		 rc;
 
     depth = NULL;
     for (i = 0; i < pScreen->numDepths; i++) {
@@ -267,56 +263,8 @@ AddScreenVisuals(ScreenPtr pScreen, int count, int d)
     if (depth == NULL)
 	return NULL;
 
-    /* Find the installed colormaps */
-    installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID));
-    if (!installedCmaps)
-	return NULL;
-
-    numInstalledCmaps = pScreen->ListInstalledColormaps(pScreen, installedCmaps);
-
-    /* realloc the visual array to fit the new one in place */
-    numVisuals = pScreen->numVisuals;
-    visuals = xrealloc(pScreen->visuals, (numVisuals + count) * sizeof(VisualRec));
-    if (!visuals) {
-	xfree(installedCmaps);
-	return NULL;
-    }
-
-    vids = xrealloc(depth->vids, (depth->numVids + count) * sizeof(XID));
-    if (vids == NULL) {
-	xfree(installedCmaps);
-	xfree(visuals);
-	return NULL;
-    }
-
-    /*
-     * Fix up any existing installed colormaps -- we'll assume that
-     * the only ones created so far have been installed.  If this
-     * isn't true, we'll have to walk the resource database looking
-     * for all colormaps.
-     */
-    for (i = 0; i < numInstalledCmaps; i++) {
-	rc = dixLookupResourceByType((pointer *)&installedCmap,
-				     installedCmaps[i], RT_COLORMAP,
-				     serverClient, DixReadAccess);
-	if (rc != Success)
-	    continue;
-	j = installedCmap->pVisual - pScreen->visuals;
-	installedCmap->pVisual = &visuals[j];
-    }
-
-    xfree(installedCmaps);
-
-    for (i = 0; i < count; i++) {
-	vid = FakeClientID(0);
-	visuals[pScreen->numVisuals + i].vid = vid;
-	vids[depth->numVids + i] = vid;
-    }
-
-    pScreen->visuals = visuals;
-    pScreen->numVisuals += count;
-    depth->vids = vids;
-    depth->numVids += count;
+    if (ResizeVisualArray(pScreen, count, depth) == FALSE)
+        return NULL;
 
     /* Return a pointer to the first of the added visuals. */ 
     return pScreen->visuals + pScreen->numVisuals - count;
diff --git a/include/colormap.h b/include/colormap.h
index a3467c9..de48ce8 100644
--- a/include/colormap.h
+++ b/include/colormap.h
@@ -179,4 +179,9 @@ extern _X_EXPORT int IsMapInstalled(
     Colormap /*map*/,
     WindowPtr /*pWin*/);
 
+extern _X_EXPORT Bool ResizeVisualArray(
+    ScreenPtr /* pScreen */,
+    int /* new_vis_count */,
+    DepthPtr /* depth */);
+
 #endif /* CMAP_H */
commit d3ba814884154150ed3e6a71254dec7312593488
Author: Michel Dänzer <daenzer at vmware.com>
Date:   Tue Sep 29 08:56:59 2009 +0200

    Fix ShmPutImage non-ZPixmap case.
    
    Fixes http://bugs.freedesktop.org/show_bug.cgi?id=23298 .
    (cherry picked from commit 11817a881cb93a89788105d1e575a468f2a8d27c)

diff --git a/Xext/shm.c b/Xext/shm.c
index e4f08e2..a6f804c 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -497,15 +497,40 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
 	      char *data)
 {
     PixmapPtr pPixmap;
-  
-    pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth,
-				     BitsPerPixel(depth),
-				     PixmapBytePad(w, depth),
-				     data);
-    if (!pPixmap)
-	return;
-    pGC->ops->CopyArea((DrawablePtr)pPixmap, dst, pGC, sx, sy, sw, sh, dx, dy);
-    FreeScratchPixmapHeader(pPixmap);
+
+    if (format == ZPixmap || depth == 1) {
+	pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth,
+					 BitsPerPixel(depth),
+					 PixmapBytePad(w, depth),
+					 data);
+	if (!pPixmap)
+	    return;
+	pGC->ops->CopyArea((DrawablePtr)pPixmap, dst, pGC, sx, sy, sw, sh, dx, dy);
+	FreeScratchPixmapHeader(pPixmap);
+    } else {
+	GCPtr putGC = GetScratchGC(depth, dst->pScreen);
+
+	if (!putGC)
+	    return;
+
+	pPixmap = (*dst->pScreen->CreatePixmap)(dst->pScreen, sw, sh, depth,
+						CREATE_PIXMAP_USAGE_SCRATCH);
+	if (!pPixmap) {
+	    FreeScratchGC(putGC);
+	    return;
+	}
+	ValidateGC(&pPixmap->drawable, putGC);
+	(*putGC->ops->PutImage)(&pPixmap->drawable, putGC, depth, -sx, -sy, w, h, 0,
+				(format == XYPixmap) ? XYPixmap : ZPixmap, data);
+	FreeScratchGC(putGC);
+	if (format == XYBitmap)
+	    (void)(*pGC->ops->CopyPlane)(&pPixmap->drawable, dst, pGC, 0, 0, sw, sh,
+					 dx, dy, 1L);
+	else
+	    (void)(*pGC->ops->CopyArea)(&pPixmap->drawable, dst, pGC, 0, 0, sw, sh,
+					dx, dy);
+	(*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
+    }
 }
 
 #ifdef PANORAMIX
commit 8fc0d54cbaf791d947c7bab23f2e982cabd7c958
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Sep 28 14:18:45 2009 +1000

    ephyr: if -parent is given, check for a trailing -screen. (#24144)
    
    If -parent is given, don't open up a new window if -screen is given as well.
    The commandline option -screen allows to set the depth of the embedded
    Xephry instance, even though width and height are autoscaled on -parent.
    
    This patch checks for a -screen parameter after -parent and - if one is
    found - delays initializing the screen. The parent window id is stored
    temporarily but re-set after a -screen argument.
    The following command is thus valid:
    
    Xephyr -parent 1234 -screen 640x480 at 8 -screen 1024x768
    
    It embeds the first 8-bit screen into window 1234 and opens up a new window
    for the second screen. Multiple parent arguments are possible, the screens
    are embedded in-order.
    
    X.Org Bug 24144 <http://bugs.freedesktop.org/show_bug.cgi?id=24144>
    
    Tested-by: Vic Lee
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 19be992d9dc542b61fa3f4fd32a09071c9e64880)

diff --git a/hw/kdrive/ephyr/Xephyr.man.pre b/hw/kdrive/ephyr/Xephyr.man.pre
index 0082569..eb80b96 100644
--- a/hw/kdrive/ephyr/Xephyr.man.pre
+++ b/hw/kdrive/ephyr/Xephyr.man.pre
@@ -46,6 +46,11 @@ sets the screen size.
 .BI -parent " id"
 uses exiting window
 .I id .
+If a 
+.BI -screen 
+argument follows a 
+.BI -parent
+argument, this screen is embedded into the given window.
 .TP 8
 .B -host-cursor
 set 'cursor acceleration':
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 22152ff..eecad7e 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -148,6 +148,7 @@ processScreenArg (char *screen_size, char *parent_id)
 int
 ddxProcessArgument (int argc, char **argv, int i)
 {
+  static char* parent = NULL;
   EPHYR_DBG("mark argv[%d]='%s'", i, argv[i] );
 
   if (i == 1)
@@ -159,6 +160,18 @@ ddxProcessArgument (int argc, char **argv, int i)
     {
       if(i+1 < argc)
 	{
+	  int j;
+	  /* If parent is specified and a screen argument follows, don't do
+           * anything, let the -screen handling init the rest */
+	  for (j = i; j < argc; j++)
+	    {
+	      if (!strcmp(argv[j], "-screen"))
+		{
+		  parent = argv[i + 1];
+		  return 2;
+		}
+	    }
+
 	  processScreenArg ("100x100", argv[i+1]);
 	  return 2;
 	}
@@ -170,7 +183,8 @@ ddxProcessArgument (int argc, char **argv, int i)
     {
       if ((i+1) < argc)
 	{
-	  processScreenArg (argv[i+1], NULL);
+	  processScreenArg (argv[i+1], parent);
+	  parent = NULL;
 	  return 2;
 	}
 
commit 857ec3e6fff571398dfcd9b4728b5c38cbcd3fcb
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Sep 28 13:59:25 2009 +1000

    xfree86: use the DDC size if either width or height of DisplaySize is bogus.
    
    If either width or height of DisplaySize is invalid, assume that the
    configuration is invalid and use the DDC-reported values instead.
    
    See Comment 9, Bug 9758.
    http://bugs.freedesktop.org/show_bug.cgi?id=9758#c9
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Dave Airlie <airlied at redhat.com>
    (cherry picked from commit 83023ffd09a84ff48e6b99f57ebad101a00478db)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 6e11f9a..2f80070 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -957,7 +957,7 @@ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
 
     quirks = xf86DDCDetectQuirks(scrnIndex, DDC, FALSE);
 
-    if (Monitor->widthmm <= 0 && Monitor->heightmm <= 0) {
+    if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) {
 	Monitor->widthmm = 10 * DDC->features.hsize;
 	Monitor->heightmm = 10 * DDC->features.vsize;
     }
commit 2d4bab18c0d894619f044f29769c67c2f63b540a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Sep 23 10:53:51 2009 +1000

    render: Plug a memory leak in AddGlyph. (#23286)
    
    AddGlyph was missing the FreePicture() call that DeleteGlyph used, resulting
    in a memory leak when more than one Glyph was added in a RenderAddGlyphs
    request.
    
    Since the code in AddGlyph and DeleteGlyph is identical, move into a static
    function to avoid such mistakes in the future.
    
    X.Org Bug 23286 <http://bugs.freedesktop.org/show_bug.cgi?id=23286>
    (cherry picked from commit f772014c435f56db56520ca13ffa39431684f122)

diff --git a/render/glyph.c b/render/glyph.c
index 7c044aa..6327c9f 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -272,13 +272,31 @@ CheckDuplicates (GlyphHashPtr hash, char *where)
 #define DuplicateRef(a,b)
 #endif
 
+static void
+FreeGlyphPicture(GlyphPtr glyph)
+{
+    PictureScreenPtr ps;
+    int i;
+
+    for (i = 0; i < screenInfo.numScreens; i++)
+    {
+        ScreenPtr pScreen = screenInfo.screens[i];
+
+        FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
+
+        ps = GetPictureScreenIfSet (pScreen);
+        if (ps)
+            (*ps->UnrealizeGlyph) (pScreen, glyph);
+    }
+}
+
+
 void
 FreeGlyph (GlyphPtr glyph, int format)
 {
     CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
     if (--glyph->refcnt == 0)
     {
-	PictureScreenPtr ps;
 	GlyphRefPtr      gr;
 	int	         i;
 	int	         first;
@@ -305,17 +323,7 @@ FreeGlyph (GlyphPtr glyph, int format)
 	    globalGlyphs[format].tableEntries--;
 	}
 
-	for (i = 0; i < screenInfo.numScreens; i++)
-	{
-	    ScreenPtr pScreen = screenInfo.screens[i];
-
-	    FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
-
-	    ps = GetPictureScreenIfSet (pScreen);
-	    if (ps)
-		(*ps->UnrealizeGlyph) (pScreen, glyph);
-	}
-	
+	FreeGlyphPicture(glyph);
 	FreeGlyphPrivates(glyph);
 	xfree (glyph);
     }
@@ -334,15 +342,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
 		       TRUE, glyph->sha1);
     if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph)
     {
-	PictureScreenPtr ps;
-	int              i;
-	
-	for (i = 0; i < screenInfo.numScreens; i++)
-	{
-	    ps = GetPictureScreenIfSet (screenInfo.screens[i]);
-	    if (ps)
-		(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
-	}
+	FreeGlyphPicture(glyph);
 	FreeGlyphPrivates(glyph);
 	xfree (glyph);
 	glyph = gr->glyph;


More information about the xorg-commit mailing list