First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xprint / ps / PsArc.c
blob0684307ddab062d279eafe6a19cd427847c9373b
1 /*
3 Copyright 1996, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
27 * (c) Copyright 1996 Hewlett-Packard Company
28 * (c) Copyright 1996 International Business Machines Corp.
29 * (c) Copyright 1996 Sun Microsystems, Inc.
30 * (c) Copyright 1996 Novell, Inc.
31 * (c) Copyright 1996 Digital Equipment Corp.
32 * (c) Copyright 1996 Fujitsu Limited
33 * (c) Copyright 1996 Hitachi, Ltd.
35 * Permission is hereby granted, free of charge, to any person obtaining
36 * a copy of this software and associated documentation files (the
37 * "Software"), to deal in the Software without restriction, including
38 * without limitation the rights to use, copy, modify, merge, publish,
39 * distribute, sublicense, and/or sell copies of the Software, and to
40 * permit persons to whom the Software is furnished to do so, subject
41 * to the following conditions:
43 * The above copyright notice and this permission notice shall be included
44 * in all copies or substantial portions of the Software.
46 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
49 * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
50 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
51 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52 * SOFTWARE.
54 * Except as contained in this notice, the names of the copyright holders
55 * shall not be used in advertising or otherwise to promote the sale, use
56 * or other dealings in this Software without prior written authorization
57 * from said copyright holders.
60 /*******************************************************************
62 ** *********************************************************
63 ** *
64 ** * File: PsArc.c
65 ** *
66 ** * Contents: Arc-drawing code for the PS DDX driver
67 ** *
68 ** * Created By: Roger Helmendach (Liberty Systems)
69 ** *
70 ** * Copyright: Copyright 1996 The Open Group, Inc.
71 ** *
72 ** *********************************************************
73 **
74 ********************************************************************/
76 #ifdef HAVE_DIX_CONFIG_H
77 #include <dix-config.h>
78 #endif
80 #include <stdio.h>
82 #include "Ps.h"
83 #include "gcstruct.h"
84 #include "windowstr.h"
86 void
87 PsPolyArc(
88 DrawablePtr pDrawable,
89 GCPtr pGC,
90 int nArcs,
91 xArc *pArcs)
93 if( pDrawable->type==DRAWABLE_PIXMAP )
95 DisplayElmPtr elm;
96 PixmapPtr pix = (PixmapPtr)pDrawable;
97 PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
98 DisplayListPtr disp;
99 GCPtr gc;
101 if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
103 disp = PsGetFreeDisplayBlock(priv);
105 elm = &disp->elms[disp->nelms];
106 elm->type = PolyArcCmd;
107 elm->gc = gc;
108 elm->c.arcs.nArcs = nArcs;
109 elm->c.arcs.pArcs = (xArc *)xalloc(nArcs*sizeof(xArc));
110 memcpy(elm->c.arcs.pArcs, pArcs, nArcs*sizeof(xArc));
111 disp->nelms += 1;
113 else
115 int i;
116 PsOutPtr psOut;
117 ColormapPtr cMap;
119 if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
120 PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
121 PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
122 PsLineAttrs(psOut, pGC, cMap);
123 for( i=0 ; i<nArcs ; i++ )
125 PsOut_DrawArc(psOut, (int)pArcs[i].x, (int)pArcs[i].y,
126 (int)pArcs[i].width, (int)pArcs[i].height,
127 (float)pArcs[i].angle1/64.,
128 (float)pArcs[i].angle2/64.);
133 void
134 PsPolyFillArc(
135 DrawablePtr pDrawable,
136 GCPtr pGC,
137 int nArcs,
138 xArc *pArcs)
140 if( pDrawable->type==DRAWABLE_PIXMAP )
142 DisplayElmPtr elm;
143 PixmapPtr pix = (PixmapPtr)pDrawable;
144 PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
145 DisplayListPtr disp;
146 GCPtr gc;
148 if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
150 disp = PsGetFreeDisplayBlock(priv);
152 elm = &disp->elms[disp->nelms];
153 elm->type = PolyFillArcCmd;
154 elm->gc = gc;
155 elm->c.arcs.nArcs = nArcs;
156 elm->c.arcs.pArcs = (xArc *)xalloc(nArcs*sizeof(xArc));
157 memcpy(elm->c.arcs.pArcs, pArcs, nArcs*sizeof(xArc));
158 disp->nelms += 1;
160 else
162 int i;
163 PsOutPtr psOut;
164 PsArcEnum styl;
165 ColormapPtr cMap;
167 if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
168 PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
169 PsSetFillColor(pDrawable, pGC, psOut, cMap);
170 PsLineAttrs(psOut, pGC, cMap);
171 if( pGC->arcMode==ArcChord ) styl = PsChord;
172 else styl = PsPieSlice;
173 for( i=0 ; i<nArcs ; i++ )
175 PsOut_FillArc(psOut, (int)pArcs[i].x, (int)pArcs[i].y,
176 (int)pArcs[i].width, (int)pArcs[i].height,
177 (float)pArcs[i].angle1/64.,
178 (float)pArcs[i].angle2/64., styl);