Commit a4011258 authored by Deron Johnson's avatar Deron Johnson
Browse files

Integrate updates from Xorg 6.8.2 RC2.

VS: ----------------------------------------------------------------------
parent b17cfa15
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/Xext/saver.c,v 1.2.4.2 2004/12/13 03:34:33 gisburn Exp $ */
/*
* $XConsortium: saver.c,v 1.12 94/04/17 20:59:36 dpw Exp $
*
......@@ -210,7 +210,7 @@ static int ScreenPrivateIndex;
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL)
#define New(t) ((t *) xalloc (sizeof (t)))
......@@ -1185,6 +1185,7 @@ ScreenSaverUnsetAttributes (ClientPtr client)
pPriv = GetScreenPrivate (pDraw->pScreen);
if (pPriv && pPriv->attr && pPriv->attr->client == client)
{
FreeResource (pPriv->attr->resource, AttrType);
FreeScreenAttr (pPriv->attr);
pPriv->attr = NULL;
CheckScreenPrivate (pDraw->pScreen);
......
......@@ -99,12 +99,12 @@ static int FontShmdescIndex;
static unsigned int pagesize;
static Bool badSysCall = FALSE;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
#include <sys/signal.h>
static Bool badSysCall = FALSE;
static void
SigSysHandler(
int signo)
......@@ -471,13 +471,16 @@ ProcXF86BigfontQueryFont(
if (nCharInfos > 0) {
#ifdef HAS_SHM
pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
if (!badSysCall)
pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
else
pDesc = NULL;
if (pDesc) {
pCI = (xCharInfo *) pDesc->attach_addr;
if (stuff_flags & XF86Bigfont_FLAGS_Shm)
shmid = pDesc->shmid;
} else {
if (stuff_flags & XF86Bigfont_FLAGS_Shm)
if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall)
pDesc = shmalloc(nCharInfos * sizeof(xCharInfo)
+ sizeof(CARD32));
if (pDesc) {
......@@ -522,7 +525,7 @@ ProcXF86BigfontQueryFont(
}
}
#ifdef HAS_SHM
if (pDesc) {
if (pDesc && !badSysCall) {
*(CARD32 *)(pCI + nCharInfos) = signature;
if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) {
shmdealloc(pDesc);
......
......@@ -163,6 +163,7 @@ static
PixmapFormatRec PSPixmapFormats[] = {
{ 1, 1, BITMAP_SCANLINE_PAD },
{ 8, 8, BITMAP_SCANLINE_PAD },
{ 12, 16, BITMAP_SCANLINE_PAD },
{ 24, 32, BITMAP_SCANLINE_PAD }
};
......@@ -1217,9 +1218,9 @@ AugmentFontPath(void)
* calling XpContextOfClient (in Xserver/Xext/xprint.c) to determine
* the context associated with the client, and then queries the context's
* attributes to determine whether the bitmap fonts should be visible.
* It looks at the value of the xp-listfonts-mode document/page attribute to
* It looks at the value of the xp-listfonts-modes document/page attribute to
* see if xp-list-glyph-fonts has been left out of the mode list. Only
* if the xp-listfonts-mode attribute exists, and it does not contain
* if the xp-listfonts-modes attribute exists, and it does not contain
* xp-list-glyph-fonts does this function return FALSE. In any other
* case the funtion returns TRUE, indicating that the bitmap fonts
* should be visible to the client.
......@@ -1238,10 +1239,10 @@ XpClientIsBitmapClient(
* Check the page attributes, and if it's not defined there, then
* check the document attributes.
*/
mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-mode");
mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-modes");
if(!mode || !strlen(mode))
{
mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-mode");
mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-modes");
if(!mode || !strlen(mode))
return TRUE;
}
......@@ -1251,14 +1252,21 @@ XpClientIsBitmapClient(
return TRUE;
}
/*
* XpClientIsPrintClient is called by the font code to find out if
* a particular client has set a context which references a printer
* which utilizes a particular font path. This function works by
* calling XpContextOfClient (in Xserver/Xext/xprint.c) to determine
* the context associated with the client, and then looks up the
* font directory for the context. The font directory is then compared
* with the directory specified in the FontPathElement which is passed in.
* which utilizes a particular font path.
* This function works by calling XpContextOfClient
* (in Xserver/Xext/xprint.c) to determine the context associated with
* the client and then looks at the value of the xp-listfonts-modes
* document/page attribute to see if xp-list-internal-printer-fonts has
* been left out of the mode list.
* If the xp-listfonts-modes attribute exists, and it does not contain
* xp-list-internal-printer-fonts this function returns FALSE.
* Otherwise it looks up the font directory for the context. The font
* directory is then compared with the directory specified in the
* FontPathElement which is passed in.
*/
Bool
XpClientIsPrintClient(
......@@ -1266,11 +1274,28 @@ XpClientIsPrintClient(
FontPathElementPtr fpe)
{
XpContextPtr pContext;
char *mode;
char *modelID, *fontDir;
if(!(pContext = XpContextOfClient(client)))
return FALSE;
/*
* Check the page attributes, and if it's not defined there, then
* check the document attributes.
*/
mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-modes");
if(!mode || !strlen(mode))
{
mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-modes");
}
if(mode && strlen(mode))
{
if(!strstr(mode, "xp-list-internal-printer-fonts"))
return FALSE;
}
if (!fpe)
return TRUE;
......
......@@ -2104,16 +2104,16 @@ const char* XpOidNotifyString(XpOidNotify notify)
{
switch(notify)
{
case XPOID_NOTIFY_UNSUPPORTED:
return (const char*)NULL;
break;
case XPOID_NOTIFY_NONE:
return NOTIFY_NONE_STR;
break;
case XPOID_NOTIFY_EMAIL:
return NOTIFY_EMAIL_STR;
break;
case XPOID_NOTIFY_NONE:
return NOTIFY_NONE_STR;
case XPOID_NOTIFY_EMAIL:
return NOTIFY_EMAIL_STR;
case XPOID_NOTIFY_UNSUPPORTED:
return (const char *)NULL;
}
ErrorF("XpOidNotifyString: Unsupported notify=%ld\n", (long)notify);
return (const char *)NULL;
}
/*
......
......@@ -1515,6 +1515,8 @@ XpSubmitJob(fileName, pContext)
FreeVector(vector);
xfree(cmdNam);
return Success;
}
/*
......
......@@ -329,12 +329,12 @@ AllocatePclPrivates(ScreenPtr pScreen)
*/
static char DOC_ATT_SUPP[]="document-attributes-supported";
static char DOC_ATT_VAL[]="document-format";
static char DOC_ATT_VAL[]="document-format xp-listfonts-modes";
static char JOB_ATT_SUPP[]="job-attributes-supported";
static char JOB_ATT_VAL[]="";
static char PAGE_ATT_SUPP[]="xp-page-attributes-supported";
static char PAGE_ATT_VAL[]="content-orientation default-printer-resolution \
default-input-tray default-medium plex";
default-input-tray default-medium plex xp-listfonts-modes";
static int
PclInitContext(XpContextPtr pCon)
......@@ -427,7 +427,7 @@ PclInitContext(XpContextPtr pCon)
server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP );
if( ( attrStr = (char *)xalloc(strlen(server) + strlen(DOC_ATT_SUPP)
+ strlen(DOC_ATT_VAL) +
strlen(PAGE_ATT_VAL) + 6 ) )
strlen(PAGE_ATT_VAL) + 8 ) )
== (char *)NULL )
return BadAlloc;
sprintf( attrStr, "*%s:\t%s %s %s", DOC_ATT_SUPP, server,
......@@ -440,7 +440,7 @@ PclInitContext(XpContextPtr pCon)
*/
server = XpGetOneAttribute( pCon, XPServerAttr, JOB_ATT_SUPP );
if( ( attrStr = (char *)xalloc(strlen(server) + strlen(JOB_ATT_SUPP)
+ strlen(JOB_ATT_VAL) + 4 ) )
+ strlen(JOB_ATT_VAL) + 8 ) )
== (char *)NULL )
return BadAlloc;
sprintf( attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL );
......@@ -452,7 +452,7 @@ PclInitContext(XpContextPtr pCon)
*/
server = XpGetOneAttribute( pCon, XPServerAttr, PAGE_ATT_SUPP );
if( ( attrStr = (char *)xalloc(strlen(server) + strlen(PAGE_ATT_SUPP)
+ strlen(PAGE_ATT_VAL) + 4 ) )
+ strlen(PAGE_ATT_VAL) + 8 ) )
== (char *)NULL )
return BadAlloc;
sprintf( attrStr, "*%s:\t%s %s", PAGE_ATT_SUPP, server, PAGE_ATT_VAL );
......
......@@ -556,7 +556,7 @@ extern int PsListInstalledColormaps(ScreenPtr pScreen, XID *pCmapList);
extern void PsStoreColors(ColormapPtr pColor, int ndef, xColorItem *pdefs);
extern void PsResolveColor(unsigned short *pRed, unsigned short *pGreen,
unsigned short *pBlue, VisualPtr pVisual);
extern int PsGetPixelColor(ColormapPtr cMap, int pixval);
extern PsOutColor PsGetPixelColor(ColormapPtr cMap, int pixval);
extern void PsSetFillColor(DrawablePtr pDrawable, GCPtr pGC, PsOutPtr psOut,
ColormapPtr cMap);
......@@ -566,6 +566,7 @@ extern void PsSetFillColor(DrawablePtr pDrawable, GCPtr pGC, PsOutPtr psOut,
extern PixmapPtr PsCreatePixmap(ScreenPtr pScreen, int width, int height,
int depth);
extern void PsScrubPixmap(PixmapPtr pPixmap);
extern Bool PsDestroyPixmap(PixmapPtr pPixmap);
extern DisplayListPtr PsGetFreeDisplayBlock(PsPixmapPrivPtr priv);
extern void PsReplayPixmap(PixmapPtr pix, DrawablePtr pDrawable);
......
......@@ -131,6 +131,13 @@ PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
pt = (char *)(&i); i = 1; if( pt[0]=='\001' ) swap = 1; else swap = 0;
#ifdef PSOUT_USE_DEEPCOLOR
if( depth==30 )
{
ErrorF("PsPutScaledImage: Not implemented yet for 30bit\m");
}
else
#endif /* PSOUT_USE_DEEPCOLOR */
if( depth==24 )
{
PsOut_BeginImage(psOut, 0, 0, x, y, w, h, sw, sh, 3);
......@@ -174,6 +181,34 @@ PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
else goto error;
PsOut_EndImage(psOut);
}
#ifdef PSOUT_USE_DEEPCOLOR
else if( (depth > 8) && (depth < 16) )
{
int rowsiz = PixmapBytePad(w, depth);
PsOut_BeginImage(psOut, 0, 0, x, y, w, h, sw, sh, 3);
for( r=0 ; r<h ; r++ )
{
short *pt = (short *)&pImage[rowsiz*r];
for( c=0 ; c<w ; c++,pt++ )
{
PsOutColor clr = PsGetPixelColor(cMap, (int)(*pt)&0xFFFF);
/* XXX: This needs to be fixed for endian swapping and to support
* depths deeper than 8bit per R-,G-,B-gun... */
int val = PSOUTCOLOR_TO_RGB24BIT(clr);
char *ipt = (char *)&val;
if( swap )
{
char tmp[4];
tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0];
PsOut_OutImageBytes(psOut, 3, &tmp[1]);
}
else
PsOut_OutImageBytes(psOut, 3, &ipt[1]);
}
}
PsOut_EndImage(psOut);
}
#endif /* PSOUT_USE_DEEPCOLOR */
else if( depth==8 )
{
int rowsiz = PixmapBytePad(w, depth);
......@@ -183,8 +218,9 @@ PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
char *pt = &pImage[rowsiz*r];
for( c=0 ; c<w ; c++,pt++ )
{
int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
char *ipt = (char *)&val;
PsOutColor clr = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
int val = PSOUTCOLOR_TO_RGB24BIT(clr);
char *ipt = (char *)&val;
if( swap )
{
char tmp[4];
......@@ -296,6 +332,14 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
PsOut_BeginImageCache(psOut, cache_id);
#endif
#ifdef PSOUT_USE_DEEPCOLOR
if( depth==30 )
{
ErrorF("PsPutScaledImageIM: Not implemented yet for 30bit\m");
}
else
#endif /* PSOUT_USE_DEEPCOLOR */
if( depth==24 )
{
PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
......@@ -339,6 +383,32 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
else goto error;
PsOut_EndImage(psOut);
}
#ifdef PSOUT_USE_DEEPCOLOR
else if( (depth > 8) && (depth < 16) )
{
int rowsiz = PixmapBytePad(w, depth);
PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
for( r=0 ; r<h ; r++ )
{
short *pt = (short *)&pImage[rowsiz*r];
for( c=0 ; c<w ; c++,pt++ )
{
PsOutColor clr = PsGetPixelColor(cMap, (int)(*pt)&0xFFFF);
int val = PSOUTCOLOR_TO_RGB24BIT(clr);
char *ipt = (char *)&val;
if( swap )
{
char tmp[4];
tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0];
PsOut_OutImageBytes(psOut, 3, &tmp[1]);
}
else
PsOut_OutImageBytes(psOut, 3, &ipt[1]);
}
}
PsOut_EndImage(psOut);
}
#endif /* PSOUT_USE_DEEPCOLOR */
else if( depth==8 )
{
int rowsiz = PixmapBytePad(w, depth);
......@@ -348,8 +418,11 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
char *pt = &pImage[rowsiz*r];
for( c=0 ; c<w ; c++,pt++ )
{
int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
char *ipt = (char *)&val;
PsOutColor clr = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
/* XXX: This needs to be fixed for endian swapping and to support
* depths deeper than 8bit per R-,G-,B-gun... */
int val = PSOUTCOLOR_TO_RGB24BIT(clr);
char *ipt = (char *)&val;
if( swap )
{
char tmp[4];
......
......@@ -75,6 +75,8 @@ in this Software without prior written authorization from The Open Group.
********************************************************************/
#include "Ps.h"
#include "mi.h"
#include "micmap.h"
#include "gcstruct.h"
#include "windowstr.h"
#include "colormapst.h"
......@@ -82,49 +84,25 @@ in this Software without prior written authorization from The Open Group.
Bool
PsCreateColormap(ColormapPtr pColor)
{
int i;
unsigned short rgb;
VisualPtr pVisual = pColor->pVisual;
Pixel pix;
if( pVisual->class==TrueColor )
{
for( i=0 ; i<pVisual->ColormapEntries ; i++ )
{
rgb = (i<<8)|i;
pColor->red[i].fShared = FALSE;
pColor->red[i].co.local.red = rgb;
pColor->red[i].co.local.green = 0;
pColor->red[i].co.local.blue = 0;
pColor->green[i].fShared = FALSE;
pColor->green[i].co.local.red = 0;
pColor->green[i].co.local.green = rgb;
pColor->green[i].co.local.blue = 0;
pColor->blue[i].fShared = FALSE;
pColor->blue[i].co.local.red = 0;
pColor->blue[i].co.local.green = 0;
pColor->blue[i].co.local.blue = rgb;
}
}
return TRUE;
return miInitializeColormap(pColor);
}
void
PsDestroyColormap(ColormapPtr pColor)
{
/* NO-OP */
}
void
PsInstallColormap(ColormapPtr pColor)
{
miInstallColormap(pColor);
}
void
PsUninstallColormap(ColormapPtr pColor)
{
miUninstallColormap(pColor);
}
int
......@@ -132,7 +110,7 @@ PsListInstalledColormaps(
ScreenPtr pScreen,
XID *pCmapList)
{
return 0;
return miListInstalledColormaps(pScreen, pCmapList);
}
void
......@@ -160,18 +138,71 @@ PsResolveColor(
unsigned short *pBlue,
VisualPtr pVisual)
{
miResolveColor(pRed, pGreen, pBlue, pVisual);
}
int
PsOutColor
PsGetPixelColor(ColormapPtr cMap, int pixval)
{
int r, g, b;
if( cMap->pVisual->class==TrueColor ) return(pixval);
if( pixval<0 || pixval>255 ) return(0);
r = cMap->red[pixval].co.local.red>>8;
g = cMap->red[pixval].co.local.green>>8;
b = cMap->red[pixval].co.local.blue>>8;
return((r<<16)|(g<<8)|b);
VisualPtr v = cMap->pVisual;
switch( v->class )
{
case TrueColor:
{
PsOutColor p = pixval;
PsOutColor r, g, b;
#ifdef PSOUT_USE_DEEPCOLOR
int shift = 16 - v->bitsPerRGBValue;
#else
int shift = 8 - v->bitsPerRGBValue;
#endif /* PSOUT_USE_DEEPCOLOR */
r = ((p & v->redMask) >> v->offsetRed) << shift;
g = ((p & v->greenMask) >> v->offsetGreen) << shift;
b = ((p & v->blueMask) >> v->offsetBlue) << shift;
#ifdef PSOUT_USE_DEEPCOLOR
return((r<<32)|(g<<16)|b);
#else
return((r<<16)|(g<<8)|b);
#endif /* PSOUT_USE_DEEPCOLOR */
}
case PseudoColor:
case GrayScale:
case StaticGray:
{
PsOutColor r, g, b;
if( pixval < 0 || pixval > v->ColormapEntries)
return(0);
r = cMap->red[pixval].co.local.red;
g = cMap->red[pixval].co.local.green;
b = cMap->red[pixval].co.local.blue;
if ((v->class | DynamicClass) == GrayScale)
{
/* rescale to gray (see |miResolveColor()|) */
r = g = b = (30L*r + 59L*g + 11L*b) / 100L;
}
#ifdef PSOUT_USE_DEEPCOLOR
return((r<<32)|(g<<16)|b);
#else
r >>= 8;
g >>= 8;
b >>= 8;
return((r<<16)|(g<<8)|b);
#endif /* PSOUT_USE_DEEPCOLOR */
}
default:
FatalError("PsGetPixelColor: Unsupported visual %x\n",
(int)cMap->pVisual->class);
break;
}
return 0; /* NO-OP*/
}
void
......
......@@ -380,6 +380,16 @@ PsCreateAndCopyGC(DrawablePtr pDrawable, GCPtr pSrc)
{
GCPtr pDst;
if (pSrc == NULL) {
/* https://freedesktop.org/bugzilla/show_bug.cgi?id=1416 ("'x11perf
* -copypixpix500' crashes Xprt's PostScript DDX [PsCreateAndCopyGC"):
* I have no clue whether this is the real fix or just wallpapering
* over the crash (that's why we warn here loudly when this
* happens) ... */
fprintf(stderr, "PsCreateAndCopyGC: pSrc == NULL\n");
return NULL;
}
if ((pDst =
CreateScratchGC(pDrawable->pScreen, pDrawable->depth)) == NULL)
{
......
......@@ -119,8 +119,18 @@ InitializePsDriver(ndx, pScreen, argc, argv)
#endif
char **printerNames;
int numPrinters;
int nVisuals;
int nDepths;
int nv, /* total number of visuals */
nv_1bit, /* number of 8bit visuals */
nv_8bit, /* number of 8bit visuals */
nv_12bit, /* number of 12bit visuals */
nv_24bit, /* number of 24bit visuals*/
nv_30bit; /* number of 30bit visuals*/
int nd; /* number of depths */
VisualID *vids_1bit,
*vids_8bit,
*vids_12bit,
*vids_24bit,
*vids_30bit;
VisualPtr visuals;
DepthPtr depths;
VisualID defaultVisual;
......@@ -179,44 +189,180 @@ InitializePsDriver(ndx, pScreen, argc, argv)
/* Will BitmapToRegion make any difference at all? */
pScreen->BitmapToRegion = mfbPixmapToRegion;
nVisuals = 2;
nDepths = 2;
visuals = (VisualPtr)xalloc(nVisuals*sizeof(VisualRec));
depths = (DepthPtr) xalloc(nDepths*sizeof(DepthRec));
visuals[0].vid = FakeClientID(0);
visuals[0].class = TrueColor;
visuals[0].bitsPerRGBValue = 8;
visuals[0].ColormapEntries = 256;
visuals[0].nplanes = 24;
visuals[0].redMask = 0x00FF0000;
visuals[0].greenMask = 0x0000FF00;
visuals[0].blueMask = 0x000000FF;
visuals[0].offsetRed = 16;
visuals[0].offsetGreen = 8;
visuals[0].offsetBlue = 0;
visuals[1].vid = FakeClientID(0);
visuals[1].class = PseudoColor;
visuals[1].bitsPerRGBValue = 8;
visuals[1].ColormapEntries = 256;
visuals[1].nplanes = 8;
visuals[1].redMask = 0x0;
visuals[1].greenMask = 0x0;
visuals[1].blueMask = 0x0;
visuals[1].offsetRed = 0x0;
visuals[1].offsetGreen = 0x0;
visuals[1].offsetBlue = 0x0;
depths[0].depth = 24;
depths[0].numVids = 1;
depths[0].vids = (VisualID *)xalloc(sizeof(VisualID));
depths[0].vids[0] = visuals[0].vid;
depths[1].depth = 8;
depths[1].numVids = 1;
depths[1].vids = (VisualID *)xalloc(sizeof(VisualID));
depths[1].vids[0] = visuals[1].vid;
visuals = (VisualPtr) xalloc(8*sizeof(VisualRec));
depths = (DepthPtr) xalloc(8*sizeof(DepthRec));
vids_1bit = (VisualID *)xalloc(8*sizeof(VisualID));
vids_8bit = (VisualID *)xalloc(8*sizeof(VisualID));
vids_12bit = (VisualID *)xalloc(8*sizeof(VisualID));
vids_24bit = (VisualID *)xalloc(8*sizeof(VisualID));
vids_30bit = (VisualID *)xalloc(8*sizeof(VisualID));
nv = nv_1bit = nv_8bit = nv_12bit = nv_24bit = nv_30bit = nd = 0;