Merge in xgl changes to render extension.

This commit is contained in:
Alan Hourihane 2007-03-27 13:09:50 +01:00
parent 2e5271f759
commit 3cd35d45f1
5 changed files with 358 additions and 229 deletions

View file

@ -271,24 +271,18 @@ PictureResetFilters (ScreenPtr pScreen)
int int
SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams) SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
{ {
ScreenPtr pScreen;
PictureScreenPtr ps;
PictFilterPtr pFilter; PictFilterPtr pFilter;
xFixed *new_params; 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) { pScreen = pPicture->pDrawable->pScreen;
/* For source pictures, the picture isn't tied to a screen. So, ensure ps = GetPictureScreen(pScreen);
* that all screens can handle a filter we set for the picture. pFilter = PictureFindFilter (pScreen, name, len);
*/
for (s = 0; s < screenInfo.numScreens; s++) {
if (PictureFindFilter (screenInfo.screens[s], name, len)->id !=
pFilter->id)
{
return BadMatch;
}
}
}
if (!pFilter) if (!pFilter)
return BadName; return BadName;
@ -313,13 +307,8 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
pPicture->filter_params[i] = params[i]; pPicture->filter_params[i] = params[i];
pPicture->filter = pFilter->id; pPicture->filter = pFilter->id;
if (pPicture->pDrawable) { result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
ScreenPtr pScreen = pPicture->pDrawable->pScreen; params, nparams);
PictureScreenPtr ps = GetPictureScreen(pScreen); return result;
result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
params, nparams);
return result;
}
return Success; return Success;
} }

View file

