1 /***********************************************************
3 Copyright 1987, 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
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.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 ******************************************************************/
47 #ifdef HAVE_DIX_CONFIG_H
48 #include <dix-config.h>
54 #include "cfbmskbits.h"
57 /* Dashed bresenham line */
61 pdashIndex
, pDash
, numInDashList
, pdashOffset
, isDoubleDash
,
63 signdx
, signdy
, axis
, x1
, y1
, e
, e1
, e2
, len
)
65 int *pdashIndex
; /* current dash */
66 unsigned char *pDash
; /* dash list */
67 int numInDashList
; /* total length of dash list */
68 int *pdashOffset
; /* offset into current dash */
70 CfbBits
*addrl
; /* pointer to base of bitmap */
71 int nlwidth
; /* width in longwords of bitmap */
72 int signdx
, signdy
; /* signs of directions */
73 int axis
; /* major axis (Y_AXIS or X_AXIS) */
74 int x1
, y1
; /* initial point */
75 register int e
; /* error accumulator */
76 register int e1
; /* bresenham increments */
78 int len
; /* length of line */
81 register PixelType
*addrp
;
83 register int e3
= e2
-e1
;
87 CfbBits xorFg
, andFg
, xorBg
, andBg
;
91 CfbBits xorPiQxlFg
[3], andPiQxlFg
[3], xorPiQxlBg
[3], andPiQxlBg
[3];
96 dashOffset
= *pdashOffset
;
97 dashIndex
= *pdashIndex
;
98 isCopy
= (rrops
[0].rop
== GXcopy
&& rrops
[1].rop
== GXcopy
);
100 xorFg
= rrops
[0].xor & 0xffffff;
101 andFg
= rrops
[0].and & 0xffffff;
102 xorBg
= rrops
[1].xor & 0xffffff;
103 andBg
= rrops
[1].and & 0xffffff;
104 xorPiQxlFg
[0] = xorFg
| (xorFg
<< 24);
105 xorPiQxlFg
[1] = (xorFg
>> 8) | (xorFg
<< 16);
106 xorPiQxlFg
[2] = (xorFg
>> 16) | (xorFg
<< 8);
107 andPiQxlFg
[0] = andFg
| (andFg
<< 24);
108 andPiQxlFg
[1] = (andFg
>> 8) | (andFg
<< 16);
109 andPiQxlFg
[2] = (andFg
>> 16) | (andFg
<< 8);
110 xorPiQxlBg
[0] = xorBg
| (xorBg
<< 24);
111 xorPiQxlBg
[1] = (xorBg
>> 8) | (xorBg
<< 16);
112 xorPiQxlBg
[2] = (xorBg
>> 16) | (xorBg
<< 8);
113 andPiQxlBg
[0] = andBg
| (andBg
<< 24);
114 andPiQxlBg
[1] = (andBg
>> 8) | (andBg
<< 16);
115 andPiQxlBg
[2] = (andFg
>> 16) | (andBg
<< 8);
117 xorFg
= rrops
[0].xor;
118 andFg
= rrops
[0].and;
119 xorBg
= rrops
[1].xor;
120 andBg
= rrops
[1].and;
122 dashRemaining
= pDash
[dashIndex
] - dashOffset
;
123 if ((thisDash
= dashRemaining
) >= len
)
126 dashRemaining
-= len
;
128 e
= e
-e1
; /* to make looping easier */
130 #define BresStep(minor,major) {if ((e += e1) >= 0) { e += e3; minor; } major;}
134 if (dashIndex == numInDashList) \
136 dashRemaining = pDash[dashIndex]; \
137 if ((thisDash = dashRemaining) >= len) \
139 dashRemaining -= len; \
147 #define Loop(store) while (thisDash--) {\
149 BresStep(addrb+=signdy3,addrb+=signdx3) \
151 /* point to first point */
153 addrp
= (PixelType
*)(addrl
) + (y1
* nlwidth
);
154 addrb
= (char *)addrp
+ x1
* 3;
157 #define Loop(store) while (thisDash--) {\
159 BresStep(addrp+=signdy,addrp+=signdx) \
161 /* point to first point */
163 addrp
= (PixelType
*)(addrl
) + (y1
* nlwidth
) + x1
;
167 signdx3
= signdx
* 3;
168 signdy3
= signdy
* sizeof (CfbBits
);
187 #define body_copy(pix) { \
188 addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
189 switch((unsigned long)addrb & 3){ \
191 *addrp = (*addrp & 0xFF000000)|((pix)[0] & 0xFFFFFF); \
194 *addrp = (*addrp & 0xFF)|((pix)[2] & 0xFFFFFF00); \
197 *addrp = (*addrp & 0xFFFFFF)|((pix)[0] & 0xFF000000); \
198 *(addrp+1) = (*(addrp+1) & 0xFFFF0000)|((pix)[1] & 0xFFFF); \
201 *addrp = (*addrp & 0xFFFF)|((pix)[1] & 0xFFFF0000); \
202 *(addrp+1) = (*(addrp+1) & 0xFFFFFF00)|((pix)[2] & 0xFF); \
206 #endif /* PSZ == 24 */
214 Loop(body_copy(xorPiQxlBg
))
223 Loop(body_copy(xorPiQxlFg
))
236 #define body_set(and, xor) { \
237 addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
238 switch((unsigned long)addrb & 3){ \
240 *addrp = (*addrp & ((and)[0]|0xFF000000)) ^ ((xor)[0] & 0xFFFFFF); \
243 *addrp = (*addrp & ((and)[2]|0xFF)) ^ ((xor)[2] & 0xFFFFFF00); \
246 *addrp = (*addrp & ((and)[0]|0xFFFFFF)) ^ ((xor)[0] & 0xFF000000); \
247 *(addrp+1)=(*(addrp+1)&((and)[1]|0xFFFF0000)) ^ ((xor)[1]&0xFFFF); \
250 *addrp = (*addrp & ((and)[1]|0xFFFF)) ^ ((xor)[1] & 0xFFFF0000); \
251 *(addrp+1)=(*(addrp+1)&((and)[2]|0xFFFFFF00)) ^ ((xor)[2] & 0xFF); \
262 Loop(body_set(andPiQxlBg
, xorPiQxlBg
))
264 Loop(*addrp
= DoRRop(*addrp
,andBg
, xorBg
))
271 Loop(body_set(andPiQxlFg
, xorPiQxlFg
))
273 Loop(*addrp
= DoRRop(*addrp
,andFg
, xorFg
))
282 #else /* !PIXEL_ADDR */
284 register CfbBits tmp
;
285 CfbBits startbit
, bit
;
287 /* point to longword containing first point */
289 addrl
= (addrl
+ (y1
* nlwidth
) + ((x1
*3) >> 2);
291 addrl
= (addrl
+ (y1
* nlwidth
) + (x1
>> PWSH
));
293 signdy
= signdy
* nlwidth
;
296 startbit
= cfbmask
[0];
299 startbit
= cfbmask
[(PPW
-1)<<1];
300 bit
= cfbmask
[(x1
& 3)<<1];
302 startbit
= cfbmask
[PPW
-1];
303 bit
= cfbmask
[x1
& PIM
];
307 #define X_Loop(store) while(thisDash--) {\
309 BresStep(addrl += signdy, \
311 bit = SCRRIGHT(bit,1); \
313 bit = SCRLEFT(bit,1); \
320 #define Y_Loop(store) while(thisDash--) {\
322 BresStep(if (signdx > 0) \
323 bit = SCRRIGHT(bit,1); \
325 bit = SCRLEFT(bit,1); \
334 #define X_Loop(store) while(thisDash--) {\
336 BresStep(addrl += signdy, \
338 bit = SCRRIGHT(bit,1); \
340 bit = SCRLEFT(bit,1); \
347 #define Y_Loop(store) while(thisDash--) {\
349 BresStep(if (signdx > 0) \
350 bit = SCRRIGHT(bit,1); \
352 bit = SCRLEFT(bit,1); \
369 X_Loop(*addrl
= DoMaskRRop(*addrl
, andBg
, xorBg
, bit
));
374 X_Loop(*addrl
= DoMaskRRop(*addrl
, andFg
, xorFg
, bit
));
388 Y_Loop(*addrl
= DoMaskRRop(*addrl
, andBg
, xorBg
, bit
));
393 Y_Loop(*addrl
= DoMaskRRop(*addrl
, andFg
, xorFg
, bit
));
402 *pdashIndex
= dashIndex
;
403 *pdashOffset
= pDash
[dashIndex
] - dashRemaining
;