xserver: Branch 'glucose-2'

Alan Hourihane alanh at kemper.freedesktop.org
Tue Mar 27 15:09:52 EEST 2007


 render/filter.c     |   33 +--
 render/picture.c    |  456 +++++++++++++++++++++++++++++-----------------------
 render/picture.h    |    6 
 render/picturestr.h |   79 +++++++--
 render/render.c     |   13 +
 5 files changed, 358 insertions(+), 229 deletions(-)

New commits:
diff-tree 3cd35d45f1ef06b4d2248b959eddda5bcbfc4a45 (from 2e5271f75999911a5c077e38915589413f1e34ba)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Tue Mar 27 13:09:50 2007 +0100

    Merge in xgl changes to render extension.

diff --git a/render/filter.c b/render/filter.c
index 71375da..c06e28f 100644
--- a/render/filter.c
+++ b/render/filter.c
@@ -271,24 +271,18 @@ PictureResetFilters (ScreenPtr pScreen)
 int
 SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
 {
+    ScreenPtr		pScreen;
+    PictureScreenPtr	ps;
     PictFilterPtr	pFilter;
     xFixed		*new_params;
-    int			i, s, result;
+    int			i, result;
 
-    pFilter = PictureFindFilter (screenInfo.screens[0], name, len);
+    if (!pPicture->pDrawable)
+       return Success;
 
-    if (pPicture->pDrawable == NULL) {
-	/* For source pictures, the picture isn't tied to a screen.  So, ensure
-	 * that all screens can handle a filter we set for the picture.
-	 */
-	for (s = 0; s < screenInfo.numScreens; s++) {
-	    if (PictureFindFilter (screenInfo.screens[s], name, len)->id !=
-		pFilter->id)
-	    {
-		return BadMatch;
-	    }
-	}
-    }
+    pScreen = pPicture->pDrawable->pScreen;
+    ps = GetPictureScreen(pScreen);
+    pFilter = PictureFindFilter (pScreen, name, len);
 
     if (!pFilter)
 	return BadName;
@@ -313,13 +307,8 @@ SetPictureFilter (PicturePtr pPicture, c
 	pPicture->filter_params[i] = params[i];
     pPicture->filter = pFilter->id;
 
-    if (pPicture->pDrawable) {
-	ScreenPtr pScreen = pPicture->pDrawable->pScreen;
-	PictureScreenPtr ps = GetPictureScreen(pScreen);
-
-	result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
-					     params, nparams);
-	return result;
-    }
+    result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
+					 params, nparams);
+    return result;
     return Success;
 }
