xserver/render filter.c, 1.8, 1.9 picture.c, 1.44, 1.45 render.c,
1.36, 1.37
Dave Airlie
xserver-commit at pdx.freedesktop.org
Tue Jan 3 01:20:00 PST 2006
- Previous message: xserver/fb fb.h, 1.44, 1.45 fbbits.h, 1.16, 1.17 fbbltone.c, 1.16,
1.17 fbcompose.c, 1.38, 1.39 fbpict.c, 1.45, 1.46 fbtile.c, 1.6, 1.7
- Next message: xserver ChangeLog,3.379,3.380
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: airlied
Update of /cvs/xserver/xserver/render
In directory gabe:/tmp/cvs-serv11094/render
Modified Files:
filter.c picture.c render.c
Log Message:
fb/render changes from Xgl
Index: filter.c
===================================================================
RCS file: /cvs/xserver/xserver/render/filter.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- filter.c 13 Jun 2005 08:00:59 -0000 1.8
+++ filter.c 3 Jan 2006 09:19:58 -0000 1.9
@@ -250,12 +250,19 @@
int
SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
{
- ScreenPtr pScreen = pPicture->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- PictFilterPtr pFilter = PictureFindFilter (pScreen, name, len);
+ ScreenPtr pScreen;
+ PictureScreenPtr ps;
+ PictFilterPtr pFilter;
xFixed *new_params;
int i, result;
+ if (!pPicture->pDrawable)
+ return Success;
+
+ pScreen = pPicture->pDrawable->pScreen;
+ ps = GetPictureScreen(pScreen);
+ pFilter = PictureFindFilter (pScreen, name, len);
+
if (!pFilter)
return BadName;
if (pFilter->ValidateParams)
Index: picture.c
===================================================================
RCS file: /cvs/xserver/xserver/render/picture.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- picture.c 1 Jul 2005 08:17:26 -0000 1.44
+++ picture.c 3 Jan 2006 09:19:58 -0000 1.45
@@ -607,6 +607,7 @@
xfree (formats);
return FALSE;
}
+ a = r = g = b = 0;
if (formats[n].type == PictTypeIndexed)
{
VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
@@ -614,9 +615,8 @@
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|
@@ -631,6 +631,10 @@
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));
@@ -808,12 +812,12 @@
static uint premultiply(uint x)
{
uint a = x >> 24;
- uint t = (x & 0xff00ff) * a;
- t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
+ uint t = (x & 0xff00ff) * a + 0x800080;
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8;
t &= 0xff00ff;
- x = ((x >> 8) & 0xff) * a;
- x = (x + ((x >> 8) & 0xff) + 0x80);
+ x = ((x >> 8) & 0xff) * a + 0x80;
+ x = (x + ((x >> 8) & 0xff));
x &= 0xff00;
x |= t | (a << 24);
return x;
@@ -831,41 +835,72 @@
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) {
- uint current_color = xRenderColorToCard32(stops[current_stop].color);
- uint 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;
@@ -875,219 +910,285 @@
}
/* 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;
+ int i;
- 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->pFormat = 0;
- pPicture->pNext = 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;
}
PicturePtr
-CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
+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;
}
PicturePtr
-CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
- int nStops, xFixed *stops, xRenderColor *colors, int *error)
+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;
- }
- if (p1->x == p2->x && p1->y == p2->y) {
- *error = BadValue;
- return 0;
+ pPicture = xalloc (sizeof (PictureRec) +
+ sizeof (PictLinearGradient) +
+ sizeof (PictGradientStop) * nStops);
+ if (!pPicture)
+ {
+ *error = BadAlloc;
+ return 0;
}
- pPicture->id = pid;
- pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient));
- if (!pPicture->pSourcePict) {
- *error = BadAlloc;
- xfree(pPicture);
- 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->pSourcePict->linear.type = SourcePictTypeLinear;
- pPicture->pSourcePict->linear.p1 = *p1;
- pPicture->pSourcePict->linear.p2 = *p2;
+ pPicture->id = pid;
- 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)
+CreateRadialGradientPicture (Picture pid,
+ xPointFixed *inner,
+ xPointFixed *outer,
+ xFixed innerRadius,
+ xFixed outerRadius,
+ int nStops,
+ xFixed *stops,
+ xRenderColor *colors,
+ int *error)
{
- PicturePtr pPicture;
- PictRadialGradient *radial;
+ PicturePtr pPicture;
+ PictRadialGradientPtr pRadial;
+ double x;
- 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 (PictRadialGradient) +
+ sizeof (PictGradientStop) * nStops);
+ if (!pPicture)
{
- 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;
- }
+ *error = BadAlloc;
+ return 0;
}
- pPicture->id = pid;
- pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient));
- if (!pPicture->pSourcePict) {
- *error = BadAlloc;
- xfree(pPicture);
- return 0;
- }
- radial = &pPicture->pSourcePict->radial;
+ pRadial = (PictRadialGradientPtr) (pPicture + 1);
+ pRadial->stops = (PictGradientStopPtr) (pRadial + 1);
+ pRadial->nstops = nStops;
- radial->type = SourcePictTypeRadial;
+ 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 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;
+ xfree (pPicture);
+ return 0;
}
- initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
- if (*error) {
- xfree(pPicture);
- return 0;
- }
+ pPicture->id = pid;
+
return pPicture;
}
PicturePtr
-CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle,
- int nStops, xFixed *stops, xRenderColor *colors, int *error)
+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;
- pPicture->pSourcePict->conical.type = SourcePictTypeConical;
- pPicture->pSourcePict->conical.center = *center;
- pPicture->pSourcePict->conical.angle = angle;
+ pConical->center = *center;
+ pConical->angle = angle;
- initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
- if (*error) {
- xfree(pPicture);
- return 0;
+ if (!GradientPictureInit (pPicture,
+ (PictGradientPtr) pConical,
+ SourcePictTypeConical,
+ nStops, stops, colors, error))
+ {
+ xfree (pPicture);
+ return 0;
}
+
+ pPicture->id = pid;
+
return pPicture;
}
@@ -1463,13 +1564,9 @@
{
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->pDrawable)
+ {
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
@@ -1498,6 +1595,10 @@
(*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
}
}
+
+ if (pPicture->pSourcePict && pPicture->pSourcePict->source.Destroy)
+ (*pPicture->pSourcePict->source.Destroy) (pPicture);
+
xfree (pPicture);
}
return Success;
Index: render.c
===================================================================
RCS file: /cvs/xserver/xserver/render/render.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- render.c 29 Jun 2005 15:14:17 -0000 1.36
+++ render.c 3 Jan 2006 09:19:58 -0000 1.37
@@ -381,7 +381,14 @@
}
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;
@@ -418,6 +425,10 @@
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;
@@ -741,9 +752,11 @@
RenderErrBase + BadPicture);
VERIFY_ALPHA (pMask, stuff->mask, client, SecurityReadAccess,
RenderErrBase + BadPicture);
- if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) ||
- (pMask && pMask->pDrawable && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen))
- return BadMatch;
+ if (pSrc->pDrawable && ((pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) ||
+ (pMask && pMask->pDrawable && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen)))
+ return BadMatch;
+ else if (pMask && pMask->pDrawable && pMask->pDrawable->pScreen != pDst->pDrawable->pScreen)
+ return BadMatch;
CompositePicture (stuff->op,
pSrc,
pMask,
- Previous message: xserver/fb fb.h, 1.44, 1.45 fbbits.h, 1.16, 1.17 fbbltone.c, 1.16,
1.17 fbcompose.c, 1.38, 1.39 fbpict.c, 1.45, 1.46 fbtile.c, 1.6, 1.7
- Next message: xserver ChangeLog,3.379,3.380
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the xserver-commit
mailing list