First import
[xorg_rtime.git] / xorg-server-1.4 / fb / fbline.c
blob2cee123ae0ca2eabfd99cad601b8efc5fd781e44
1 /*
2 * Copyright © 1998 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #ifdef HAVE_DIX_CONFIG_H
24 #include <dix-config.h>
25 #endif
27 #include "fb.h"
29 void
30 fbZeroLine (DrawablePtr pDrawable,
31 GCPtr pGC,
32 int mode,
33 int npt,
34 DDXPointPtr ppt)
36 int x1, y1, x2, y2;
37 int x, y;
38 int dashOffset;
40 x = pDrawable->x;
41 y = pDrawable->y;
42 x1 = ppt->x;
43 y1 = ppt->y;
44 dashOffset = pGC->dashOffset;
45 while (--npt)
47 ++ppt;
48 x2 = ppt->x;
49 y2 = ppt->y;
50 if (mode == CoordModePrevious)
52 x2 += x1;
53 y2 += y1;
55 fbSegment (pDrawable, pGC, x1 + x, y1 + y,
56 x2 + x, y2 + y,
57 npt == 1 && pGC->capStyle != CapNotLast,
58 &dashOffset);
59 x1 = x2;
60 y1 = y2;
64 void
65 fbZeroSegment (DrawablePtr pDrawable,
66 GCPtr pGC,
67 int nseg,
68 xSegment *pSegs)
70 int dashOffset;
71 int x, y;
72 Bool drawLast = pGC->capStyle != CapNotLast;
74 x = pDrawable->x;
75 y = pDrawable->y;
76 while (nseg--)
78 dashOffset = pGC->dashOffset;
79 fbSegment (pDrawable, pGC,
80 pSegs->x1 + x, pSegs->y1 + y,
81 pSegs->x2 + x, pSegs->y2 + y,
82 drawLast,
83 &dashOffset);
84 pSegs++;
88 void
89 fbFixCoordModePrevious (int npt,
90 DDXPointPtr ppt)
92 int x, y;
94 x = ppt->x;
95 y = ppt->y;
96 npt--;
97 while (npt--)
99 ppt++;
100 x = (ppt->x += x);
101 y = (ppt->y += y);
105 void
106 fbPolyLine (DrawablePtr pDrawable,
107 GCPtr pGC,
108 int mode,
109 int npt,
110 DDXPointPtr ppt)
112 void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt);
114 if (pGC->lineWidth == 0)
116 line = fbZeroLine;
117 #ifndef FBNOPIXADDR
118 if (pGC->fillStyle == FillSolid &&
119 pGC->lineStyle == LineSolid &&
120 REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1)
122 switch (pDrawable->bitsPerPixel) {
123 case 8: line = fbPolyline8; break;
124 case 16: line = fbPolyline16; break;
125 #ifdef FB_24BIT
126 case 24: line = fbPolyline24; break;
127 #endif
128 case 32: line = fbPolyline32; break;
131 #endif
133 else
135 if (pGC->lineStyle != LineSolid)
136 line = miWideDash;
137 else
138 line = miWideLine;
140 (*line) (pDrawable, pGC, mode, npt, ppt);
143 void
144 fbPolySegment (DrawablePtr pDrawable,
145 GCPtr pGC,
146 int nseg,
147 xSegment *pseg)
149 void (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pseg);
151 if (pGC->lineWidth == 0)
153 seg = fbZeroSegment;
154 #ifndef FBNOPIXADDR
155 if (pGC->fillStyle == FillSolid &&
156 pGC->lineStyle == LineSolid &&
157 REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1)
159 switch (pDrawable->bitsPerPixel) {
160 case 8: seg = fbPolySegment8; break;
161 case 16: seg = fbPolySegment16; break;
162 #ifdef FB_24BIT
163 case 24: seg = fbPolySegment24; break;
164 #endif
165 case 32: seg = fbPolySegment32; break;
168 #endif
170 else
172 seg = miPolySegment;
174 (*seg) (pDrawable, pGC, nseg, pseg);