@ -233,14 +233,10 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
formats[nformats].format = PICT_a1; formats[nformats].format = PICT_a1;
formats[nformats].depth = 1; formats[nformats].depth = 1;
nformats++; nformats++;
formats[nformats].format = PICT_FORMAT(BitsPerPixel(8), formats[nformats].format = PICT_a8;
PICT_TYPE_A,
8, 0, 0, 0);
formats[nformats].depth = 8; formats[nformats].depth = 8;
nformats++; nformats++;
formats[nformats].format = PICT_FORMAT(BitsPerPixel(4), formats[nformats].format = PICT_a4;
PICT_TYPE_A,
4, 0, 0, 0);
formats[nformats].depth = 4; formats[nformats].depth = 4;
nformats++; nformats++;
formats[nformats].format = PICT_a8r8g8b8; formats[nformats].format = PICT_a8r8g8b8;
@ -664,6 +660,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
xfree (formats); xfree (formats);
return FALSE; return FALSE;
} }
a = r = g = b = 0;
if (formats[n].type == PictTypeIndexed) if (formats[n].type == PictTypeIndexed)
{ {
VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid); VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
@ -671,9 +668,8 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
type = PICT_TYPE_COLOR; type = PICT_TYPE_COLOR;
else else
type = PICT_TYPE_GRAY; type = PICT_TYPE_GRAY;
a = r = g = b = 0;
} }
else else if (formats[n].type == PictTypeDirect)
{ {
if ((formats[n].direct.redMask| if ((formats[n].direct.redMask|
formats[n].direct.blueMask| formats[n].direct.blueMask|
@ -688,6 +684,10 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
g = Ones (formats[n].direct.greenMask); g = Ones (formats[n].direct.greenMask);
b = Ones (formats[n].direct.blueMask); 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); formats[n].format = PICT_FORMAT(0,type,a,r,g,b);
} }
ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec)); ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec));
@ -890,41 +890,72 @@ static unsigned int INTERPOLATE_PIXEL_256(unsigned int x, unsigned int a,
return x; 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; int begin_pos, end_pos;
xFixed incr, dpos; xFixed incr, dpos;
int pos, current_stop; int pos, current_stop;
PictGradientStopPtr stops = pGradient->linear.stops; PictGradientStopPtr stops = gradient->stops;
int nstops = pGradient->linear.nstops; 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 */ /* The position where the gradient begins and ends */
begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; begin_pos = (stops[0].x * gradient->colorTableSize) >> 16;
end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; end_pos = (stops[nstops - 1].x * gradient->colorTableSize) >> 16;
pos = 0; /* The position in the color table. */ pos = 0; /* The position in the color table. */
/* Up to first point */ /* Up to first point */
while (pos <= begin_pos) { while (pos <= begin_pos) {
pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color); gradient->colorTable[pos] = stops[0].color;
++pos; ++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. */ dpos = incr * pos; /* The position in terms of 0-1. */
current_stop = 0; /* We always interpolate between current and current + 1. */ current_stop = 0; /* We always interpolate between current and current + 1. */
/* Gradient area */ /* Gradient area */
while (pos < end_pos) { while (pos < end_pos) {
unsigned int current_color = xRenderColorToCard32(stops[current_stop].color); gradient->colorTable[pos] =
unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color); PictureGradientColor (&stops[current_stop],
&stops[current_stop + 1],
int dist = (int)(256*(dpos - stops[current_stop].x) dpos);
/ (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));
++pos; ++pos;
dpos += incr; dpos += incr;
@ -934,58 +965,96 @@ static void initGradientColorTable(SourcePictPtr pGradient, int *error)
} }
/* After last point */ /* After last point */
while (pos < PICT_GRADIENT_STOPTABLE_SIZE) { while (pos < gradient->colorTableSize) {
pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color); gradient->colorTable[pos] = stops[nstops - 1].color;
++pos; ++pos;
} }
} }
static void initGradient(SourcePictPtr pGradient, int stopCount, static void
xFixed *stopPoints, xRenderColor *stopColors, int *error) 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; int i;
xFixed dpos; xFixed dpos;
if (stopCount <= 0) { if (stopCount <= 0)
*error = BadValue; {
return; *error = BadValue;
return FALSE;
} }
SourcePictureInit (pPicture, (SourcePictPtr) pGradient, type);
dpos = -1; dpos = -1;
for (i = 0; i < stopCount; ++i) { for (i = 0; i < stopCount; ++i)
if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) { {
*error = BadValue; if (stopPoints[i] < dpos || stopPoints[i] > (1 << 16))
return; {
} *error = BadValue;
dpos = stopPoints[i]; return FALSE;
}
dpos = stopPoints[i];
} }
pGradient->linear.stops = xalloc(stopCount*sizeof(PictGradientStop)); for (i = 0; i < stopCount; ++i)
if (!pGradient->linear.stops) { {
*error = BadAlloc; pGradient->stops[i].x = stopPoints[i];
return; 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) { return TRUE;
pGradient->linear.stops[i].x = stopPoints[i];
pGradient->linear.stops[i].color = stopColors[i];
}
initGradientColorTable(pGradient, error);
} }
static PicturePtr createSourcePicture(void) PicturePtr
CreateDevicePicture (Picture pid,
int *error)
{ {
PicturePtr pPicture; 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; return pPicture;
} }
@ -993,21 +1062,22 @@ PicturePtr
CreateSolidPicture (Picture pid, xRenderColor *color, int *error) CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
{ {
PicturePtr pPicture; PicturePtr pPicture;
pPicture = createSourcePicture();
if (!pPicture) { pPicture = xalloc (sizeof (PictureRec) + sizeof (PictSolidFill));
*error = BadAlloc; if (!pPicture)
return 0; {
*error = BadAlloc;
return 0;
} }
SourcePictureInit (pPicture,
(SourcePictPtr) (pPicture + 1),
SourcePictTypeSolidFill);
pPicture->id = pid; pPicture->id = pid;
pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill));
if (!pPicture->pSourcePict) { pPicture->pSourcePict->solidFill.color = xRenderColorToCard32 (*color);
*error = BadAlloc;
xfree(pPicture);
return 0;
}
pPicture->pSourcePict->type = SourcePictTypeSolidFill;
pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
return pPicture; return pPicture;
} }
@ -1015,103 +1085,109 @@ PicturePtr
CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
int nStops, xFixed *stops, xRenderColor *colors, int *error) int nStops, xFixed *stops, xRenderColor *colors, int *error)
{ {
PicturePtr pPicture; PictLinearGradientPtr pLinear;
PicturePtr pPicture;
if (nStops < 2) { if (nStops < 2)
*error = BadValue; {
return 0; *error = BadValue;
return 0;
} }
pPicture = createSourcePicture(); pPicture = xalloc (sizeof (PictureRec) +
if (!pPicture) { sizeof (PictLinearGradient) +
*error = BadAlloc; sizeof (PictGradientStop) * nStops);
return 0; if (!pPicture)
{
*error = BadAlloc;
return 0;
} }
if (p1->x == p2->x && p1->y == p2->y) {
*error = BadValue; pLinear = (PictLinearGradientPtr) (pPicture + 1);
return 0; 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->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; return pPicture;
} }
#define FixedToDouble(x) ((x)/65536.) #define FixedToDouble(x) ((x)/65536.)
PicturePtr PicturePtr
CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer, CreateRadialGradientPicture (Picture pid,
xFixed innerRadius, xFixed outerRadius, xPointFixed *inner,
int nStops, xFixed *stops, xRenderColor *colors, int *error) xPointFixed *outer,
xFixed innerRadius,
xFixed outerRadius,
int nStops,
xFixed *stops,
xRenderColor *colors,
int *error)
{ {
PicturePtr pPicture; PicturePtr pPicture;
PictRadialGradient *radial; PictRadialGradientPtr pRadial;
double x;
if (nStops < 2) { if (nStops < 2) {
*error = BadValue; *error = BadValue;
return 0; return 0;
} }
pPicture = createSourcePicture(); pPicture = xalloc (sizeof (PictureRec) +
if (!pPicture) { sizeof (PictRadialGradient) +
*error = BadAlloc; sizeof (PictGradientStop) * nStops);
return 0; if (!pPicture)
}
{ {
double dx = (double)(inner->x - outer->x); *error = BadAlloc;
double dy = (double)(inner->y - outer->y); return 0;
if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) { }
*error = BadValue;
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))
{
xfree (pPicture);
return 0;
} }
pPicture->id = pid; 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; return pPicture;
} }
@ -1119,36 +1195,42 @@ PicturePtr
CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle, CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle,
int nStops, xFixed *stops, xRenderColor *colors, int *error) int nStops, xFixed *stops, xRenderColor *colors, int *error)
{ {
PicturePtr pPicture; PicturePtr pPicture;
PictConicalGradientPtr pConical;
if (nStops < 2) { if (nStops < 2)
*error = BadValue; {
return 0; *error = BadValue;
return 0;
} }
pPicture = createSourcePicture(); pPicture = xalloc (sizeof (PictureRec) +
if (!pPicture) { sizeof (PictConicalGradient) +
*error = BadAlloc; sizeof (PictGradientStop) * nStops);
return 0; if (!pPicture)
{
*error = BadAlloc;
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->id = pid; pPicture->id = pid;
pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictConicalGradient));
if (!pPicture->pSourcePict) {
*error = BadAlloc;
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;
}
return pPicture; return pPicture;
} }
@ -1459,25 +1541,20 @@ SetPictureClipRegion (PicturePtr pPicture,
return result; 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 int
SetPictureTransform (PicturePtr pPicture, SetPictureTransform (PicturePtr pPicture,
PictTransform *transform) 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; transform = 0;
if (transform) if (transform)
@ -1499,17 +1576,10 @@ SetPictureTransform (PicturePtr pPicture,
} }
} }
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
if (ps)
result = (*ps->ChangePictureTransform) (pPicture, transform);
if (pPicture->pDrawable != NULL) { return result;
int result;
PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen);
result = (*ps->ChangePictureTransform) (pPicture, transform);
return result;
}
return Success;
} }
void void
@ -1625,15 +1695,11 @@ FreePicture (pointer value,
if (--pPicture->refcnt == 0) if (--pPicture->refcnt == 0)
{ {
if (pPicture->transform) if (pPicture->transform)
xfree (pPicture->transform); xfree (pPicture->transform);
if (!pPicture->pDrawable) {
if (pPicture->pSourcePict) { if (pPicture->pDrawable)
if (pPicture->pSourcePict->type != SourcePictTypeSolidFill) {
xfree(pPicture->pSourcePict->linear.stops);
xfree(pPicture->pSourcePict);
}
} else {
ScreenPtr pScreen = pPicture->pDrawable->pScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen); PictureScreenPtr ps = GetPictureScreen(pScreen);
@ -1662,6 +1728,10 @@ FreePicture (pointer value,
(*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable); (*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
} }
} }
if (pPicture->pSourcePict && pPicture->pSourcePict->source.Destroy)
(*pPicture->pSourcePict->source.Destroy) (pPicture);
xfree (pPicture); xfree (pPicture);
} }
return Success; return Success;

