1 /***********************************************************
3 Copyright (c) 1987 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of the X Consortium shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from the X Consortium.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 ******************************************************************/
49 #ifdef HAVE_DIX_CONFIG_H
50 #include <dix-config.h>
59 /* Dashed bresenham line */
62 if (!--dashRemaining) { \
63 if (++ dashIndex == numInDashList) \
65 dashRemaining = pDash[dashIndex]; \
72 afbBresD(pdashIndex
, pDash
, numInDashList
, pdashOffset
, isDoubleDash
,
73 addrlbase
, nlwidth
, sizeDst
, depthDst
,
74 signdx
, signdy
, axis
, x1
, y1
, e
, e1
, e2
, len
, rrops
, bgrrops
)
75 int *pdashIndex
; /* current dash */
76 unsigned char *pDash
; /* dash list */
77 int numInDashList
; /* total length of dash list */
78 int *pdashOffset
; /* offset into current dash */
80 PixelType
*addrlbase
; /* pointer to base of bitmap */
81 int nlwidth
; /* width in longwords of bitmap */
84 int signdx
, signdy
; /* signs of directions */
85 int axis
; /* major axis (Y_AXIS or X_AXIS) */
86 int x1
, y1
; /* initial point */
87 register int e
; /* error accumulator */
88 register int e1
; /* bresenham increments */
90 int len
; /* length of line */
92 unsigned char *bgrrops
;
94 register int yinc
; /* increment to next scanline, in bytes */
95 register PixelType
*addrl
;
96 register int e3
= e2
-e1
;
97 register unsigned long bit
;
98 PixelType leftbit
= mfbGetmask(0); /* leftmost bit to process in new word */
99 PixelType rightbit
= mfbGetmask(PPW
-1); /* rightmost bit to process in new word */
110 dashOffset
= *pdashOffset
;
111 dashIndex
= *pdashIndex
;
112 dashRemaining
= pDash
[dashIndex
] - dashOffset
;
113 /* point to longword containing first point */
115 yinc
= signdy
* nlwidth
;
116 e
= e
-e1
; /* to make looping easier */
121 for (d
= 0; d
< depthDst
; d
++) {
122 addrl
= afbScanline(addrlbase
, x1
, y1
, nlwidth
);
123 addrlbase
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
130 bit
= mfbGetmask(x1
& PIM
);
138 if (axis
== X_AXIS
) {
141 if (rop
== RROP_BLACK
)
143 else if (rop
== RROP_WHITE
)
145 else if (rop
== RROP_INVERT
)
149 afbScanlineInc(addrl
, yinc
);
152 bit
= SCRRIGHT(bit
,1);
153 if (!bit
) { bit
= leftbit
;addrl
++; }
158 if (rop
== RROP_BLACK
)
160 else if (rop
== RROP_WHITE
)
162 else if (rop
== RROP_INVERT
)
166 afbScanlineInc(addrl
, yinc
);
169 bit
= SCRLEFT(bit
,1);
170 if (!bit
) { bit
= rightbit
;addrl
--; }
174 } /* if X_AXIS */ else {
177 if (rop
== RROP_BLACK
)
179 else if (rop
== RROP_WHITE
)
181 else if (rop
== RROP_INVERT
)
185 bit
= SCRRIGHT(bit
,1);
186 if (!bit
) { bit
= leftbit
;addrl
++; }
189 afbScanlineInc(addrl
, yinc
);
194 if (rop
== RROP_BLACK
)
196 else if (rop
== RROP_WHITE
)
198 else if (rop
== RROP_INVERT
)
202 bit
= SCRLEFT(bit
,1);
203 if (!bit
) { bit
= rightbit
;addrl
--; }
206 afbScanlineInc(addrl
, yinc
);
211 } /* for (d = ...) */
212 *pdashIndex
= dashIndex
;
213 *pdashOffset
= pDash
[dashIndex
] - dashRemaining
;