diff --git a/render/picture.c b/render/picture.c
index c30649c..40af4c4 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -233,14 +233,10 @@ PictureCreateDefaultFormats (ScreenPtr p
     formats[nformats].format = PICT_a1;
     formats[nformats].depth = 1;
     nformats++;
-    formats[nformats].format = PICT_FORMAT(BitsPerPixel(8),
-					   PICT_TYPE_A,
-					   8, 0, 0, 0);
+    formats[nformats].format = PICT_a8;
     formats[nformats].depth = 8;
     nformats++;
-    formats[nformats].format = PICT_FORMAT(BitsPerPixel(4),
-					   PICT_TYPE_A,
-					   4, 0, 0, 0);
+    formats[nformats].format = PICT_a4;
     formats[nformats].depth = 4;
     nformats++;
     formats[nformats].format = PICT_a8r8g8b8;
@@ -664,6 +660,7 @@ PictureInit (ScreenPtr pScreen, PictForm
 	    xfree (formats);
 	    return FALSE;
 	}
+	a = r = g = b = 0;
 	if (formats[n].type == PictTypeIndexed)
 	{
             VisualPtr   pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
@@ -671,9 +668,8 @@ PictureInit (ScreenPtr pScreen, PictForm
 		type = PICT_TYPE_COLOR;
 	    else
 		type = PICT_TYPE_GRAY;
-	    a = r = g = b = 0;
 	}
-	else
+	else if (formats[n].type == PictTypeDirect)
 	{
 	    if ((formats[n].direct.redMask|
 		 formats[n].direct.blueMask|
@@ -688,6 +684,10 @@ PictureInit (ScreenPtr pScreen, PictForm
 	    g = Ones (formats[n].direct.greenMask);
 	    b = Ones (formats[n].direct.blueMask);
 	}
+	else
+	{
+            type = PICT_FORMAT_TYPE (formats[n].format);
+	}
 	formats[n].format = PICT_FORMAT(0,type,a,r,g,b);
     }
     ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec));
@@ -890,41 +890,72 @@ static unsigned int INTERPOLATE_PIXEL_25
     return x;
 }
 
-static void initGradientColorTable(SourcePictPtr pGradient, int *error)
+CARD32
+PictureGradientColor (PictGradientStopPtr stop1,
+		      PictGradientStopPtr stop2,
+		      CARD32	          x)
+{
+    int	dist, idist;
+
+    dist  = (int) (256 * (x - stop1->x) / (stop2->x - stop1->x));
+    idist = 256 - dist;
+
+    return premultiply (INTERPOLATE_PIXEL_256 (stop1->color, idist,
+					       stop2->color, dist));
+}
+
+static void
+initGradientColorTable(PictGradientPtr gradient,
+		       int	       tableSize,
+		       int	       *error)
 {
     int begin_pos, end_pos;
     xFixed incr, dpos;
     int pos, current_stop;
-    PictGradientStopPtr stops = pGradient->linear.stops;
-    int nstops = pGradient->linear.nstops;
+    PictGradientStopPtr stops = gradient->stops;
+    int nstops = gradient->nstops;
+
+    if (gradient->colorTableSize < tableSize)
+    {
+	CARD32 *newColorTable;
+
+	newColorTable = realloc (gradient->colorTable,
+				 tableSize * sizeof (CARD32));
+	if (!newColorTable)
+	{
+	    *error = BadAlloc;
+	    return;
+	}
+
+	gradient->colorTable = newColorTable;
+	gradient->colorTableSize = tableSize;
+    }
+
+    gradient->stopRange = tableSize;
 
     /* The position where the gradient begins and ends */
-    begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
-    end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
+    begin_pos = (stops[0].x * gradient->colorTableSize) >> 16;
+    end_pos = (stops[nstops - 1].x * gradient->colorTableSize) >> 16;
 
     pos = 0; /* The position in the color table. */
 
     /* Up to first point */
     while (pos <= begin_pos) {
-        pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color);
+	gradient->colorTable[pos] = stops[0].color;
         ++pos;
     }
 
-    incr =  (1<<16)/ PICT_GRADIENT_STOPTABLE_SIZE; /* the double increment. */
+    incr =  (1<<16)/ gradient->colorTableSize; /* the double increment. */
     dpos = incr * pos; /* The position in terms of 0-1. */
 
     current_stop = 0; /* We always interpolate between current and current + 1. */
 
     /* Gradient area */
     while (pos < end_pos) {
-        unsigned int current_color = xRenderColorToCard32(stops[current_stop].color);
-        unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color);
-
-        int dist = (int)(256*(dpos - stops[current_stop].x)
-                         / (stops[current_stop+1].x - stops[current_stop].x));
-        int idist = 256 - dist;
-
-        pGradient->linear.colorTable[pos] = premultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist));
+	gradient->colorTable[pos] =
+	    PictureGradientColor (&stops[current_stop],
+				  &stops[current_stop + 1],
+				  dpos);
 
         ++pos;
         dpos += incr;
@@ -934,58 +965,96 @@ static void initGradientColorTable(Sourc
     }
 
     /* After last point */
-    while (pos < PICT_GRADIENT_STOPTABLE_SIZE) {
-        pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color);
+    while (pos < gradient->colorTableSize) {
+	gradient->colorTable[pos] = stops[nstops - 1].color;
         ++pos;
     }
 }
 
