Revert "EXA: Accumulate arbitrary number of glyphs without flushing."
This reverts commit c11678cc18.
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@vmware.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
			
			
This commit is contained in:
		
							parent
							
								
									99d88ef69d
								
							
						
					
					
						commit
						0e555a1033
					
				| 
						 | 
					@ -62,10 +62,15 @@
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#define CACHE_PICTURE_WIDTH 1024
 | 
					#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 {
 | 
					typedef struct {
 | 
				
			||||||
    PicturePtr mask;
 | 
					    PicturePtr mask;
 | 
				
			||||||
 | 
					    ExaCompositeRectRec rects[GLYPH_BUFFER_SIZE];
 | 
				
			||||||
    int count;
 | 
					    int count;
 | 
				
			||||||
    ExaCompositeRectRec rects[0];
 | 
					 | 
				
			||||||
} ExaGlyphBuffer, *ExaGlyphBufferPtr;
 | 
					} ExaGlyphBuffer, *ExaGlyphBufferPtr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef enum {
 | 
					typedef enum {
 | 
				
			||||||
| 
						 | 
					@ -552,13 +557,16 @@ exaBufferGlyph(ScreenPtr         pScreen,
 | 
				
			||||||
	       INT16             yDst)
 | 
						       INT16             yDst)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ExaScreenPriv(pScreen);
 | 
					    ExaScreenPriv(pScreen);
 | 
				
			||||||
    PicturePtr mask = GlyphPicture(pGlyph)[pScreen->myNum];
 | 
					    unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format;
 | 
				
			||||||
    unsigned int format = mask->format;
 | 
					 | 
				
			||||||
    int width = pGlyph->info.width;
 | 
					    int width = pGlyph->info.width;
 | 
				
			||||||
    int height = pGlyph->info.height;
 | 
					    int height = pGlyph->info.height;
 | 
				
			||||||
    ExaCompositeRectPtr rect;
 | 
					    ExaCompositeRectPtr rect;
 | 
				
			||||||
 | 
					    PicturePtr mask;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (buffer->count == GLYPH_BUFFER_SIZE)
 | 
				
			||||||
 | 
						return ExaGlyphNeedFlush;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (PICT_FORMAT_BPP(format) == 1)
 | 
					    if (PICT_FORMAT_BPP(format) == 1)
 | 
				
			||||||
	format = PICT_a8;
 | 
						format = PICT_a8;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					@ -589,6 +597,7 @@ exaBufferGlyph(ScreenPtr         pScreen,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Couldn't find the glyph in the cache, use the glyph picture directly */
 | 
					    /* Couldn't find the glyph in the cache, use the glyph picture directly */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mask = GlyphPicture(pGlyph)[pScreen->myNum];
 | 
				
			||||||
    if (buffer->mask && buffer->mask != mask)
 | 
					    if (buffer->mask && buffer->mask != mask)
 | 
				
			||||||
	return ExaGlyphNeedFlush;
 | 
						return ExaGlyphNeedFlush;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -702,18 +711,12 @@ exaGlyphs (CARD8 	 op,
 | 
				
			||||||
    int		width = 0, height = 0;
 | 
					    int		width = 0, height = 0;
 | 
				
			||||||
    int		x, y;
 | 
					    int		x, y;
 | 
				
			||||||
    int		first_xOff = list->xOff, first_yOff = list->yOff;
 | 
					    int		first_xOff = list->xOff, first_yOff = list->yOff;
 | 
				
			||||||
    int		i, n;
 | 
					    int		n;
 | 
				
			||||||
    GlyphPtr	glyph;
 | 
					    GlyphPtr	glyph;
 | 
				
			||||||
    int		error;
 | 
					    int		error;
 | 
				
			||||||
    BoxRec	extents = {0, 0, 0, 0};
 | 
					    BoxRec	extents = {0, 0, 0, 0};
 | 
				
			||||||
    CARD32	component_alpha;
 | 
					    CARD32	component_alpha;
 | 
				
			||||||
    ExaGlyphBufferPtr buffer;
 | 
					    ExaGlyphBuffer buffer;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (i = 0, n = 0; i < nlist; i++)
 | 
					 | 
				
			||||||
	n += list[i].len;
 | 
					 | 
				
			||||||
    buffer = alloca(sizeof(ExaGlyphBuffer) + n * sizeof(ExaCompositeRectRec));
 | 
					 | 
				
			||||||
    if (!buffer)
 | 
					 | 
				
			||||||
	return;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (maskFormat)
 | 
					    if (maskFormat)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -793,8 +796,8 @@ exaGlyphs (CARD8 	 op,
 | 
				
			||||||
	x = 0;
 | 
						x = 0;
 | 
				
			||||||
	y = 0;
 | 
						y = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    buffer->count = 0;
 | 
					    buffer.count = 0;
 | 
				
			||||||
    buffer->mask = NULL;
 | 
					    buffer.mask = NULL;
 | 
				
			||||||
    while (nlist--)
 | 
					    while (nlist--)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
	x += list->xOff;
 | 
						x += list->xOff;
 | 
				
			||||||
| 
						 | 
					@ -809,23 +812,23 @@ exaGlyphs (CARD8 	 op,
 | 
				
			||||||
		/* pGlyph->info.{x,y} compensate for empty space in the glyph. */
 | 
							/* pGlyph->info.{x,y} compensate for empty space in the glyph. */
 | 
				
			||||||
		if (maskFormat)
 | 
							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)
 | 
									       0, 0, 0, 0, x - glyph->info.x, y - glyph->info.y) == ExaGlyphNeedFlush)
 | 
				
			||||||
		    {
 | 
							    {
 | 
				
			||||||
			exaGlyphsToMask(pMask, buffer);
 | 
								exaGlyphsToMask(pMask, &buffer);
 | 
				
			||||||
			exaBufferGlyph(pScreen, buffer, glyph, NULL, pMask,
 | 
								exaBufferGlyph(pScreen, &buffer, glyph, NULL, pMask,
 | 
				
			||||||
				       0, 0, 0, 0, x - glyph->info.x, y - glyph->info.y);
 | 
									       0, 0, 0, 0, x - glyph->info.x, y - glyph->info.y);
 | 
				
			||||||
		    }
 | 
							    }
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							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,
 | 
									       xSrc + (x - glyph->info.x) - first_xOff, ySrc + (y - glyph->info.y) - first_yOff,
 | 
				
			||||||
				       0, 0, x - glyph->info.x, y - glyph->info.y)
 | 
									       0, 0, x - glyph->info.x, y - glyph->info.y)
 | 
				
			||||||
			== ExaGlyphNeedFlush)
 | 
								== ExaGlyphNeedFlush)
 | 
				
			||||||
		    {
 | 
							    {
 | 
				
			||||||
			exaGlyphsToDst(pSrc, pDst, buffer);
 | 
								exaGlyphsToDst(pSrc, pDst, &buffer);
 | 
				
			||||||
			exaBufferGlyph(pScreen, buffer, glyph, pSrc, pDst,
 | 
								exaBufferGlyph(pScreen, &buffer, glyph, pSrc, pDst,
 | 
				
			||||||
				       xSrc + (x - glyph->info.x) - first_xOff, ySrc + (y - glyph->info.y) - first_yOff,
 | 
									       xSrc + (x - glyph->info.x) - first_xOff, ySrc + (y - glyph->info.y) - first_yOff,
 | 
				
			||||||
				       0, 0, x - glyph->info.x, y - glyph->info.y);
 | 
									       0, 0, x - glyph->info.x, y - glyph->info.y);
 | 
				
			||||||
		    }
 | 
							    }
 | 
				
			||||||
| 
						 | 
					@ -838,11 +841,11 @@ exaGlyphs (CARD8 	 op,
 | 
				
			||||||
	list++;
 | 
						list++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (buffer->count) {
 | 
					    if (buffer.count) {
 | 
				
			||||||
        if (maskFormat)
 | 
					        if (maskFormat)
 | 
				
			||||||
	    exaGlyphsToMask(pMask, buffer);
 | 
						    exaGlyphsToMask(pMask, &buffer);
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
	    exaGlyphsToDst(pSrc, pDst, buffer);
 | 
						    exaGlyphsToDst(pSrc, pDst, &buffer);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (maskFormat)
 | 
					    if (maskFormat)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue