First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xprint / pcl / PclPixel.c
blobf41af272f0311d80f2df4099d23d7a11914190e8
1 /*******************************************************************
2 **
3 ** *********************************************************
4 ** *
5 ** * File: PclPixel.c
6 ** *
7 ** * Contents:
8 ** * Pixel-drawing code for the PCL DDX driver
9 ** *
10 ** * Created: 10/23/95
11 ** *
12 ** *********************************************************
13 **
14 ********************************************************************/
16 (c) Copyright 1996 Hewlett-Packard Company
17 (c) Copyright 1996 International Business Machines Corp.
18 (c) Copyright 1996 Sun Microsystems, Inc.
19 (c) Copyright 1996 Novell, Inc.
20 (c) Copyright 1996 Digital Equipment Corp.
21 (c) Copyright 1996 Fujitsu Limited
22 (c) Copyright 1996 Hitachi, Ltd.
24 Permission is hereby granted, free of charge, to any person obtaining a copy
25 of this software and associated documentation files (the "Software"), to deal
26 in the Software without restriction, including without limitation the rights
27 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28 copies of the Software, and to permit persons to whom the Software is
29 furnished to do so, subject to the following conditions:
31 The above copyright notice and this permission notice shall be included in
32 all copies or substantial portions of the Software.
34 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 Except as contained in this notice, the names of the copyright holders shall
42 not be used in advertising or otherwise to promote the sale, use or other
43 dealings in this Software without prior written authorization from said
44 copyright holders.
47 #ifdef HAVE_DIX_CONFIG_H
48 #include <dix-config.h>
49 #endif
51 #include <stdio.h>
53 #include "windowstr.h"
54 #include "gcstruct.h"
56 #include "Pcl.h"
58 void
59 PclPolyPoint( pDrawable, pGC, mode, nPoints, pPoints )
60 DrawablePtr pDrawable;
61 GCPtr pGC;
62 int mode;
63 int nPoints;
64 xPoint *pPoints;
66 char t[80];
67 FILE *outFile;
68 int xoffset, yoffset;
69 BoxRec box;
70 int xloc, yloc, i;
71 #if 0
72 XpContextPtr pCon;
73 PclContextPrivPtr cPriv;
74 PclPixmapPrivPtr pPriv;
75 #endif
77 if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
78 return;
80 xoffset = pDrawable->x;
81 yoffset = pDrawable->y;
84 * Enter HP-GL/2 and change the line style to one in which only
85 * the vertices of the specified polyline are drawn. We must also
86 * temporarily change the line width so that only a single pixel
87 * is drawn. Then move to the first possible location.
89 xloc = pPoints[0].x + pDrawable->x;
90 yloc = pPoints[0].y + pDrawable->y;
92 sprintf( t, "\27%%0BPW0,0;LT0;PU;PA%d,%d", xloc, yloc );
93 SEND_PCL( outFile, t );
96 * Check each point against the clip region. If it is outside the
97 * region, don't send the PCL to the printer.
100 for( i = 0; i < nPoints; i++ )
102 if( POINT_IN_REGION( pGC->pScreen, pGC->clientClip, xloc, yloc, &box ) )
104 sprintf( t, ",%d,%d", xloc, yloc );
105 SEND_PCL( outFile, t );
108 if( mode == CoordModeOrigin )
110 xloc = pPoints[i+1].x + xoffset;
111 yloc = pPoints[i+1].y + yoffset;
113 else
115 xloc += pPoints[i+1].x;
116 yloc += pPoints[i+1].y;
120 #if 0
122 * Change the line style and width back to what they were before
123 * this routine was called. No, this isn't pretty...
125 if( pDrawable->type == DRAWABLE_WINDOW )
127 pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
128 cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
129 cPriv->changeMask = GCLineWidth | GCLineStyle;
131 else
133 pPriv =
134 ((PixmapPtr)pDrawable)->devPrivates[PclPixmapPrivateIndex].ptr;
135 pPriv->changeMask = GCLineWidth | GCLineStyle;
137 #endif
139 PclUpdateDrawableGC( pGC, pDrawable, &outFile );
142 * Go back to PCL
144 SEND_PCL( outFile, "\27%0A" );
147 void
148 PclPushPixels( pGC, pBitmap, pDrawable, width, height, x, y )
149 GCPtr pGC;
150 PixmapPtr pBitmap;
151 DrawablePtr pDrawable;
152 int width;
153 int height;
154 int x;
155 int y;