-static void initGradient(SourcePictPtr pGradient, int stopCount,
-                         xFixed *stopPoints, xRenderColor *stopColors, int *error)
+static void
+SourcePictureInit (PicturePtr	 pPicture,
+		   SourcePictPtr pSourcePict,
+		   int		 type)
+{
+    pPicture->pDrawable = 0;
+    pPicture->pFormat	= 0;
+    pPicture->pNext	= 0;
+    pPicture->format	= PICT_a8r8g8b8;
+
+    SetPictureToDefaults (pPicture);
+
+    pPicture->pSourcePict = pSourcePict;
+
+    pSourcePict->source.type	       = type;
+    pSourcePict->source.class	       = SourcePictClassUnknown;
+    pSourcePict->source.devPrivate.ptr = NULL;
+    pSourcePict->source.Destroy	       = NULL;
+}
+
+static Bool
+GradientPictureInit (PicturePtr	     pPicture,
+		     PictGradientPtr pGradient,
+		     int	     type,
+		     int	     stopCount,
+		     xFixed	     *stopPoints,
+		     xRenderColor    *stopColors,
+		     int	     *error)
 {
     int i;
     xFixed dpos;
 
-    if (stopCount <= 0) {
-        *error = BadValue;
-        return;
+    if (stopCount <= 0)
+    {
+	*error = BadValue;
+	return FALSE;
     }
 
+    SourcePictureInit (pPicture, (SourcePictPtr) pGradient, type);
+
     dpos = -1;
-    for (i = 0; i < stopCount; ++i) {
-        if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) {
-            *error = BadValue;
-            return;
-        }
-        dpos = stopPoints[i];
+    for (i = 0; i < stopCount; ++i)
+    {
+	if (stopPoints[i] < dpos || stopPoints[i] > (1 << 16))
+	{
+	    *error = BadValue;
+	    return FALSE;
+	}
+	dpos = stopPoints[i];
     }
 
-    pGradient->linear.stops = xalloc(stopCount*sizeof(PictGradientStop));
-    if (!pGradient->linear.stops) {
-        *error = BadAlloc;
-        return;
+    for (i = 0; i < stopCount; ++i)
+    {
+	pGradient->stops[i].x	  = stopPoints[i];
+	pGradient->stops[i].color = xRenderColorToCard32 (stopColors[i]);
     }
 
-    pGradient->linear.nstops = stopCount;
+    pGradient->class	      = SourcePictClassUnknown;
+    pGradient->stopRange      = 0xffff;
+    pGradient->colorTable     = NULL;
+    pGradient->colorTableSize = 0;
 
-    for (i = 0; i < stopCount; ++i) {
-        pGradient->linear.stops[i].x = stopPoints[i];
-        pGradient->linear.stops[i].color = stopColors[i];
-    }
-    initGradientColorTable(pGradient, error);
+    return TRUE;
 }
 
-static PicturePtr createSourcePicture(void)
+PicturePtr
+CreateDevicePicture (Picture pid,
+		     int     *error)
 {
     PicturePtr pPicture;
-    pPicture = (PicturePtr) xalloc(sizeof(PictureRec));
-    pPicture->pDrawable = 0;
-    pPicture->format = PICT_a8r8g8b8;
-    pPicture->pFormat = 0;
-    pPicture->pNext = 0;
-    pPicture->devPrivates = 0;
 
-    SetPictureToDefaults(pPicture);
+    pPicture = xalloc (sizeof (PictureRec) + sizeof (PictSourceRec));
+    if (!pPicture)
+    {
+	*error = BadAlloc;
+	return 0;
+    }
+
+    SourcePictureInit (pPicture,
+		       (SourcePictPtr) (pPicture + 1),
+		       SourcePictTypeOther);
+
+    pPicture->id = pid;
+
     return pPicture;
 }
 
@@ -993,21 +1062,22 @@ PicturePtr
 CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
 {
     PicturePtr pPicture;
-    pPicture = createSourcePicture();
-    if (!pPicture) {
-        *error = BadAlloc;
-        return 0;
+
+    pPicture = xalloc (sizeof (PictureRec) + sizeof (PictSolidFill));
+    if (!pPicture)
+    {
+	*error = BadAlloc;
+	return 0;
     }
 
+    SourcePictureInit (pPicture,
+		       (SourcePictPtr) (pPicture + 1),
+		       SourcePictTypeSolidFill);
+
     pPicture->id = pid;
-    pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill));
-    if (!pPicture->pSourcePict) {
-        *error = BadAlloc;
-        xfree(pPicture);
-        return 0;
-    }
-    pPicture->pSourcePict->type = SourcePictTypeSolidFill;
-    pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
+
+    pPicture->pSourcePict->solidFill.color = xRenderColorToCard32 (*color);
+
     return pPicture;
 }
 
@@ -1015,103 +1085,109 @@ PicturePtr
 CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
                              int nStops, xFixed *stops, xRenderColor *colors, int *error)
 {
-    PicturePtr pPicture;
+    PictLinearGradientPtr pLinear;
+    PicturePtr	          pPicture;
 
-    if (nStops < 2) {
-        *error = BadValue;
-        return 0;
+    if (nStops < 2)
+    {
+	*error = BadValue;
+	return 0;
     }
 
-    pPicture = createSourcePicture();
-    if (!pPicture) {
-        *error = BadAlloc;
-        return 0;
+    pPicture = xalloc (sizeof (PictureRec) +
+		       sizeof (PictLinearGradient) +
+		       sizeof (PictGradientStop) * nStops);
+    if (!pPicture)
+    {
+	*error = BadAlloc;
+	return 0;
     }
-    if (p1->x == p2->x && p1->y == p2->y) {
-        *error = BadValue;
-        return 0;
+
+    pLinear	    = (PictLinearGradientPtr) (pPicture + 1);
+    pLinear->stops  = (PictGradientStopPtr) (pLinear + 1);
+    pLinear->nstops = nStops;
+    pLinear->p1	    = *p1;
+    pLinear->p2	    = *p2;
+
+    if (!GradientPictureInit (pPicture,
+			 (PictGradientPtr) pLinear,
+			 SourcePictTypeLinear,
+			 nStops, stops, colors, error))
+    {
+	xfree (pPicture);
+	return 0;
     }
 
     pPicture->id = pid;
-    pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient));
-    if (!pPicture->pSourcePict) {
-        *error = BadAlloc;
-        xfree(pPicture);
-        return 0;
-    }
 
-    pPicture->pSourcePict->linear.type = SourcePictTypeLinear;
-    pPicture->pSourcePict->linear.p1 = *p1;
-    pPicture->pSourcePict->linear.p2 = *p2;
-
-    initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
-    if (*error) {
-        xfree(pPicture);
-        return 0;
-    }
     return pPicture;
 }
 
 #define FixedToDouble(x) ((x)/65536.)
 
 PicturePtr
-CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer,
-                             xFixed innerRadius, xFixed outerRadius,
-                             int nStops, xFixed *stops, xRenderColor *colors, int *error)
-{
-    PicturePtr pPicture;
-    PictRadialGradient *radial;
+CreateRadialGradientPicture (Picture	  pid,
+			     xPointFixed  *inner,
+			     xPointFixed  *outer,
+			     xFixed	  innerRadius,
+			     xFixed	  outerRadius,
+			     int	  nStops,
+			     xFixed	  *stops,
+			     xRenderColor *colors,
+			     int	  *error)
+{
+    PicturePtr		  pPicture;
+    PictRadialGradientPtr pRadial;
+    double		  x;
 
     if (nStops < 2) {
         *error = BadValue;
         return 0;
     }
 
-    pPicture = createSourcePicture();
-    if (!pPicture) {
-        *error = BadAlloc;
-        return 0;
+    pPicture = xalloc (sizeof (PictureRec) +
+		       sizeof (PictRadialGradient) +
+		       sizeof (PictGradientStop) * nStops);
+    if (!pPicture)
+    {
+	*error = BadAlloc;
+	return 0;
     }
+
+    pRadial	    = (PictRadialGradientPtr) (pPicture + 1);
+    pRadial->stops  = (PictGradientStopPtr) (pRadial + 1);
+    pRadial->nstops = nStops;
+
+    pRadial->inner  = *inner;
+    pRadial->outer  = *outer;
+    pRadial->inner_radius = innerRadius;
+    pRadial->outer_radius = outerRadius;
+
+    x = (double) innerRadius / (double) outerRadius;
+    pRadial->dx = (outer->x - inner->x);
+    pRadial->dy = (outer->y - inner->y);
+    pRadial->fx = (inner->x) - x * pRadial->dx;
+    pRadial->fy = (inner->y) - x * pRadial->dy;
+    pRadial->m = 1. / (1 + x);
+    pRadial->b = -x * pRadial->m;
+    pRadial->dx /= 65536.;
+    pRadial->dy /= 65536.;
+    pRadial->fx /= 65536.;
+    pRadial->fy /= 65536.;
+    x = outerRadius / 65536.;
+    pRadial->a = x * x - pRadial->dx * pRadial->dx - pRadial->dy * pRadial->dy;
+    
+    if (!GradientPictureInit (pPicture,
+			 (PictGradientPtr) pRadial,
+			 SourcePictTypeRadial,
+			 nStops, stops, colors, error))
     {
-        double dx = (double)(inner->x - outer->x);
-        double dy = (double)(inner->y - outer->y);
-        if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) {
-            *error = BadValue;
-            return 0;
-        }
+	xfree (pPicture);
+	return 0;
     }
 
     pPicture->id = pid;
-    pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient));
-    if (!pPicture->pSourcePict) {
-        *error = BadAlloc;
-        xfree(pPicture);
-        return 0;
-    }
-    radial = &pPicture->pSourcePict->radial;
 
