Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.424 diff -u -2 -0 -r1.424 ChangeLog --- xc/ChangeLog 3 Oct 2004 23:54:40 -0000 1.424 +++ xc/ChangeLog 4 Oct 2004 04:57:36 -0000 @@ -1,20 +1,33 @@ +2004-10-03 Roland Mainz + * xc/programs/Xserver/Xprint/Init.c + * xc/programs/Xserver/Xprint/ps/Ps.h + * xc/programs/Xserver/Xprint/ps/PsArea.c + * xc/programs/Xserver/Xprint/ps/PsColor.c + * xc/programs/Xserver/Xprint/ps/PsInit.c + * xc/programs/Xserver/Xprint/ps/psout.c + * xc/programs/Xserver/Xprint/ps/psout.h + Bugzilla #1299: Add more visuals to the Postscript DDX (8bit + GrayScale/StaticGray, 1bit StaticGray and the basic + infratructure for "deep" visuals with more than 8bits per RGB + gun). + 2004-10-03 Vladimir Dergachev Modified: * xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_mm_i2c.c Remove debugging statement that cause loading of DLL modules to fail. 2004-10-03 Roland Mainz * xc/programs/Xserver/Xprint/Init.c * xc/programs/Xserver/Xprint/pcl/PclInit.c * xc/programs/Xserver/Xprint/ps/PsInit.c Bugzilla #1496: Fixed Xprt font handling which did not support "*xp-listfonts-modes: xp-list-internal-printer-fonts" or "*xp-listfonts-modes: xp-list-glyph-fonts" to toggle the usage of printer-builtin and glyph fonts in XListFonts*(), XLoad*Font(), etc. Additionally the Xprint DDX now explicitly list "xp-listfonts-modes" in "document-attributes-supported" (for document-level) or "xp-page-attributes-supported" (for page-level) when the DDX implements this feature (as described in the CDE DtPrint specification). Index: xc/programs/Xserver/Xprint/Init.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/Init.c,v retrieving revision 1.7 diff -u -2 -0 -r1.7 Init.c --- xc/programs/Xserver/Xprint/Init.c 3 Oct 2004 23:29:20 -0000 1.7 +++ xc/programs/Xserver/Xprint/Init.c 4 Oct 2004 04:57:55 -0000 @@ -146,40 +146,41 @@ static PixmapFormatRec MonoPclPixmapFormats[] = { { 1, 1, BITMAP_SCANLINE_PAD } }; #define NUMMPCLFORMATS (sizeof MonoPclPixmapFormats)/(sizeof MonoPclPixmapFormats[0]) #endif #if defined(XPPCLDDX) || defined(XPMONOPCLDDX) #include "pcl/Pcl.h" #endif #ifdef XPPSDDX static PixmapFormatRec PSPixmapFormats[] = { { 1, 1, BITMAP_SCANLINE_PAD }, { 8, 8, BITMAP_SCANLINE_PAD }, + { 12, 16, BITMAP_SCANLINE_PAD }, { 24, 32, BITMAP_SCANLINE_PAD } }; #define NUMPSFORMATS (sizeof PSPixmapFormats)/(sizeof PSPixmapFormats[0]) #include "ps/Ps.h" #endif /* * The driverInitArray contains an entry for each driver the * server knows about. Each element contains pointers to pixmap formats, the * driver's initialization routine, and pointers to the driver's * attribute validation rec, and/or a driver function which * returns the maximum medium width&height, and maximum resolution * given a printer name. Either the validation rec OR the dimension * function can be NULL. If the function is non-NULL then it * will be called, and will be passed the (possibly NULL) validation rec. * If the function is NULL, then XpGetMaxWidthHeightRes() is called. */ Index: xc/programs/Xserver/Xprint/ps/Ps.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/Ps.h,v retrieving revision 1.3 diff -u -2 -0 -r1.3 Ps.h --- xc/programs/Xserver/Xprint/ps/Ps.h 18 Jul 2004 05:21:20 -0000 1.3 +++ xc/programs/Xserver/Xprint/ps/Ps.h 4 Oct 2004 04:57:55 -0000 @@ -539,41 +539,41 @@ extern char *PsGetAttributes(XpContextPtr pCon, XPAttributes pool); extern char *PsGetOneAttribute(XpContextPtr pCon, XPAttributes pool, char *attr); extern int PsAugmentAttributes(XpContextPtr pCon, XPAttributes pool, char *attrs); extern int PsSetAttributes(XpContextPtr pCon, XPAttributes pool, char *attrs); /* * Functions in PsColor.c */ extern Bool PsCreateColormap(ColormapPtr pColor); extern void PsDestroyColormap(ColormapPtr pColor); extern void PsInstallColormap(ColormapPtr pColor); extern void PsUninstallColormap(ColormapPtr pColor); 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); /* * Functions in PsPixmap.c */ extern PixmapPtr PsCreatePixmap(ScreenPtr pScreen, int width, int height, int depth); extern Bool PsDestroyPixmap(PixmapPtr pPixmap); extern DisplayListPtr PsGetFreeDisplayBlock(PsPixmapPrivPtr priv); extern void PsReplayPixmap(PixmapPtr pix, DrawablePtr pDrawable); extern int PsCloneDisplayElm(PixmapPtr dst, DisplayElmPtr elm, DisplayElmPtr newElm, int xoff, int yoff); extern void PsCopyDisplayList(PixmapPtr src, PixmapPtr dst, int xoff, int yoff, int x, int y, int w, int h); extern PsElmPtr PsCreateFillElementList(PixmapPtr pix, int *nElms); extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms); extern void PsDestroyFillElementList(int nElms, PsElmPtr elms); Index: xc/programs/Xserver/Xprint/ps/PsArea.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsArea.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 PsArea.c --- xc/programs/Xserver/Xprint/ps/PsArea.c 23 Apr 2004 18:57:56 -0000 1.2 +++ xc/programs/Xserver/Xprint/ps/PsArea.c 4 Oct 2004 04:57:55 -0000 @@ -114,40 +114,47 @@ int i, j; int r, c; int swap; char *pt; PsOutPtr psOut; ColormapPtr cMap; int pageRes, sw, sh; if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; if (!imageRes) { sw = w; sh = h; } else { pageRes = XpGetResolution(XpGetPrintContext(requestingClient)); sw = (float)w * (float)pageRes / (float)imageRes + 0.5; sh = (float)h * (float)pageRes / (float)imageRes + 0.5; } 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); if( format==XYPixmap ) { int rowsiz = PixmapBytePad(w, depth); char *planes[3]; planes[0] = pImage; planes[1] = &pImage[rowsiz*h]; planes[2] = &pImage[rowsiz*h*2]; for( r=0 ; r 8) && (depth < 16) ) + { + int rowsiz = PixmapBytePad(w, depth); + PsOut_BeginImage(psOut, 0, 0, x, y, w, h, sw, sh, 3); + for( r=0 ; rbgPixel), PsGetPixelColor(cMap, pGC->fgPixel), x, y, w, h, sw, sh, 1); @@ -279,40 +315,48 @@ } else { pageRes = XpGetResolution(XpGetPrintContext(requestingClient)); sw = (float)w * (float)pageRes / (float)imageRes + 0.5; sh = (float)h * (float)pageRes / (float)imageRes + 0.5; } PsOut_Offset(psOut, pDrawable->x, pDrawable->y); pt = (char *)(&i); i = 1; if( pt[0]=='\001' ) swap = 1; else swap = 0; #ifdef BM_CACHE cache_id = PsBmIsImageCached(w, h, pImage); if(!cache_id) { cache_id = PsBmPutImageInCache(w, h, pImage); if(!cache_id) return; 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); if( format==XYPixmap ) { int rowsiz = PixmapBytePad(w, depth); char *planes[3]; planes[0] = pImage; planes[1] = &pImage[rowsiz*h]; planes[2] = &pImage[rowsiz*h*2]; for( r=0 ; r 8) && (depth < 16) ) + { + int rowsiz = PixmapBytePad(w, depth); + PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3); + for( r=0 ; rbgPixel), PsGetPixelColor(cMap, pGC->fgPixel), x, y, w, h, sw, sh, 1); Index: xc/programs/Xserver/Xprint/ps/PsColor.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsColor.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 PsColor.c --- xc/programs/Xserver/Xprint/ps/PsColor.c 18 Jul 2004 05:21:20 -0000 1.3 +++ xc/programs/Xserver/Xprint/ps/PsColor.c 4 Oct 2004 04:57:55 -0000 @@ -58,137 +58,168 @@ * from said copyright holders. */ /******************************************************************* ** ** ********************************************************* ** * ** * File: PsColor.c ** * ** * Contents: Color routines for the PS driver ** * ** * Created By: Roger Helmendach (Liberty Systems) ** * ** * Copyright: Copyright 1996 The Open Group, Inc. ** * ** ********************************************************* ** ********************************************************************/ #include "Ps.h" +#include "mi.h" +#include "micmap.h" #include "gcstruct.h" #include "windowstr.h" #include "colormapst.h" Bool PsCreateColormap(ColormapPtr pColor) { - int i; - unsigned short rgb; - VisualPtr pVisual = pColor->pVisual; - Pixel pix; - - if( pVisual->class==TrueColor ) - { - for( i=0 ; iColormapEntries ; 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; + miInitializeColormap(pColor); } void PsDestroyColormap(ColormapPtr pColor) { + /* NO-OP */ } void PsInstallColormap(ColormapPtr pColor) { + miInstallColormap(pColor); } void PsUninstallColormap(ColormapPtr pColor) { + miUninstallColormap(pColor); } int PsListInstalledColormaps( ScreenPtr pScreen, XID *pCmapList) { - return 0; + return miListInstalledColormaps(pScreen, pCmapList); } void PsStoreColors( ColormapPtr pColor, int ndef, xColorItem *pdefs) { int i; for( i=0 ; ired[pdefs[i].pixel].co.local.red = pdefs[i].red; if( pdefs[i].flags&DoGreen ) pColor->red[pdefs[i].pixel].co.local.green = pdefs[i].green; if( pdefs[i].flags&DoBlue ) pColor->red[pdefs[i].pixel].co.local.blue = pdefs[i].blue; } } void PsResolveColor( unsigned short *pRed, unsigned short *pGreen, 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 PsSetFillColor(DrawablePtr pDrawable, GCPtr pGC, PsOutPtr psOut, ColormapPtr cMap) { switch(pGC->fillStyle) { case FillSolid: PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); break; case FillTiled: if( !PsOut_BeginPattern(psOut, pGC->tile.pixmap, pGC->tile.pixmap->drawable.width, pGC->tile.pixmap->drawable.height, PsTile, 0, 0) ) { PsReplayPixmap(pGC->tile.pixmap, pDrawable); PsOut_EndPattern(psOut); } PsOut_SetPattern(psOut, pGC->tile.pixmap, PsTile); Index: xc/programs/Xserver/Xprint/ps/PsInit.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsInit.c,v retrieving revision 1.4 diff -u -2 -0 -r1.4 PsInit.c --- xc/programs/Xserver/Xprint/ps/PsInit.c 3 Oct 2004 23:29:21 -0000 1.4 +++ xc/programs/Xserver/Xprint/ps/PsInit.c 4 Oct 2004 04:57:55 -0000 @@ -102,42 +102,52 @@ int PsWindowPrivateIndex; #ifdef GLXEXT extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); #endif /* GLXEXT */ Bool InitializePsDriver(ndx, pScreen, argc, argv) int ndx; ScreenPtr pScreen; int argc; char **argv; { #if 0 int maxXres, maxYres, maxWidth, maxHeight; int maxRes, maxDim, numBytes; PsScreenPrivPtr pPriv; #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; int rootDepth; /* * Register this driver's InitContext function with the print * extension. */ XpRegisterInitFunc(pScreen, "XP-POSTSCRIPT", PsInitContext); /* * Create and fill in the devPrivate for the PS driver. */ AllocatePsPrivates(pScreen); #if 0 pPriv = (PsScreenPrivPtr)pScreen->devPrivates[PsScreenPrivateIndex].ptr; pPriv->resDB = rmdb; #endif @@ -162,100 +172,236 @@ /* XXX Hard routine to write! */ /* * These two are going to be VERY different... */ pScreen->CreatePixmap = PsCreatePixmap; pScreen->DestroyPixmap = PsDestroyPixmap; pScreen->RealizeFont = PsRealizeFont; pScreen->UnrealizeFont = PsUnrealizeFont; pScreen->CreateGC = PsCreateGC; pScreen->CreateColormap = PsCreateColormap; pScreen->DestroyColormap = PsDestroyColormap; pScreen->InstallColormap = PsInstallColormap; pScreen->UninstallColormap = PsUninstallColormap; pScreen->ListInstalledColormaps = PsListInstalledColormaps; pScreen->StoreColors = PsStoreColors; pScreen->ResolveColor = PsResolveColor; /* 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; + + /* TrueColor, 24bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = TrueColor; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 24; + visuals[nv].redMask = 0X00FF0000; + visuals[nv].greenMask = 0X0000FF00; + visuals[nv].blueMask = 0X000000FF; + visuals[nv].offsetRed = 16; + visuals[nv].offsetGreen = 8; + visuals[nv].offsetBlue = 0; + vids_24bit[nv_24bit] = visuals[nv].vid; + nv++; nv_24bit++; + + /* PseudoColor, 8bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = PseudoColor; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 8; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_8bit[nv_8bit] = visuals[nv].vid; + nv++; nv_8bit++; + + /* GrayScale, 8bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = GrayScale; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 8; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_8bit[nv_8bit] = visuals[nv].vid; + nv++; nv_8bit++; + + /* StaticGray, 8bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = StaticGray; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 8; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_8bit[nv_8bit] = visuals[nv].vid; + nv++; nv_8bit++; + + /* StaticGray, 1bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = StaticGray; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 2; + visuals[nv].nplanes = 1; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_1bit[nv_1bit] = visuals[nv].vid; + nv++; nv_1bit++; + +#ifdef PSOUT_USE_DEEPCOLOR + /* TrueColor, 30bit, 10bit per R-,G-,B-gun */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = TrueColor; + visuals[nv].bitsPerRGBValue = 10; + visuals[nv].ColormapEntries = 1024; + visuals[nv].nplanes = 30; + visuals[nv].redMask = 0X3FF00000; + visuals[nv].greenMask = 0X000FFC00; + visuals[nv].blueMask = 0X000003FF; + visuals[nv].offsetRed = 20; + visuals[nv].offsetGreen = 10; + visuals[nv].offsetBlue = 0; + vids_30bit[nv_30bit] = visuals[nv].vid; + nv++; nv_30bit++; + + /* PostScript Level 2 and above, colors can have 12 bits per component + * (36 bit for RGB) */ + + /* GrayScale, 12bit, 12bit per R-,G-,B-gun */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = GrayScale; + visuals[nv].bitsPerRGBValue = 12; + visuals[nv].ColormapEntries = 4096; + visuals[nv].nplanes = 12; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_12bit[nv_12bit] = visuals[nv].vid; + nv++; nv_12bit++; + + /* StaticGray, 12bit, 12bit per R-,G-,B-gun */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = StaticGray; + visuals[nv].bitsPerRGBValue = 12; + visuals[nv].ColormapEntries = 4096; + visuals[nv].nplanes = 12; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_12bit[nv_12bit] = visuals[nv].vid; + nv++; nv_12bit++; +#endif /* PSOUT_USE_DEEPCOLOR */ + + if( nv_30bit > 0 ) + { + depths[nd].depth = 30; + depths[nd].numVids = nv_30bit; + depths[nd].vids = vids_30bit; + nd++; + } + + if( nv_24bit > 0 ) + { + depths[nd].depth = 24; + depths[nd].numVids = nv_24bit; + depths[nd].vids = vids_24bit; + nd++; + } + + if( nv_12bit > 0 ) + { + depths[nd].depth = 12; + depths[nd].numVids = nv_12bit; + depths[nd].vids = vids_12bit; + nd++; + } + + if( nv_8bit > 0 ) + { + depths[nd].depth = 8; + depths[nd].numVids = nv_8bit; + depths[nd].vids = vids_8bit; + nd++; + } + + if( nv_1bit > 0 ) + { + depths[nd].depth = 1; + depths[nd].numVids = nv_1bit; + depths[nd].vids = vids_1bit; + nd++; + } /* Defaul visual is 8bit PseudoColor */ defaultVisual = visuals[1].vid; rootDepth = visuals[1].nplanes; #ifdef GLXEXT { miInitVisualsProcPtr proc = NULL; GlxWrapInitVisuals(&proc); /* GlxInitVisuals ignores the last three arguments. */ - proc(&visuals, &depths, &nVisuals, &nDepths, + proc(&visuals, &depths, &nv, &nd, &rootDepth, &defaultVisual, 0, 0, 0); } #endif /* GLXEXT */ miScreenInit(pScreen, (pointer)0, pScreen->width, pScreen->height, (int) (pScreen->width / (pScreen->mmWidth / 25.40)), (int) (pScreen->height / (pScreen->mmHeight / 25.40)), - 0, rootDepth, nDepths, - depths, defaultVisual, nVisuals, visuals); + 0, rootDepth, nd, + depths, defaultVisual, nv, visuals); if( cfbCreateDefColormap(pScreen)==FALSE ) return FALSE; /*scalingScreenInit(pScreen);*/ return TRUE; } static void AllocatePsPrivates(ScreenPtr pScreen) { static unsigned long PsGeneration = 0; if((unsigned long)PsGeneration != serverGeneration) { PsScreenPrivateIndex = AllocateScreenPrivateIndex(); PsWindowPrivateIndex = AllocateWindowPrivateIndex(); AllocateWindowPrivate(pScreen, PsWindowPrivateIndex, sizeof(PsWindowPrivRec)); Index: xc/programs/Xserver/Xprint/ps/psout.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/psout.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 psout.c --- xc/programs/Xserver/Xprint/ps/psout.c 6 May 2004 00:24:32 -0000 1.3 +++ xc/programs/Xserver/Xprint/ps/psout.c 4 Oct 2004 04:57:55 -0000 @@ -405,51 +405,53 @@ while( buf[k] != '\0' ) k++; } strcat(self->Buf, "("); i = strlen(self->Buf); memcpy(&self->Buf[i], buf, k); self->Buf[i+k] = '\0'; strcat(self->Buf, ")"); if( strlen(self->Buf)>70 ) S_Flush(self); } void S_OutTok(PsOutPtr self, char *tok, int cr) { if( self->Buf[0] ) strcat(self->Buf, " "); strcat(self->Buf, tok); if( cr ) S_Flush(self); } static void -S_Color(PsOutPtr self, int clr) +S_Color(PsOutPtr self, PsOutColor clr) { int ir, ig, ib; - ir = clr>>16; ig = (clr>>8)&0xFF; ib = clr&0xFF; + ir = PSOUTCOLOR_TO_REDBITS(clr); + ig = PSOUTCOLOR_TO_GREENBITS(clr); + ib = PSOUTCOLOR_TO_BLUEBITS(clr); if( ir==ig && ig==ib ) - { S_OutNum(self, (float)ir/255.); S_OutTok(self, "g", 1); } + { S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); S_OutTok(self, "g", 1); } else { - S_OutNum(self, (float)ir/255.); - S_OutNum(self, (float)ig/255.); - S_OutNum(self, (float)ib/255.); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib)); S_OutTok(self, "sc", 1); } } static void S_SetPageDevice(PsOutPtr self, int orient, int count, int plex, int res, int wd, int ht, int isPage) { float fwd = ((float)wd/(float)res)*72.; float fht = ((float)ht/(float)res)*72.; #define USE_WORKAROUND_COPY_COUNT_BUG 1 #ifdef USE_WORKAROUND_COPY_COUNT_BUG /* Workaround (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1861 - * 'Need workaround for bug 1378 ...') to avoid that we print n^2 copies * instead of n copies. * The problem is that we use both /NumCopies here but pass the * %copy-count% to the spooler, too. * But we only have to use _one_ way... @@ -619,41 +621,41 @@ sprintf(buffer, "%%%%Title: %.256s", title); S_Comment(psout, buffer); } S_Comment(psout, "%%EndComments"); S_Comment(psout, "%%BeginProlog"); S_Comment(psout, "%%BeginProcSet: XServer_PS_Functions"); S_OutDefs(psout, S_StandardDefs); S_OutDefs(psout, S_CompositeDefs); S_Comment(psout, "%%EndProcSet"); S_Comment(psout, "%%EndProlog"); S_Comment(psout, "%%BeginSetup"); /* set document level page attributes */ S_SetPageDevice(psout, orient, count, plex, res, wd, ht, 0); S_Comment(psout, "%%Pages: atend"); S_OutDefs(psout, S_SetupDefs); S_Comment(psout, "%%EndSetup"); } /* * Initialize the structure */ - psout->CurColor = 0xFFFFFFFF; + psout->CurColor = PSOUTCOLOR_NOCOLOR; psout->LineWidth = 1; psout->LineCap = PsCButt; psout->LineJoin = PsJMiter; psout->NDashes = 0; psout->Dashes = (int *)0; psout->FontName = (char *)0; psout->FontSize = 0; psout->start_image = 0; for( i=0 ; i<4 ; i++ ) psout->FontMtx[i] = 0.; psout->ImageFormat = 0; return(psout); } void PsOut_EndFile(PsOutPtr self, int closeFile) { char coms[50]; int i; if (!self) @@ -706,41 +708,41 @@ void PsOut_EndPage(PsOutPtr self) { S_OutTok(self, "gr gr sp", 1); /* did grestore: mark attributes 'dirty' so they will be re-sent */ PsOut_DirtyAttributes(self); /*** comment for pagenumbers *****/ S_Comment(self,"%%PageTrailer"); /*** end comment *****************/ } void PsOut_DirtyAttributes(PsOutPtr self) { int i; - self->CurColor = 0xFFFFFFFF; + self->CurColor = PSOUTCOLOR_NOCOLOR; self->LineWidth = -1; self->LineCap = (PsCapEnum)-1; self->LineJoin = (PsJoinEnum)-1; self->NDashes = -1; self->FontSize = -1; for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.; if( self->Dashes ) { xfree(self->Dashes); self->Dashes = (int *)0; } if( self->FontName ) { xfree(self->FontName); self->FontName = (char *)0; } } void PsOut_Comment(PsOutPtr self, char *comment) { S_Comment(self, comment); } void PsOut_Offset(PsOutPtr self, int x, int y) { self->XOff = x; @@ -894,56 +896,56 @@ S_OutNum(self, (float)elm->c.arc.x+xo+(float)elm->c.arc.w/2.); S_OutNum(self, (float)elm->c.arc.y+yo+(float)elm->c.arc.h/2.); S_OutTok(self, "m", 0); } S_OutNum(self, (float)elm->c.arc.x+xo+(float)elm->c.arc.w/2.); S_OutNum(self, (float)elm->c.arc.y+yo+(float)elm->c.arc.h/2.); S_OutNum(self, (float)elm->c.arc.w); S_OutNum(self, (float)elm->c.arc.h); S_OutNum(self, (float)elm->c.arc.a1/64.); S_OutNum(self, (float)elm->c.arc.a1/64.+(float)elm->c.arc.a2/64.); if( elm->c.arc.a2<0 ) S_OutTok(self, "An cp", 1); else S_OutTok(self, "Ac cp", 1); break; } } S_OutTok(self, "cl n", 1); } } void -PsOut_Color(PsOutPtr self, int clr) +PsOut_Color(PsOutPtr self, PsOutColor clr) { if( clr==self->CurColor || self->InTile>=PsStip ) return; self->CurColor = clr; S_Color(self, clr); } void PsOut_FillRule(PsOutPtr self, PsRuleEnum rule) { self->FillRule = rule; } void PsOut_LineAttrs(PsOutPtr self, int wd, PsCapEnum cap, PsJoinEnum join, - int nDsh, int *dsh, int dshOff, int bclr) + int nDsh, int *dsh, int dshOff, PsOutColor bclr) { int i; int same = 1; if( wd!=self->LineWidth && wd>=0 ) { if( wd==0 ) wd = 1; self->LineWidth = wd; S_OutNum(self, (float)wd); S_OutTok(self, "w", 1); } if( cap!=self->LineCap ) { self->LineCap = cap; S_OutNum(self, (float)cap); S_OutTok(self, "lc", 1); } if( join!=self->LineJoin ) { self->LineJoin = join; S_OutNum(self, (float)join); S_OutTok(self, "lj", 1); } @@ -956,41 +958,44 @@ if( iNDashes && self->Dashes ) { xfree(self->Dashes); self->Dashes = (int *)0; } self->NDashes = nDsh; self->DashOffset = dshOff; if( nDsh ) self->Dashes = (int *)xalloc(sizeof(int)*nDsh); S_OutTok(self, "[", 0); for( i=0 ; iDashes[i] = dsh[i]; S_OutNum(self, (float)dsh[i]); } S_OutTok(self, "]", 0); S_OutNum(self, (float)dshOff); S_OutTok(self, "ds", 1); } - if( nDsh ) self->LineBClr = bclr; else bclr = -1; + if( nDsh ) + self->LineBClr = bclr; + else + bclr = PSOUTCOLOR_NOCOLOR; } void PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso) { int i; char buf[256]; if( self->FontName && strcmp(fnam, self->FontName)==0 && siz==self->FontSize ) return; if( self->FontName ) xfree(self->FontName); self->FontName = (char *)xalloc(strlen(fnam)+1); strcpy(self->FontName, fnam); self->FontSize = siz; for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.; strcpy(buf, "/"); strcat(buf, fnam); S_OutTok(self, buf, 0); S_OutNum(self, (float)siz); if( iso ) S_OutTok(self, "t", 0); else S_OutTok(self, "f", 0); S_OutTok(self, "Tf", 1); @@ -1077,310 +1082,317 @@ if( ang2<0 ) S_OutTok(self, "An cp fl", 1); else S_OutTok(self, "Ac cp fl", 1); } void PsOut_Lines(PsOutPtr self, int nPts, PsPointPtr pts) { int i; int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; if( nPts<1 ) return; for( i=0 ; iLineBClr>=0 ) + if( self->LineBClr != PSOUTCOLOR_NOCOLOR ) { S_OutTok(self, "gs", 0); S_Color(self, self->LineBClr); S_OutTok(self, "[] 0 ds st gr", 0); } S_OutTok(self, "st", 1); } void PsOut_Points(PsOutPtr self, int nPts, PsPointPtr pts) { int i; int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; if( nPts<1 ) return; for( i=0 ; iXOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; S_OutNum(self, (float)x); S_OutNum(self, (float)y); S_OutNum(self, (float)w); S_OutNum(self, (float)h); S_OutTok(self, "R", 0); - if( self->LineBClr>=0 ) + if( self->LineBClr != PSOUTCOLOR_NOCOLOR ) { S_OutTok(self, "gs", 0); S_Color(self, self->LineBClr); S_OutTok(self, "[] 0 ds st gr", 0); } S_OutTok(self, "st", 1); } void PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h, float ang1, float ang2) { int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; S_OutNum(self, (float)x+(float)w/2.); S_OutNum(self, (float)y+(float)h/2.); S_OutNum(self, (float)w); S_OutNum(self, (float)h); S_OutNum(self, ang1); S_OutNum(self, ang1+ang2); if( ang2<0 ) S_OutTok(self, "An", 0); else S_OutTok(self, "Ac", 0); - if( self->LineBClr>=0 ) + if( self->LineBClr != PSOUTCOLOR_NOCOLOR ) { S_OutTok(self, "gs", 0); S_Color(self, self->LineBClr); S_OutTok(self, "[] 0 ds st gr", 0); } S_OutTok(self, "st", 1); } void -PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, int bclr) +PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, PsOutColor bclr) { int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; S_OutStr(self, text, textl); S_OutNum(self, (float)x); S_OutNum(self, (float)y); - if( bclr<0 ) S_OutTok(self, "T", 1); + if( bclr == PSOUTCOLOR_NOCOLOR ) + S_OutTok(self, "T", 1); else { - int ir = bclr>>16; - int ig = (bclr>>8)&0xFF; - int ib = bclr&0xFF; - S_OutNum(self, (float)ir/255.); - S_OutNum(self, (float)ig/255.); - S_OutNum(self, (float)ib/255.); + int ir = PSOUTCOLOR_TO_REDBITS(bclr); + int ig = PSOUTCOLOR_TO_GREENBITS(bclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(bclr); + + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib)); S_OutTok(self, "Tb", 1); } } void -PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr) +PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, PsOutColor bclr) { int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; S_OutStr16(self, text, textl); S_OutNum(self, (float)x); S_OutNum(self, (float)y); - if( bclr<0 ) S_OutTok(self, "T", 1); + if( bclr == PSOUTCOLOR_NOCOLOR ) + S_OutTok(self, "T", 1); else { - int ir = bclr>>16; - int ig = (bclr>>8)&0xFF; - int ib = bclr&0xFF; - S_OutNum(self, (float)ir/255.); - S_OutNum(self, (float)ig/255.); - S_OutNum(self, (float)ib/255.); + int ir = PSOUTCOLOR_TO_REDBITS(bclr); + int ig = PSOUTCOLOR_TO_GREENBITS(bclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(bclr); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib)); S_OutTok(self, "Tb", 1); } } #ifdef BM_CACHE void /* new */ -PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr) +PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, PsOutColor bclr, PsOutColor fclr) { char cacheID[10]; int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; sprintf(cacheID, "c%di", cache_id); S_OutNum(self, (float)x); S_OutNum(self, (float)y); - if( fclr==0xFFFFFF ) + if( fclr==PSOUTCOLOR_WHITE ) { - int ir, ig, ib; - ir = bclr>>16; ig = (bclr>>8)&0xFF; ib = bclr&0xFF; + int ir = PSOUTCOLOR_TO_REDBITS(bclr); + int ig = PSOUTCOLOR_TO_GREENBITS(bclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(bclr); + if( ir==ig && ig==ib ) - S_OutNum(self, (float)ir/255.); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); else S_OutNum(self, (float)0); self->RevImage = 1; } else { - int ir, ig, ib; - ir = fclr>>16; ig = (fclr>>8)&0xFF; ib = fclr&0xFF; + int ir = PSOUTCOLOR_TO_REDBITS(fclr); + int ig = PSOUTCOLOR_TO_GREENBITS(fclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(fclr); + if( ir==ig && ig==ib ) - S_OutNum(self, (float)ir/255.); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); else S_OutNum(self, (float)0); } S_OutTok(self, cacheID, 1); } /* new */ void /* new */ PsOut_BeginImageCache(PsOutPtr self, long cache_id) { char cacheID[10]; sprintf(cacheID, "/c%di {", cache_id); S_OutTok(self, cacheID, 0); } /* new */ void /* new */ PsOut_EndImageCache(PsOutPtr self) { S_OutTok(self, "}bd", 1); } /* new */ #endif void -PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, +PsOut_BeginImage(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, int w, int h, int sw, int sh, int format) { - int savClr = self->CurColor; + PsOutColor savClr = self->CurColor; int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; if( self->InTile ) { if( self->InTile>=PsStip && format!=1 ) { self->ImgSkip = 1; return; } self->ImgBClr = bclr; self->ImgFClr = fclr; self->ImgX = x; self->ImgY = y; self->ImgW = w; self->ImgH = h; self->SclW = sw; self->SclH = sh; S_OutTok(self, "<", 0); self->ImageFormat = format; self->RevImage = 0; - if( self->InTile==PsTile && format==1 && fclr==0xFFFFFF ) + if( self->InTile==PsTile && format==1 && fclr==PSOUTCOLOR_WHITE ) self->RevImage = 1; return; } self->RevImage = 0; if( format==1 ) { S_OutTok(self, "gs", 0); - if( fclr==0xFFFFFF ) + if( fclr==PSOUTCOLOR_WHITE ) { PsOut_Color(self, fclr); PsOut_FillRect(self, x, y, sw, sh); PsOut_Color(self, bclr); self->RevImage = 1; } else { PsOut_Color(self, bclr); PsOut_FillRect(self, x, y, sw, sh); PsOut_Color(self, fclr); } } S_OutNum(self, (float)x); S_OutNum(self, (float)y); S_OutNum(self, (float)w); S_OutNum(self, (float)h); S_OutNum(self, (float)sw); S_OutNum(self, (float)sh); if( format==1 ) { if(self->RevImage) S_OutTok(self, "Im1rev", 1); else S_OutTok(self, "Im1", 1); } else S_OutTok(self, "Im24", 1); self->ImageFormat = format; self->CurColor = savClr; } void -PsOut_BeginImageIM(PsOutPtr self, int bclr, int fclr, int x, int y, +PsOut_BeginImageIM(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, int w, int h, int sw, int sh, int format) { - int savClr = self->CurColor; + PsOutColor savClr = self->CurColor; int xo = self->XOff; int yo = self->YOff; if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; if( self->InTile ) { if( self->InTile>=PsStip && format!=1 ) { self->ImgSkip = 1; return; } self->ImgBClr = bclr; self->ImgFClr = fclr; self->ImgX = x; self->ImgY = y; self->ImgW = w; self->ImgH = h; self->SclW = sw; self->SclH = sh; S_OutTok(self, "<", 0); self->ImageFormat = format; self->RevImage = 0; - if( self->InTile==PsTile && format==1 && fclr==0xFFFFFF ) + if( self->InTile==PsTile && format==1 && fclr==PSOUTCOLOR_WHITE ) self->RevImage = 1; return; } self->RevImage = 0; if( format==1 ) { S_OutTok(self, "gs", 0); #ifdef BM_CACHE S_OutTok(self, "g", 1); #else - if( fclr==0xFFFFFF ) + if( fclr==PSOUTCOLOR_WHITE ) { PsOut_Color(self, bclr); self->RevImage = 1; } else { PsOut_Color(self, fclr); } #endif } #ifdef BM_CACHE S_OutTok(self, "tr", 0); /* new */ #else S_OutNum(self, (float)x); S_OutNum(self, (float)y); #endif S_OutNum(self, (float)w); S_OutNum(self, (float)h); S_OutNum(self, (float)sw); @@ -1394,41 +1406,41 @@ if(self->RevImage) S_OutTok(self, "Im1rev", 1); else S_OutTok(self, "Im1", 1); } else S_OutTok(self, "Im24", 1); #endif self->ImageFormat = format; self->CurColor = savClr; } void PsOut_EndImage(PsOutPtr self) { if( self->ImgSkip ) { self->ImgSkip = 0; return; } if( self->InTile ) { S_OutTok(self, ">", 1); if( self->ImageFormat==1 && self->InTile==PsTile ) { - if( self->ImgFClr==0xFFFFFF ) + if( self->ImgFClr==PSOUTCOLOR_WHITE ) { PsOut_Color(self, self->ImgFClr); PsOut_FillRect(self, self->ImgX, self->ImgY, self->SclW, self->SclH); PsOut_Color(self, self->ImgBClr); } else { PsOut_Color(self, self->ImgBClr); PsOut_FillRect(self, self->ImgX, self->ImgY, self->SclW, self->SclH); PsOut_Color(self, self->ImgFClr); } } S_OutNum(self, (float)self->ImgX); S_OutNum(self, (float)self->ImgY); S_OutNum(self, (float)self->ImgW); S_OutNum(self, (float)self->ImgH); S_OutNum(self, (float)self->SclW); S_OutNum(self, (float)self->SclH); if( self->ImageFormat==1 ) S_OutTok(self, "Im1t", 1); else S_OutTok(self, "Im24t", 1); @@ -1492,41 +1504,41 @@ { S_OutNum(self, (float)xoff); S_OutNum(self, (float)yoff); S_OutTok(self, "tr", 0); } S_OutTok(self, "gs", 1); self->InFrame += 1; } void PsOut_EndFrame(PsOutPtr self) { self->InFrame -= 1; if( self->InFrame<0 ) self->InFrame = 0; S_OutTok(self, "gr gr", 1); PsOut_DirtyAttributes(self); } int PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, PsFillEnum type, - int bclr, int fclr) + PsOutColor bclr, PsOutColor fclr) { int i; char key[64]; for( i=0 ; iNPatterns ; i++ ) { if( self->Patterns[i].tag==tag && self->Patterns[i].type==type ) break; } if( iNPatterns ) return(1); if( (self->NPatterns+1)>self->MxPatterns ) { if( self->Patterns ) { self->MxPatterns *= 2; self->Patterns = (PsPatPtr)xrealloc(self->Patterns, sizeof(PsPatRec)*self->MxPatterns); } else { self->MxPatterns = 64; self->Patterns = (PsPatPtr)xalloc(sizeof(PsPatRec)*self->MxPatterns); } @@ -1568,41 +1580,41 @@ self->InTile = PsSolid; S_OutTok(self, "rs ed}d de im_ mp d", 1); } void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type) { int i; char key[64]; for( i=0 ; iNPatterns ; i++ ) { if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; } if( i>=self->NPatterns ) return; sprintf(key, " %d", (int)tag); switch(type) { case PsTile: key[0] = 't'; break; case PsStip: key[0] = 's'; break; case PsOpStip: key[0] = 'o'; break; } S_OutTok(self, key, 0); S_OutTok(self, "spt", 1); - self->CurColor = 0xFFFFFFFF; + self->CurColor = PSOUTCOLOR_NOCOLOR; } void PsOut_RawData(PsOutPtr self, char *data, int len) { S_Flush(self); if (!ferror(self->Fp)) { (void) fwrite(data, 1, len, self->Fp); } } typedef enum PsDownfontFontType_ { PsDFT_Type1PFA=0, PsDFT_Type1PFB, PsDFT_TrueType /* not implemented yet */ } PsDownfontFontType; /* Download a PS Type1 font */ int Index: xc/programs/Xserver/Xprint/ps/psout.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/psout.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 psout.h --- xc/programs/Xserver/Xprint/ps/psout.h 23 Apr 2004 18:57:56 -0000 1.2 +++ xc/programs/Xserver/Xprint/ps/psout.h 4 Oct 2004 04:57:55 -0000 @@ -136,151 +136,175 @@ typedef struct PsClipRec_ { int nRects; PsRectPtr rects; int nElms; PsElmPtr elms; int nOutterClips; PsRectPtr outterClips; } PsClipRec; typedef PsClipRec *PsClipPtr; typedef enum PsFTDownloadFontType_ { PsFontBitmap=0, PsFontType1, PsFontType3 } PsFTDownloadFontType; +#ifdef PSOUT_USE_DEEPCOLOR +typedef long long PsOutColor; +#define PSOUTCOLOR_TO_REDBITS(clr) ((clr) >> 32) +#define PSOUTCOLOR_TO_GREENBITS(clr) (((clr) >> 16) & 0xFFFF) +#define PSOUTCOLOR_TO_BLUEBITS(clr) ((clr) & 0xFFFF) +#define PSOUTCOLOR_BITS_TO_PSFLOAT(b) ((float)(b) / 65535.) +#define PSOUTCOLOR_WHITE (0xFFFFFFFFFFFFLL) +#define PSOUTCOLOR_NOCOLOR (-1LL) +#define PSOUTCOLOR_TO_RGB24BIT(clr) (((PSOUTCOLOR_TO_REDBITS(clr) >> 8) << 16) | \ + ((PSOUTCOLOR_TO_GREENBITS(clr) >> 8) << 8) | \ + ((PSOUTCOLOR_TO_BLUEBITS(clr) >> 8) << 0)) +#else +typedef long PsOutColor; +#define PSOUTCOLOR_TO_REDBITS(clr) ((clr) >> 16) +#define PSOUTCOLOR_TO_GREENBITS(clr) (((clr) >> 8) & 0xFF) +#define PSOUTCOLOR_TO_BLUEBITS(clr) ((clr) & 0xFF) +#define PSOUTCOLOR_BITS_TO_PSFLOAT(b) ((float)(b) / 255.) +#define PSOUTCOLOR_WHITE (0xFFFFFF) +#define PSOUTCOLOR_NOCOLOR (-1) +#define PSOUTCOLOR_TO_RGB24BIT(clr) ((PSOUTCOLOR_TO_REDBITS(clr) << 16) | \ + (PSOUTCOLOR_TO_GREENBITS(clr) << 8) | \ + (PSOUTCOLOR_TO_BLUEBITS(clr) << 0)) +#endif /* PSOUT_USE_DEEPCOLOR */ + #ifdef USE_PSOUT_PRIVATE typedef void *voidPtr; typedef struct PsPatRec_ { PsFillEnum type; voidPtr tag; } PsPatRec; typedef PsPatRec *PsPatPtr; typedef struct PsOutRec_ { FILE *Fp; char Buf[16384]; - int CurColor; + PsOutColor CurColor; int LineWidth; PsCapEnum LineCap; PsJoinEnum LineJoin; int NDashes; int *Dashes; int DashOffset; - int LineBClr; + PsOutColor LineBClr; PsRuleEnum FillRule; char *FontName; int FontSize; float FontMtx[4]; int ImageFormat; int RevImage; int NPatterns; int MxPatterns; PsPatPtr Patterns; int ClipType; PsClipRec Clip; int InFrame; int XOff; int YOff; PsFillEnum InTile; int ImgSkip; - int ImgBClr; - int ImgFClr; + PsOutColor ImgBClr; + PsOutColor ImgFClr; int ImgX; int ImgY; int ImgW; int ImgH; int SclW; int SclH; Bool isRaw; int pagenum; int start_image; } PsOutRec; typedef struct PsOutRec_ *PsOutPtr; extern void S_Flush(PsOutPtr self); extern void S_OutNum(PsOutPtr self, float num); extern void S_OutTok(PsOutPtr self, char *tok, int cr); #else typedef struct PsOutRec_ *PsOutPtr; #endif /* USE_PSOUT_PRIVATE */ extern PsOutPtr PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, int res, int wd, int ht, Bool raw); extern void PsOut_EndFile(PsOutPtr self, int closeFile); extern void PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res, int wd, int ht); extern void PsOut_EndPage(PsOutPtr self); extern void PsOut_DirtyAttributes(PsOutPtr self); extern void PsOut_Comment(PsOutPtr self, char *comment); extern void PsOut_Offset(PsOutPtr self, int x, int y); extern void PsOut_Clip(PsOutPtr self, int clpTyp, PsClipPtr clpinf); -extern void PsOut_Color(PsOutPtr self, int clr); +extern void PsOut_Color(PsOutPtr self, PsOutColor clr); extern void PsOut_FillRule(PsOutPtr self, PsRuleEnum rule); extern void PsOut_LineAttrs(PsOutPtr self, int wd, PsCapEnum cap, PsJoinEnum join, int nDsh, int *dsh, int dshOff, - int bclr); + PsOutColor bclr); extern void PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso); extern void PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso); extern void PsOut_Polygon(PsOutPtr self, int nPts, PsPointPtr pts); extern void PsOut_FillRect(PsOutPtr self, int x, int y, int w, int h); extern void PsOut_FillArc(PsOutPtr self, int x, int y, int w, int h, float ang1, float ang2, PsArcEnum style); extern void PsOut_Lines(PsOutPtr self, int nPts, PsPointPtr pts); extern void PsOut_Points(PsOutPtr self, int nPts, PsPointPtr pts); extern void PsOut_DrawRect(PsOutPtr self, int x, int y, int w, int h); extern void PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h, float ang1, float ang2); extern void PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, - int bclr); -extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr); + PsOutColor bclr); +extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, PsOutColor bclr); -extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, +extern void PsOut_BeginImage(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, int w, int h, int sw, int sh, int format); -extern void PsOut_BeginImageIM(PsOutPtr self, int bclr, int fclr, int x, int y, +extern void PsOut_BeginImageIM(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, int w, int h, int sw, int sh, int format); extern void PsOut_EndImage(PsOutPtr self); extern void PsOut_OutImageBytes(PsOutPtr self, int nBytes, char *bytes); extern void PsOut_BeginFrame(PsOutPtr self, int xoff, int yoff, int x, int y, int w, int h); extern void PsOut_EndFrame(PsOutPtr self); extern int PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, - PsFillEnum type, int bclr, int fclr); + PsFillEnum type, PsOutColor bclr, PsOutColor fclr); extern void PsOut_EndPattern(PsOutPtr self); extern void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type); extern void PsOut_RawData(PsOutPtr self, char *data, int len); extern int PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname); extern int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); extern int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); extern int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset); extern void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex); extern void PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl); extern void PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl); extern void PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso); extern void PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso); #endif