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"
58 /* Solid bresenham line */
60 e2 is used less often than e1, so it's not in a register
64 cfbBresS(rop
, and, xor, addrl
, nlwidth
, signdx
, signdy
, axis
, x1
, y1
, e
, e1
,
68 CfbBits
*addrl
; /* pointer to base of bitmap */
69 int nlwidth
; /* width in longwords of bitmap */
71 int signdy
; /* signs of directions */
72 int axis
; /* major axis (Y_AXIS or X_AXIS) */
73 int x1
, y1
; /* initial point */
74 register int e
; /* error accumulator */
75 register int e1
; /* bresenham increments */
77 int len
; /* length of line */
79 register int e3
= e2
-e1
;
81 CfbBits piQxelXor
[3],piQxelAnd
[3];
83 int nlwidth3
, signdx3
;
86 register PixelType
*addrp
; /* Pixel pointer */
90 /* point to first point */
93 addrp
= (PixelType
*)(addrl
) + (y1
* nlwidth
);
94 addrb
= (char *)addrp
+ x1
* 3;
96 piQxelXor
[0] = (xor << 24) | xor;
97 piQxelXor
[1] = (xor << 16)| (xor >> 8);
98 piQxelXor
[2] = (xor << 8) | (xor >> 16);
99 piQxelAnd
[0] = (and << 24) | and;
100 piQxelAnd
[1] = (and << 16)| (and >> 8);
101 piQxelAnd
[2] = (and << 8) | (and >> 16);
103 addrp
= (PixelType
*)(addrl
) + (y1
* nlwidth
) + x1
;
107 e
= e
-e1
; /* to make looping easier */
109 nlwidth3
= nlwidth
* sizeof (CfbBits
);
110 signdx3
= signdx
* 3;
131 addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
132 switch((unsigned long)addrb & 3){ \
134 *addrp = ((*addrp)&0xFF000000)|(piQxelXor[0] & 0xFFFFFF); \
137 *addrp = ((*addrp)&0xFF)|(piQxelXor[2] & 0xFFFFFF00); \
140 *addrp = ((*addrp)&0xFFFFFF)|(piQxelXor[0] & 0xFF000000); \
141 *(addrp+1) = ((*(addrp+1))&0xFFFF0000)|(piQxelXor[1] & 0xFFFF); \
144 *addrp = ((*addrp)&0xFFFF)|(piQxelXor[1] & 0xFFFF0000); \
145 *(addrp+1) = ((*(addrp+1))&0xFFFFFF00)|(piQxelXor[2] & 0xFF); \
158 #else /* PSZ == 24 */
169 #endif /* PSZ == 24 */
177 case 3: body
case 2: body
case 1: body
187 else /* not GXcopy */
192 addrp
= (PixelType
*)((unsigned long)addrb
& ~0x03);
193 switch((unsigned long)addrb
& 3){
195 *addrp
= (*addrp
& (piQxelAnd
[0]|0xFF000000))
196 ^ (piQxelXor
[0] & 0xFFFFFF);
199 *addrp
= (*addrp
& (piQxelAnd
[2]|0xFF))
200 ^ (piQxelXor
[2] & 0xFFFFFF00);
203 *addrp
= (*addrp
& (piQxelAnd
[0]|0xFFFFFF))
204 ^ (piQxelXor
[0] & 0xFF000000);
205 *(addrp
+1) = (*(addrp
+1) & (piQxelAnd
[1]|0xFFFF0000))
206 ^ (piQxelXor
[1] & 0xFFFF);
209 *addrp
= (*addrp
& (piQxelAnd
[1]|0xFFFF))
210 ^ (piQxelXor
[1] & 0xFFFF0000);
211 *(addrp
+1) = (*(addrp
+1) & (piQxelAnd
[2]|0xFFFFFF00))
212 ^ (piQxelXor
[2] & 0xFF);
222 #else /* PSZ == 24 */
223 *addrp
= DoRRop (*addrp
, and, xor);
231 #endif /* PSZ == 24 */
234 #else /* !PIXEL_ADDR */
235 register CfbBits tmp
, bit
;
236 CfbBits leftbit
, rightbit
;
238 /* point to longword containing first point */
240 addrl
= (addrl
+ (y1
* nlwidth
) + ((x1
* 3) >>2);
242 addrl
= (addrl
+ (y1
* nlwidth
) + (x1
>> PWSH
));
246 e
= e
-e1
; /* to make looping easier */
248 leftbit
= cfbmask
[0];
250 rightbit
= cfbmask
[(PPW
-1)<<1];
251 bit
= cfbmask
[(x1
& 3)<<1];
253 rightbit
= cfbmask
[PPW
-1];
254 bit
= cfbmask
[x1
& PIM
];
263 *addrl
= DoMaskRRop (*addrl
, and, xor, bit
);
264 bit
= SCRRIGHT(bit
,1);
282 *addrl
= DoMaskRRop (*addrl
, and, xor, bit
);
284 bit
= SCRLEFT(bit
,1);
304 *addrl
= DoMaskRRop (*addrl
, and, xor, bit
);
308 bit
= SCRRIGHT(bit
,1);
323 *addrl
= DoMaskRRop (*addrl
, and, xor, bit
);
327 bit
= SCRLEFT(bit
,1);