View file

@ -63,6 +63,8 @@ typedef struct _Picture *PicturePtr;
#define PICT_TYPE_ABGR 3 #define PICT_TYPE_ABGR 3
#define PICT_TYPE_COLOR 4 #define PICT_TYPE_COLOR 4
#define PICT_TYPE_GRAY 5 #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) #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_a1 = PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0),
PICT_g1 = PICT_FORMAT(1,PICT_TYPE_GRAY,0,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; } PictFormatShort;
/* /*

View file

@ -30,6 +30,8 @@
#include "scrnintstr.h" #include "scrnintstr.h"
#include "resource.h" #include "resource.h"
#define PictTypeOther 0xff
typedef struct _DirectFormat { typedef struct _DirectFormat {
CARD16 red, redMask; CARD16 red, redMask;
CARD16 green, greenMask; CARD16 green, greenMask;
@ -62,43 +64,79 @@ typedef struct _PictTransform {
xFixed matrix[3][3]; xFixed matrix[3][3];
} PictTransform, *PictTransformPtr; } PictTransform, *PictTransformPtr;
typedef void (*DestroySourcePictProcPtr) (PicturePtr pPicture);
#define PICT_GRADIENT_STOPTABLE_SIZE 1024 #define PICT_GRADIENT_STOPTABLE_SIZE 1024
#define SourcePictTypeSolidFill 0 #define SourcePictTypeSolidFill 0
#define SourcePictTypeLinear 1 #define SourcePictTypeLinear 1
#define SourcePictTypeRadial 2 #define SourcePictTypeRadial 2
#define SourcePictTypeConical 3 #define SourcePictTypeConical 3
#define SourcePictTypeOther 4
#define SourcePictClassUnknown 0
#define SourcePictClassHorizontal 1
#define SourcePictClassVertical 2
typedef struct _PictSource {
unsigned int type;
unsigned int class;
DevUnion devPrivate;
DestroySourcePictProcPtr Destroy;
} PictSourceRec, *PictSourcePtr;
typedef struct _PictSolidFill { typedef struct _PictSolidFill {
unsigned int type; unsigned int type;
unsigned int class;
DevUnion devPrivate;
DestroySourcePictProcPtr Destroy;
CARD32 color; CARD32 color;
} PictSolidFill, *PictSolidFillPtr; } PictSolidFill, *PictSolidFillPtr;
typedef struct _PictGradientStop { typedef struct _PictGradientStop {
xFixed x; xFixed x;
xRenderColor color; CARD32 color;
} PictGradientStop, *PictGradientStopPtr; } PictGradientStop, *PictGradientStopPtr;
typedef struct _PictGradient { typedef struct _PictGradient {
unsigned int type; unsigned int type;
unsigned int class;
DevUnion devPrivate;
DestroySourcePictProcPtr Destroy;
int nstops; int nstops;
PictGradientStopPtr stops; PictGradientStopPtr stops;
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; int stopRange;
CARD32 *colorTable;
int colorTableSize;
} PictGradient, *PictGradientPtr; } PictGradient, *PictGradientPtr;
typedef struct _PictLinearGradient { typedef struct _PictLinearGradient {
unsigned int type; unsigned int type;
unsigned int class;
DevUnion devPrivate;
DestroySourcePictProcPtr Destroy;
int nstops; int nstops;
PictGradientStopPtr stops; PictGradientStopPtr stops;
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; int stopRange;
CARD32 *colorTable;
int colorTableSize;
xPointFixed p1; xPointFixed p1;
xPointFixed p2; xPointFixed p2;
} PictLinearGradient, *PictLinearGradientPtr; } PictLinearGradient, *PictLinearGradientPtr;
typedef struct _PictRadialGradient { typedef struct _PictRadialGradient {
unsigned int type; unsigned int type;
unsigned int class;
DevUnion devPrivate;
DestroySourcePictProcPtr Destroy;
int nstops; int nstops;
PictGradientStopPtr stops; 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 fx;
double fy; double fy;
double dx; double dx;
@ -109,16 +147,22 @@ typedef struct _PictRadialGradient {
} PictRadialGradient, *PictRadialGradientPtr; } PictRadialGradient, *PictRadialGradientPtr;
typedef struct _PictConicalGradient { typedef struct _PictConicalGradient {
unsigned int type; unsigned int type;
unsigned int class;
DevUnion devPrivate;
DestroySourcePictProcPtr Destroy;
int nstops; int nstops;
PictGradientStopPtr stops; PictGradientStopPtr stops;
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; int stopRange;
CARD32 *colorTable;
int colorTableSize;
xPointFixed center; xPointFixed center;
xFixed angle; xFixed angle;
} PictConicalGradient, *PictConicalGradientPtr; } PictConicalGradient, *PictConicalGradientPtr;
typedef union _SourcePict { typedef union _SourcePict {
unsigned int type; unsigned int type;
PictSourceRec source;
PictSolidFill solidFill; PictSolidFill solidFill;
PictGradient gradient; PictGradient gradient;
PictLinearGradient linear; PictLinearGradient linear;
@ -624,6 +668,11 @@ Bool
PictureTransformPoint3d (PictTransformPtr transform, PictureTransformPoint3d (PictTransformPtr transform,
PictVectorPtr vector); PictVectorPtr vector);
CARD32
PictureGradientColor (PictGradientStopPtr stop1,
PictGradientStopPtr stop2,
CARD32 x);
void RenderExtensionInit (void); void RenderExtensionInit (void);
Bool Bool
@ -639,6 +688,10 @@ AddTraps (PicturePtr pPicture,
int ntraps, int ntraps,
xTrap *traps); xTrap *traps);
PicturePtr
CreateDevicePicture (Picture pid,
int *error);
PicturePtr PicturePtr
CreateSolidPicture (Picture pid, CreateSolidPicture (Picture pid,
xRenderColor *color, xRenderColor *color,

View file

@ -390,7 +390,14 @@ ProcRenderQueryPictFormats (ClientPtr client)
} }
ps = GetPictureScreenIfSet(pScreen); ps = GetPictureScreenIfSet(pScreen);
if (ps) 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) if (pRenderClient->major_version == 0 && pRenderClient->minor_version < 6)
numSubpixel = 0; numSubpixel = 0;
@ -427,6 +434,10 @@ ProcRenderQueryPictFormats (ClientPtr client)
nformat < ps->nformats; nformat < ps->nformats;
nformat++, pFormat++) nformat++, pFormat++)
{ {
if (pFormat->type != PictTypeIndexed &&
pFormat->type != PictTypeDirect)
continue;
pictForm->id = pFormat->id; pictForm->id = pFormat->id;
pictForm->type = pFormat->type; pictForm->type = pFormat->type;
pictForm->depth = pFormat->depth; pictForm->depth = pFormat->depth;