-    radial->type = SourcePictTypeRadial;
-    {
-        double x = (double)innerRadius / (double)outerRadius;
-        radial->dx = (outer->x - inner->x);
-        radial->dy = (outer->y - inner->y);
-        radial->fx = (inner->x) - x*radial->dx;
-        radial->fy = (inner->y) - x*radial->dy;
-        radial->m = 1./(1+x);
-        radial->b = -x*radial->m;
-        radial->dx /= 65536.;
-        radial->dy /= 65536.;
-        radial->fx /= 65536.;
-        radial->fy /= 65536.;
-        x = outerRadius/65536.;
-        radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy;
-    }
-
-    initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
-    if (*error) {
-        xfree(pPicture);
-        return 0;
-    }
     return pPicture;
 }
 
@@ -1119,36 +1195,42 @@ PicturePtr
 CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle,
                               int nStops, xFixed *stops, xRenderColor *colors, int *error)
 {
-    PicturePtr pPicture;
+    PicturePtr		   pPicture;
+    PictConicalGradientPtr pConical;
 
-    if (nStops < 2) {
-        *error = BadValue;
-        return 0;
+    if (nStops < 2)
+    {
+	*error = BadValue;
+	return 0;
     }
 
-    pPicture = createSourcePicture();
-    if (!pPicture) {
-        *error = BadAlloc;
-        return 0;
+    pPicture = xalloc (sizeof (PictureRec) +
+		       sizeof (PictConicalGradient) +
+		       sizeof (PictGradientStop) * nStops);
+    if (!pPicture)
+    {
+	*error = BadAlloc;
+	return 0;
     }
 
-    pPicture->id = pid;
-    pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictConicalGradient));
-    if (!pPicture->pSourcePict) {
-        *error = BadAlloc;
-        xfree(pPicture);
-        return 0;
+pConical	     = (PictConicalGradientPtr) (pPicture + 1);
+    pConical->stops  = (PictGradientStopPtr) (pConical + 1);
+    pConical->nstops = nStops;
+
+    pConical->center = *center;
+    pConical->angle  = angle;
+
+    if (!GradientPictureInit (pPicture,
+			 (PictGradientPtr) pConical,
+			 SourcePictTypeConical,
+			 nStops, stops, colors, error))
+    {
+	xfree (pPicture);
+	return 0;
     }
 
-    pPicture->pSourcePict->conical.type = SourcePictTypeConical;
-    pPicture->pSourcePict->conical.center = *center;
-    pPicture->pSourcePict->conical.angle = angle;
-
-    initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
-    if (*error) {
-        xfree(pPicture);
-        return 0;
-    }
+    pPicture->id = pid;
+
     return pPicture;
 }
 
@@ -1459,25 +1541,20 @@ SetPictureClipRegion (PicturePtr    pPic
     return result;
 }
 
-static Bool
-transformIsIdentity(PictTransform *t)
-{
-    return ((t->matrix[0][0] == t->matrix[1][1]) &&
-            (t->matrix[0][0] == t->matrix[2][2]) &&
-            (t->matrix[0][0] != 0) &&
-            (t->matrix[0][1] == 0) &&
-            (t->matrix[0][2] == 0) &&
-            (t->matrix[1][0] == 0) &&
-            (t->matrix[1][2] == 0) &&
-            (t->matrix[2][0] == 0) &&
-            (t->matrix[2][1] == 0));
-}
 
 int
 SetPictureTransform (PicturePtr	    pPicture,
 		     PictTransform  *transform)
 {
-    if (transform && transformIsIdentity (transform))
+    static const PictTransform	identity = { {
+	{ xFixed1, 0x00000, 0x00000 },
+	{ 0x00000, xFixed1, 0x00000 },
+	{ 0x00000, 0x00000, xFixed1 },
+    } };
+    PictureScreenPtr	ps = pPicture->pDrawable ? GetPictureScreen(pPicture->pDrawable->pScreen) : 0;
+    int			result = 0;
+
+    if (transform && memcmp (transform, &identity, sizeof (PictTransform)) == 0)
 	transform = 0;
     
     if (transform)
@@ -1499,17 +1576,10 @@ SetPictureTransform (PicturePtr	    pPic
 	}
     }
     pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+    if (ps)
+    result = (*ps->ChangePictureTransform) (pPicture, transform);
 
-    if (pPicture->pDrawable != NULL) {
-	int result;
-	PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen);
-
-	result = (*ps->ChangePictureTransform) (pPicture, transform);
-
-	return result;
-    }
-
-    return Success;
+    return result;
 }
 
 void
