First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xprint / pcl / PclSpans.c
blob4951899ab7c9dc46569a64bcf4241d1e389adc4f
1 /*******************************************************************
2 **
3 ** *********************************************************
4 ** *
5 ** * File: PclSpans.c
6 ** *
7 ** * Contents:
8 ** * Code to set and fill spans in the PCL DDX
9 ** *
10 ** * Created: 10/23/95
11 ** *
12 ** *********************************************************
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.
48 #ifdef HAVE_DIX_CONFIG_H
49 #include <dix-config.h>
50 #endif
52 #include "Pcl.h"
53 #include "gcstruct.h"
54 #include "windowstr.h"
56 void
57 PclFillSpans(
58 DrawablePtr pDrawable,
59 GCPtr pGC,
60 int nSpans,
61 DDXPointPtr pPoints,
62 int *pWidths,
63 int fSorted)
65 char t[80];
66 FILE *outFile;
67 int xoffset, yoffset;
68 xRectangle *rects, *r;
69 RegionPtr fillRegion, region = 0;
70 int i;
71 int nbox;
72 BoxPtr pbox;
74 if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
75 return;
78 * Build a region out of the spans
80 rects = (xRectangle *)xalloc( nSpans * sizeof( xRectangle ) );
81 xoffset = pDrawable->x;
82 yoffset = pDrawable->y;
84 for( i = 0, r = rects; i < nSpans; i++, r++ )
86 r->x = pPoints[i].x + xoffset;
87 r->y = pPoints[i].y + yoffset;
88 r->width = pWidths[i];
89 r->height = 1;
91 fillRegion = RECTS_TO_REGION( pGC->pScreen, nSpans, rects, ( fSorted ) ?
92 CT_YSORTED : CT_UNSORTED );
95 * Intersect this region with the clip region. Whatever's left,
96 * should be filled.
98 REGION_INTERSECT( pGC->pScreen, region, fillRegion, pGC->clientClip );
100 pbox = REGION_RECTS( region );
101 nbox = REGION_NUM_RECTS( region );
103 /* Enter HP-GL/2 */
104 SEND_PCL( outFile, "\27%0B" );
106 while( nbox )
108 sprintf( t, "PU%d,%d;RR%d,%d;", pbox->x1, pbox->y1,
109 pbox->x2, pbox->y2 );
110 SEND_PCL( outFile, t );
112 nbox--;
113 pbox++;
116 /* Go back to PCL */
117 SEND_PCL( outFile, "\27%0A" );
120 * Clean up the temporary regions
122 REGION_DESTROY( pGC->pScreen, fillRegion );
123 REGION_DESTROY( pGC->pScreen, region );
124 xfree( rects );
127 void
128 PclSetSpans(
129 DrawablePtr pDrawable,
130 GCPtr pGC,
131 char *pSrc,
132 DDXPointPtr pPoints,
133 int *pWidths,
134 int nSpans,
135 int fSorted)