diff options
Diffstat (limited to 'Xprint/ps/PsInit.c')
-rw-r--r-- | Xprint/ps/PsInit.c | 90 |
1 files changed, 59 insertions, 31 deletions
diff --git a/Xprint/ps/PsInit.c b/Xprint/ps/PsInit.c index a7a63343d..f2e064921 100644 --- a/Xprint/ps/PsInit.c +++ b/Xprint/ps/PsInit.c @@ -71,9 +71,8 @@ in this Software without prior written authorization from The Open Group. ** * Copyright: Copyright 1996 The Open Group, Inc. ** * ** ********************************************************* -** +** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsInit.c,v 1.13tsi Exp $ */ #include <stdio.h> #include <string.h> @@ -84,6 +83,7 @@ in this Software without prior written authorization from The Open Group. #include "Ps.h" #include "mi.h" +#include "micmap.h" #include "AttrValid.h" #include "../../mfb/mfb.h" @@ -101,6 +101,10 @@ int PsContextPrivateIndex; int PsPixmapPrivateIndex; int PsWindowPrivateIndex; +#ifdef GLXEXT +extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); +#endif /* GLXEXT */ + Bool InitializePsDriver(ndx, pScreen, argc, argv) int ndx; @@ -109,12 +113,18 @@ InitializePsDriver(ndx, pScreen, argc, argv) char **argv; { #if 0 + int maxXres, maxYres, maxWidth, maxHeight; + int maxRes, maxDim, numBytes; PsScreenPrivPtr pPriv; #endif + char **printerNames; + int numPrinters; int nVisuals; int nDepths; VisualPtr visuals; DepthPtr depths; + VisualID defaultVisual; + int rootDepth; /* * Register this driver's InitContext function with the print @@ -188,7 +198,7 @@ InitializePsDriver(ndx, pScreen, argc, argv) visuals[1].vid = FakeClientID(0); visuals[1].class = PseudoColor; - visuals[1].bitsPerRGBValue = 0; + visuals[1].bitsPerRGBValue = 8; visuals[1].ColormapEntries = 256; visuals[1].nplanes = 8; visuals[1].redMask = 0x0; @@ -200,27 +210,35 @@ InitializePsDriver(ndx, pScreen, argc, argv) depths[0].depth = 24; depths[0].numVids = 1; - depths[0].vids = &visuals[0].vid; + 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 = &visuals[1].vid; + depths[1].vids = (VisualID *)xalloc(sizeof(VisualID)); + depths[1].vids[0] = visuals[1].vid; -/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 24 BIT */ -/* miScreenInit(pScreen, (pointer)0, - pScreen->width, pScreen->height, - pScreen->width / (pScreen->mmWidth / 25.40), - pScreen->height / (pScreen->mmHeight / 25.40), - 0, 24, nDepths, - depths, visuals[1].vid, nVisuals, visuals); */ + /* 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, + &rootDepth, &defaultVisual, 0, 0, 0); + } +#endif /* GLXEXT */ -/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 8 BIT */ miScreenInit(pScreen, (pointer)0, - pScreen->width, pScreen->height, - (int) (pScreen->width / (pScreen->mmWidth / 25.40)), - (int) (pScreen->height / (pScreen->mmHeight / 25.40)), - 0, 8, nDepths, - depths, visuals[1].vid, nVisuals, visuals); + 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); if( cfbCreateDefColormap(pScreen)==FALSE ) return FALSE; @@ -243,7 +261,7 @@ AllocatePsPrivates(ScreenPtr pScreen) sizeof(PsWindowPrivRec)); PsContextPrivateIndex = XpAllocateContextPrivateIndex(); - XpAllocateContextPrivate(PsContextPrivateIndex, + XpAllocateContextPrivate(PsContextPrivateIndex, sizeof(PsContextPrivRec)); PsPixmapPrivateIndex = AllocatePixmapPrivateIndex(); @@ -278,7 +296,7 @@ PsInitContext(pCon) XpDriverFuncsPtr pFuncs; PsContextPrivPtr pConPriv; char *server, *attrStr; - + /* * Initialize the attribute store for this printer. */ @@ -304,18 +322,23 @@ PsInitContext(pCon) pFuncs->GetMediumDimensions = PsGetMediumDimensions; pFuncs->GetReproducibleArea = PsGetReproducibleArea; pFuncs->SetImageResolution = PsSetImageResolution; - + /* * Set up the context privates */ pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; - pConPriv->jobFileName = (char *)NULL; - pConPriv->pJobFile = (FILE *)NULL; - - pConPriv->getDocClient = (ClientPtr)NULL; - pConPriv->getDocBufSize = 0; + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + pConPriv->jobFileName = (char *)NULL; + pConPriv->pJobFile = (FILE *)NULL; + pConPriv->dash = (unsigned char *)NULL; + pConPriv->validGC = 0; + pConPriv->getDocClient = (ClientPtr)NULL; + pConPriv->getDocBufSize = 0; + pConPriv->pPsOut = NULL; + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; /* * document-attributes-supported @@ -323,15 +346,15 @@ PsInitContext(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)) == NULL) + + strlen(PAGE_ATT_VAL) + 6)) == NULL) { return BadAlloc; } - sprintf(attrStr, "*%s:\t%s %s %s", + sprintf(attrStr, "*%s:\t%s %s %s", DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL); XpAugmentAttributes( pCon, XPPrinterAttr, attrStr); xfree(attrStr); - + /* * job-attributes-supported */ @@ -344,7 +367,7 @@ PsInitContext(pCon) sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL); XpAugmentAttributes(pCon, XPPrinterAttr, attrStr); xfree(attrStr); - + /* * xp-page-attributes-supported */ @@ -375,7 +398,7 @@ PsDestroyContext(pCon) { PsContextPrivPtr pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; - + if( pConPriv->pJobFile!=(FILE *)NULL ) { fclose(pConPriv->pJobFile); @@ -388,6 +411,11 @@ PsDestroyContext(pCon) pConPriv->jobFileName = (char *)NULL; } + PsFreeFontInfoRecords(pConPriv); + + /* Reset context to make sure we do not use any stale/invalid/obsolete data */ + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + /*### free up visuals/depths ###*/ return Success; |