@@ -1625,15 +1695,11 @@ FreePicture (pointer	value,
 
     if (--pPicture->refcnt == 0)
     {
-	if (pPicture->transform)
-	    xfree (pPicture->transform);
-        if (!pPicture->pDrawable) {
-            if (pPicture->pSourcePict) {
-                if (pPicture->pSourcePict->type != SourcePictTypeSolidFill)
-                    xfree(pPicture->pSourcePict->linear.stops);
-                xfree(pPicture->pSourcePict);
-            }
-        } else {
+        if (pPicture->transform)
+            xfree (pPicture->transform);
+
+	if (pPicture->pDrawable)
+	{
             ScreenPtr	    pScreen = pPicture->pDrawable->pScreen;
             PictureScreenPtr    ps = GetPictureScreen(pScreen);
 	
@@ -1662,6 +1728,10 @@ FreePicture (pointer	value,
                 (*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
             }
         }
+
+	if (pPicture->pSourcePict && pPicture->pSourcePict->source.Destroy)
+	    (*pPicture->pSourcePict->source.Destroy) (pPicture);
+
 	xfree (pPicture);
     }
     return Success;
diff --git a/render/picture.h b/render/picture.h
index 1b62234..56ac83a 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -63,6 +63,8 @@ typedef struct _Picture		*PicturePtr;
 #define PICT_TYPE_ABGR	3
 #define PICT_TYPE_COLOR	4
 #define PICT_TYPE_GRAY	5
+#define PICT_TYPE_YUY2  6
+#define PICT_TYPE_YV12  7
 
 #define PICT_FORMAT_COLOR(f)	(PICT_FORMAT_TYPE(f) & 2)
 
@@ -119,6 +121,10 @@ typedef enum _PictFormatShort {
    PICT_a1 =		PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0),
 
    PICT_g1 =		PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0),
+
+/* YUV formats */
+   PICT_yuy2 =		PICT_FORMAT(16,PICT_TYPE_YUY2,0,0,0,0),
+   PICT_yv12 =		PICT_FORMAT(12,PICT_TYPE_YV12,0,0,0,0),
 } PictFormatShort;
 
 /*
diff --git a/render/picturestr.h b/render/picturestr.h
index f1617f6..37654fb 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -30,6 +30,8 @@
 #include "scrnintstr.h"
 #include "resource.h"
 
+#define PictTypeOther 0xff
+
 typedef struct _DirectFormat {
     CARD16	    red, redMask;
     CARD16	    green, greenMask;
@@ -62,43 +64,79 @@ typedef struct _PictTransform {
     xFixed	    matrix[3][3];
 } PictTransform, *PictTransformPtr;
 
+typedef void (*DestroySourcePictProcPtr) (PicturePtr pPicture);
+
 #define PICT_GRADIENT_STOPTABLE_SIZE 1024
 #define SourcePictTypeSolidFill 0
-#define SourcePictTypeLinear 1
-#define SourcePictTypeRadial 2
-#define SourcePictTypeConical 3
+#define SourcePictTypeLinear    1
+#define SourcePictTypeRadial    2
+#define SourcePictTypeConical   3
+#define SourcePictTypeOther     4
+
+#define SourcePictClassUnknown    0
+#define SourcePictClassHorizontal 1
+#define SourcePictClassVertical   2
 
-typedef struct _PictSolidFill {
+typedef struct _PictSource {
     unsigned int type;
+    unsigned int class;
+    DevUnion devPrivate;
+    DestroySourcePictProcPtr Destroy;
+} PictSourceRec, *PictSourcePtr;
+
+typedef struct _PictSolidFill {
+    unsigned int	     type;
+    unsigned int	     class;
+    DevUnion		     devPrivate;
+    DestroySourcePictProcPtr Destroy;
     CARD32 color;
 } PictSolidFill, *PictSolidFillPtr;
 
 typedef struct _PictGradientStop {
     xFixed x;
-    xRenderColor color;
+    CARD32 color;
 } PictGradientStop, *PictGradientStopPtr;
 
 typedef struct _PictGradient {
-    unsigned int type;
+    unsigned int	     type;
+    unsigned int	     class;
+    DevUnion		     devPrivate;
+    DestroySourcePictProcPtr Destroy;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+    int	stopRange;
+    CARD32 *colorTable;
+    int	colorTableSize;
 } PictGradient, *PictGradientPtr;
 
 typedef struct _PictLinearGradient {
-    unsigned int type;
+    unsigned int	     type;
+    unsigned int	     class;
+    DevUnion		     devPrivate;
+    DestroySourcePictProcPtr Destroy;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+    int	stopRange;
+    CARD32 *colorTable;
+    int	colorTableSize;
     xPointFixed p1;
     xPointFixed p2;
 } PictLinearGradient, *PictLinearGradientPtr;
 
 typedef struct _PictRadialGradient {
-    unsigned int type;
+    unsigned int	     type;
+    unsigned int	     class;
+    DevUnion		     devPrivate;
+    DestroySourcePictProcPtr Destroy;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+    int	stopRange;
+    CARD32 *colorTable;
+    int	colorTableSize;
+    xPointFixed inner;
+    xPointFixed outer;
+    xFixed inner_radius;
+    xFixed outer_radius;
     double fx;
     double fy;
     double dx;
@@ -109,16 +147,22 @@ typedef struct _PictRadialGradient {
 } PictRadialGradient, *PictRadialGradientPtr;
 
 typedef struct _PictConicalGradient {
-    unsigned int type;
+    unsigned int	     type;
+    unsigned int	     class;
+    DevUnion		     devPrivate;
+    DestroySourcePictProcPtr Destroy;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+    int	stopRange;
+    CARD32 *colorTable;
+    int	colorTableSize;
     xPointFixed center;
     xFixed angle;
 } PictConicalGradient, *PictConicalGradientPtr;
 
 typedef union _SourcePict {
     unsigned int type;
+    PictSourceRec source;
     PictSolidFill solidFill;
     PictGradient gradient;
     PictLinearGradient linear;
@@ -624,6 +668,11 @@ Bool
 PictureTransformPoint3d (PictTransformPtr transform,
                          PictVectorPtr	vector);
 
+CARD32
+PictureGradientColor (PictGradientStopPtr stop1,
+		      PictGradientStopPtr stop2,
+		      CARD32	          x);
+
 void RenderExtensionInit (void);
 
 Bool
@@ -640,6 +689,10 @@ AddTraps (PicturePtr	pPicture,
 	  xTrap		*traps);
 
 PicturePtr
+CreateDevicePicture (Picture pid,
+		     int     *error);
+
+PicturePtr
 CreateSolidPicture (Picture pid,
                     xRenderColor *color,
                     int *error);
diff --git a/render/render.c b/render/render.c
index 348d4c6..60a0f31 100644
--- a/render/render.c
+++ b/render/render.c
@@ -390,7 +390,14 @@ ProcRenderQueryPictFormats (ClientPtr cl
 	}
 	ps = GetPictureScreenIfSet(pScreen);
 	if (ps)
-	    nformat += ps->nformats;
+	{
+	    for (d = 0; d < ps->nformats; d++)
+	    {
+		if (ps->formats[d].type == PictTypeIndexed ||
+		    ps->formats[d].type == PictTypeDirect)
+		    nformat++;
+	    }
+	}
     }
     if (pRenderClient->major_version == 0 && pRenderClient->minor_version < 6)
 	numSubpixel = 0;
@@ -427,6 +434,10 @@ ProcRenderQueryPictFormats (ClientPtr cl
 		 nformat < ps->nformats;
 		 nformat++, pFormat++)
 	    {
+		if (pFormat->type != PictTypeIndexed &&
+		    pFormat->type != PictTypeDirect)
+		    continue;
+
 		pictForm->id = pFormat->id;
 		pictForm->type = pFormat->type;
 		pictForm->depth = pFormat->depth;



More information about the xorg-commit mailing list