xserver: Branch 'master' - 3 commits

Keith Packard keithp at kemper.freedesktop.org
Mon Nov 30 08:42:28 PST 2009


 exa/exa_glyphs.c    |   47 +++++++++++++++++++++++++----------------------
 exa/exa_offscreen.c |   25 +------------------------
 fb/fbpict.c         |    6 ++++--
 3 files changed, 30 insertions(+), 48 deletions(-)

New commits:
commit 66a9616d645f5a23225251d197e00b94c79274f6
Author: Michel Dänzer <daenzer at vmware.com>
Date:   Mon Nov 30 13:17:53 2009 +0100

    fb: Don't crash if copy_drawable() returns NULL.
    
    Fixes http://bugs.freedesktop.org/show_bug.cgi?id=24634 .
    
    Signed-off-by: Michel Dänzer <daenzer at vmware.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 2fbef15..7ae3ec5 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -329,9 +329,11 @@ create_bits_picture (PicturePtr pict,
     pixman_image_t *image;
     DrawablePtr drawable;
 
-    if (is_src && pict->pDrawable->type == DRAWABLE_WINDOW)
+    if (is_src && pict->pDrawable->type == DRAWABLE_WINDOW) {
 	drawable = copy_drawable (pict->pDrawable);
-    else
+	if (!drawable)
+	    return NULL;
+    } else
 	drawable = pict->pDrawable;
     
     fbGetDrawable (drawable, bits, stride, bpp, xoff, yoff);
commit 8754db77d8169e5ea506a963cebee1a651bcf094
Author: Michel Dänzer <daenzer at vmware.com>
Date:   Mon Nov 30 13:17:52 2009 +0100

    EXA: Don't defragment offscreen memory at allocation time.
    
    Fixes http://bugs.freedesktop.org/show_bug.cgi?id=24300 .
    
    Offscreen memory allocation can occur from various places, and apparently
    doing defragmentation from at least some of them can confuse some driver
    acceleration code.
    
    There's still the regular background defragmentation in the WakeupHandler,
    which should manage to keep fragmentation at a reasonable level.
    
    Signed-off-by: Michel Dänzer <daenzer at vmware.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/exa/exa_offscreen.c b/exa/exa_offscreen.c
index acdf439..e3a9ab2 100644
--- a/exa/exa_offscreen.c
+++ b/exa/exa_offscreen.c
@@ -169,7 +169,7 @@ exaOffscreenAlloc (ScreenPtr pScreen, int size, int align,
 {
     ExaOffscreenArea *area;
     ExaScreenPriv (pScreen);
-    int real_size = 0, free_total = 0, largest_avail = 0;
+    int real_size = 0, largest_avail = 0;
 #if DEBUG_OFFSCREEN
     static int number = 0;
     ErrorF("================= ============ allocating a new pixmap %d\n", ++number);
@@ -208,33 +208,10 @@ exaOffscreenAlloc (ScreenPtr pScreen, int size, int align,
 	if (real_size <= area->size)
 	    break;
 
-	free_total += area->size;
-
 	if (area->size > largest_avail)
 	    largest_avail = area->size;
     }
 
-    if (!area && free_total >= size) {
-	CARD32 now = GetTimeInMillis();
-
-	/* Don't defragment more than once per second, to avoid adding more
-	 * overhead than we're trying to prevent
-	 */
-	if (abs((INT32) (now - pExaScr->lastDefragment)) > 1000) {
-	    area = ExaOffscreenDefragment(pScreen);
-	    pExaScr->lastDefragment = now;
-
-	    if (area) {
-		/* adjust size to match alignment requirement */
-		real_size = size + (area->base_offset + area->size - size) % align;
-
-		/* does it fit? */
-		if (real_size > area->size)
-		    area = NULL;
-	    }
-	}
-    }
-
     if (!area)
     {
 	area = exaFindAreaToEvict(pExaScr, size, align);
commit 0e555a1033e5deed1db8582ca075455a6a2d4228
Author: Michel Dänzer <daenzer at vmware.com>
Date:   Mon Nov 30 13:17:51 2009 +0100

    Revert "EXA: Accumulate arbitrary number of glyphs without flushing."
    
    This reverts commit c11678cc189551f2a01eaa7a63969c16950739b4.
    
    Not sure what I was thinking, turns out alloca() of a size derived from client
    input is a bad idea.
    
    Signed-off-by: Michel Dänzer <daenzer at vmware.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
index 4bc80eb..fd14e9b 100644
--- a/exa/exa_glyphs.c
+++ b/exa/exa_glyphs.c
@@ -62,10 +62,15 @@
  */
 #define CACHE_PICTURE_WIDTH 1024
 
+/* Maximum number of glyphs we buffer on the stack before flushing
+ * rendering to the mask or destination surface.
+ */
+#define GLYPH_BUFFER_SIZE 256
+
 typedef struct {
     PicturePtr mask;
+    ExaCompositeRectRec rects[GLYPH_BUFFER_SIZE];
     int count;
-    ExaCompositeRectRec rects[0];
 } ExaGlyphBuffer, *ExaGlyphBufferPtr;
 
 typedef enum {
@@ -552,13 +557,16 @@ exaBufferGlyph(ScreenPtr         pScreen,
 	       INT16             yDst)
 {
     ExaScreenPriv(pScreen);
-    PicturePtr mask = GlyphPicture(pGlyph)[pScreen->myNum];
-    unsigned int format = mask->format;
+    unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format;
     int width = pGlyph->info.width;
     int height = pGlyph->info.height;
     ExaCompositeRectPtr rect;
+    PicturePtr mask;
     int i;
 
+    if (buffer->count == GLYPH_BUFFER_SIZE)
+	return ExaGlyphNeedFlush;
+
     if (PICT_FORMAT_BPP(format) == 1)
 	format = PICT_a8;
     
@@ -589,6 +597,7 @@ exaBufferGlyph(ScreenPtr         pScreen,
 
     /* Couldn't find the glyph in the cache, use the glyph picture directly */
 
+    mask = GlyphPicture(pGlyph)[pScreen->myNum];
     if (buffer->mask && buffer->mask != mask)
 	return ExaGlyphNeedFlush;
 
@@ -702,18 +711,12 @@ exaGlyphs (CARD8 	 op,
     int		width = 0, height = 0;
     int		x, y;
     int		first_xOff = list->xOff, first_yOff = list->yOff;
-    int		i, n;
+    int		n;
     GlyphPtr	glyph;
     int		error;
     BoxRec	extents = {0, 0, 0, 0};
     CARD32	component_alpha;
-    ExaGlyphBufferPtr buffer;
-
-    for (i = 0, n = 0; i < nlist; i++)
-	n += list[i].len;
-    buffer = alloca(sizeof(ExaGlyphBuffer) + n * sizeof(ExaCompositeRectRec));
-    if (!buffer)
-	return;
+    ExaGlyphBuffer buffer;
 
     if (maskFormat)
     {
@@ -793,8 +796,8 @@ exaGlyphs (CARD8 	 op,
 	x = 0;
 	y = 0;
     }
-    buffer->count = 0;
-    buffer->mask = NULL;
+    buffer.count = 0;
+    buffer.mask = NULL;
     while (nlist--)
     {
 	x += list->xOff;
@@ -809,23 +812,23 @@ exaGlyphs (CARD8 	 op,
 		/* pGlyph->info.{x,y} compensate for empty space in the glyph. */
 		if (maskFormat)
 		{
-		    if (exaBufferGlyph(pScreen, buffer, glyph, NULL, pMask,
+		    if (exaBufferGlyph(pScreen, &buffer, glyph, NULL, pMask,
 				       0, 0, 0, 0, x - glyph->info.x, y - glyph->info.y) == ExaGlyphNeedFlush)
 		    {
-			exaGlyphsToMask(pMask, buffer);
-			exaBufferGlyph(pScreen, buffer, glyph, NULL, pMask,
+			exaGlyphsToMask(pMask, &buffer);
+			exaBufferGlyph(pScreen, &buffer, glyph, NULL, pMask,
 				       0, 0, 0, 0, x - glyph->info.x, y - glyph->info.y);
 		    }
 		}
 		else
 		{
-		    if (exaBufferGlyph(pScreen, buffer, glyph, pSrc, pDst,
+		    if (exaBufferGlyph(pScreen, &buffer, glyph, pSrc, pDst,
 				       xSrc + (x - glyph->info.x) - first_xOff, ySrc + (y - glyph->info.y) - first_yOff,
 				       0, 0, x - glyph->info.x, y - glyph->info.y)
 			== ExaGlyphNeedFlush)
 		    {
-			exaGlyphsToDst(pSrc, pDst, buffer);
-			exaBufferGlyph(pScreen, buffer, glyph, pSrc, pDst,
+			exaGlyphsToDst(pSrc, pDst, &buffer);
+			exaBufferGlyph(pScreen, &buffer, glyph, pSrc, pDst,
 				       xSrc + (x - glyph->info.x) - first_xOff, ySrc + (y - glyph->info.y) - first_yOff,
 				       0, 0, x - glyph->info.x, y - glyph->info.y);
 		    }
@@ -838,11 +841,11 @@ exaGlyphs (CARD8 	 op,
 	list++;
     }
     
-    if (buffer->count) {
+    if (buffer.count) {
         if (maskFormat)
-	    exaGlyphsToMask(pMask, buffer);
+	    exaGlyphsToMask(pMask, &buffer);
         else
-	    exaGlyphsToDst(pSrc, pDst, buffer);
+	    exaGlyphsToDst(pSrc, pDst, &buffer);
     }
 
     if (maskFormat)


More information about the xorg-commit mailing list